//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "axlock.h"
#include "resource.h"
//-----------------------------------------------------------------------------
#define szRDS _RXST("")
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CTestCmdArxApp : public AcRxArxApp {
public:
CTestCmdArxApp () : AcRxArxApp () {}
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
// TODO: Load dependencies here
// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
// TODO: Add your initialization code here
return (retCode) ;
}
virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
// TODO: Add your code here
// You *must* call On_kUnloadAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
// TODO: Unload dependencies here
return (retCode) ;
}
virtual void RegisterServerComponents () {
}
static void RanTestCmd () {
if (curDoc() == NULL) return;
AcDbDatabase *pDb = curDoc()->database();
AcAxDocLock doclock(pDb);
AcDbObjectId newLayerId;
resbuf _cmdecho; _cmdecho.restype = RTSHORT; _cmdecho.resval.rint = 0;
acedGetVar(_T("CMDECHO"),&_cmdecho);
if (_cmdecho.resval.rint == 0) {
_cmdecho.resval.rint = 1;
acedSetVar(_T("CMDECHO"),&_cmdecho);
_cmdecho.resval.rint = 0;
}
{
AcDbLayerTablePointer pLT(pDb->layerTableId(), AcDb::kForRead);
if (pLT.openStatus() != Acad::eOk) return;
if (pLT->getAt(_T("New Layer"), newLayerId) != Acad::eOk) {
AcDbLayerTableRecordPointer pLTR; pLTR.create();
pLTR->setName(_T("New Layer"));
if (pLT->upgradeOpen() != Acad::eOk) return;
if (pLT->add(newLayerId,pLTR) != Acad::eOk) return;
}
}
pDb->setClayer(newLayerId);
AcCmColor _cecolor = pDb->cecolor();
AcDbObjectId _clayer = pDb->clayer();
AcCmColor color; color.setColorIndex(30);
pDb->setCecolor(color);
AcDb::LineWeight _celweight = pDb->celweight();
pDb->setCelweight(AcDb::kLnWt100);
resbuf *rb = acutBuildList(RTSTR,_T("_INSERT"), RTSTR,_T("PICKET"),RTSTR,_T("_SCALE"), RTSTR,_T("1"), NULL);
acedCmd(rb);
while (true) {
resbuf rbNames; rbNames.restype = RTSTR; rbNames.resval.rstring = NULL;
acedGetVar(_T("CMDNAMES"), &rbNames);
if (rbNames.resval.rstring != NULL && CString(rbNames.resval.rstring).MakeUpper().Find(_T("INSERT")) >= 0) {
acutRelRb(rb); rb = acutBuildList(RTSTR,_T("\\"),NULL);
if (acedCmd(rb) != RTNORM) break;
} else break;
}
acedSetVar(_T("CMDECHO"),&_cmdecho);
pDb->setClayer(_clayer);
pDb->setCecolor(_cecolor);
pDb->setCelweight(_celweight);
}
} ;
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CTestCmdArxApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CTestCmdArxApp, Ran, TestCmd, TestCmd, ACRX_CMD_MODAL, NULL)