//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
#define szRDS _RXST("")
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CAddLineApp : public AcRxArxApp {
public:
CAddLineApp() : AcRxArxApp() {}
virtual AcRx::AppRetCode On_kInitAppMsg(void *pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kInitAppMsg(pkt);
return (retCode);
}
virtual AcRx::AppRetCode On_kUnloadAppMsg(void *pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kUnloadAppMsg(pkt);
return (retCode);
}
virtual void RegisterServerComponents() { }
class LineJig : public AcEdJig {
public:
AcGePoint3d pStartPoint;
AcGePoint3d pEndPoint;
AcDbLine *mpEntity;
AcString dispString;
public:
LineJig() : mpEntity(NULL) {};
~LineJig() {};
DragStatus startJig()
{
setDispPrompt(dispString);
return drag();
}
protected:
virtual DragStatus sampler() {
return GetEndPoint();
}
virtual Adesk::Boolean update() {
mpEntity->setEndPoint(pEndPoint);
return true;
}
virtual AcDbEntity *entity() const {
return ((AcDbEntity *)mpEntity);
}
AcEdJig::DragStatus GetEndPoint()
{
AcGePoint3d oldPnt = pEndPoint;
AcGePoint3d newPnt;
AcEdJig::DragStatus status = acquirePoint(newPnt, oldPnt);
//- If valid input
if (status == AcEdJig::kNormal)
{
if (newPnt.isEqualTo(oldPnt))
return (AcEdJig::kNoChange);
pEndPoint = newPnt;
}
return (status);
}
};
static void RivilisAddLine2() {
ads_point pp1;
AcGePoint3d pStart, pEnd;
if (acedGetPoint(NULL, L"\nУкажите начальную точку: ", pp1) == RTNORM)
{
acdbUcs2Wcs(pp1, asDblArray(pStart), false);
AcDbObjectPointer<AcDbLine> pLine; pLine.create();
pLine->setDatabaseDefaults();
pLine->setStartPoint(pStart); pLine->setEndPoint(pStart);
LineJig jig;
jig.mpEntity = pLine;
jig.pStartPoint = jig.pEndPoint = pStart;
jig.dispString = L"\nУкажите конечную точку: ";
if (jig.startJig() != AcEdJig::DragStatus::kNormal)
return;
pEnd = jig.pEndPoint; // Конечная точка отрезка
// Добавляем отрезок в чертеж
AcDbBlockTableRecordPointer pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForWrite);
if (pSpace.openStatus() == Acad::eOk)
pSpace->appendAcDbEntity(pLine);
}
}
};
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CAddLineApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CAddLineApp, Rivilis, AddLine2, AddLine2, ACRX_CMD_MODAL, NULL)