- UID
- 5043
- 积分
- 1347
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-13
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[sell=5]
[pcode=cpp,true]//This program shows how to create named ucs and set it current
//Author I. R. Nagwani
//Developer Consulting Group, Autodesk
//Date Written 8-12-99
#include "dbsymtb.h"
#include "rxregsvc.h" // ARX linker
#include "dbapserv.h" // Host application services
#include "acdb.h" // acdb definitions
#include "aced.h" // aced stuff
#include "adslib.h" // RXADS definitions
// This command registers an ARX command.
void AddCommand(const char* cmdGroup, const char* cmdInt, const char* cmdLoc,
const int cmdFlags, const AcRxFunctionPtr cmdProc, const int idLocal = -1);
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_MSG
void InitApplication();
void UnloadApplication();
//}}AFX_ARX_MSG
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_ADDIN_FUNCS
//}}AFX_ARX_ADDIN_FUNCS
void asdktest()
{
Acad::ErrorStatus es;
AcDbUCSTableRecord *myUCS = new AcDbUCSTableRecord;
//define your own ucs
AcGePoint3d origin_point(0,0,0);
AcGeVector3d UCSXaxis(0,1,0);
AcGeVector3d UCSYaxis(1,0,0);
myUCS->setOrigin(origin_point);
myUCS->setXAxis(UCSXaxis);
myUCS->setYAxis(UCSYaxis);
es=myUCS->setName( "MyUCS");
if (es != Acad::eOk)
{
acutPrintf("\nFailed to set name");
return;
}
AcDbObjectId UCSId;
AcDbSymbolTable *pUCSTable;
if (acdbHostApplicationServices()->workingDatabase()->getUCSTable(pUCSTable,AcDb::kForWrite)==Acad::eOk)
{
es=pUCSTable->add(UCSId,myUCS);
es=pUCSTable->close();
es= myUCS->close();
}
else
{
acutPrintf("\nFailed to get UCS table");
return;
}
//To set the current UCS, I accessed the active AcDbViewportTableRecord
// and used setUCS to set the UCS I created as current.
AcDbViewportTable *pVT;
es = acedVports2VportTableRecords();
if (es != Acad::eOk)
{
acutPrintf("\nFailed to load vport info into vport table records");
return;
}
es=acdbHostApplicationServices()->workingDatabase()->getViewportTable(pVT,AcDb::kForRead);
if (es != Acad::eOk)
{
acutPrintf("\nFailed to get vport table");
pVT->close();
return;
}
AcDbViewportTableIterator* pIter = NULL;
es=pVT->newIterator(pIter);
if (es != Acad::eOk)
{
acutPrintf("\nFailed to get vport table");
pVT->close();
delete pIter;
return;
}
for (pIter->start();!pIter->done();pIter->step())
{
AcDbViewportTableRecord* pRec;
es=pIter->getRecord(pRec,AcDb::kForWrite); //it should be open for write mode
if (es != Acad::eOk)
{
acutPrintf("\nFailed to get vport table record");
pVT->close();
pRec->close();
delete pIter;
return;
}
char* name=NULL;
es=pRec->getName(name);
if (es != Acad::eOk)
{
acutPrintf("\nFailed to get name from vport table");
pVT->close();
pRec->close();
delete pIter;
return;
}
if (stricmp(name,"*ACTIVE")==0)
{
es=pRec->setUcs(UCSId);
}
es=pRec->close();
}
es=acedVportTableRecords2Vports(); //force update
es=pVT->close();
delete pIter;
return ;
}
/////////////////////////////////////////////////////////////////////////////
// ObjectARX EntryPoint
extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
switch (msg) {
case AcRx::kInitAppMsg:
// Comment out the following line if your
// application should be locked into memory
acrxDynamicLinker->unlockApplication(pkt);
acrxDynamicLinker->registerAppMDIAware(pkt);
InitApplication();
break;
case AcRx::kUnloadAppMsg:
UnloadApplication();
break;
}
return AcRx::kRetOK;
}
// Init this application. Register your
// commands, reactors...
void InitApplication()
{
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_INIT
AddCommand("ASDK", "TEST", "TEST", ACRX_CMD_TRANSPARENT | ACRX_CMD_USEPICKSET, asdktest);
//}}AFX_ARX_INIT
// TODO: add your initialization functions
}
// Unload this application. Unregister all objects
// registered in InitApplication.
void UnloadApplication()
{
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_EXIT
acedRegCmds->removeGroup("ASDK");
//}}AFX_ARX_EXIT
// TODO: clean up your application
}
// This functions registers an ARX command.
// It can be used to read the localized command name
// from a string table stored in the resources.
void AddCommand(const char* cmdGroup, const char* cmdInt, const char* cmdLoc,
const int cmdFlags, const AcRxFunctionPtr cmdProc, const int idLocal)
{
char cmdLocRes[65];
// If idLocal is not -1, it's treated as an ID for
// a string stored in the resources.
if (idLocal != -1) {
HMODULE hModule = GetModuleHandle("asdkucsarx.arx");
// Load strings from the string table and register the command.
::LoadString(hModule, idLocal, cmdLocRes, 64);
acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLocRes, cmdFlags, cmdProc);
} else
// idLocal is -1, so the 'hard coded'
// localized function name is used.
acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLoc, cmdFlags, cmdProc);
}
[/pcode]
[/sell]
|
评分
-
查看全部评分
|