Sie sind auf Seite 1von 4

www.pudn.com > Create_AcDb3dPolyline.rar > acrxEntryPoint.

cpp, change:2004-1007,size:3697b

1. // (C) Copyright 2002-2003 by Autodesk, Inc.


2. //
3. // Permission to use, copy, modify, and distribute this software
in
4. // object code form for any purpose and without fee is hereby gra
nted,
5. // provided that the above copyright notice appears in all copies
and
6. // that both that copyright notice and the limited warranty and
7. // restricted rights notice below appear in all supporting
8. // documentation.
9. //
10. // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
11. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
12. // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, IN
C.
13. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
14. // UNINTERRUPTED OR ERROR FREE.
15. //
16. // Use, duplication, or disclosure by the U.S. Government is subj
ect to
17. // restrictions set forth in FAR 52.227-19 (Commercial Computer
18. // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
19. // (Rights in Technical Data and Computer Software), as applicabl
e.
20. //
21.
22. //---------------------------------------------------------------------------23. //----- acrxEntryPoint.h
24. //---------------------------------------------------------------------------25. #include "StdAfx.h"
26.
27. //---------------------------------------------------------------------------28. #define szRDS _RXST("asdk")
29.
30. //---------------------------------------------------------------------------31. //----- ObjectARX EntryPoint
32. class CtestApp : public AcRxArxApp {

33.
34. public:
35.
CtestApp () : AcRxArxApp () {}
36.
37.
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
38.
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg
(pkt) ;
39.
// TODO: Add your initialization code here
40.
41.
return (retCode) ;
42.
}
43.
44.
virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
45.
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadApp
Msg (pkt) ;
46.
// TODO: Add your code here
47.
48.
return (retCode) ;
49.
}
50.
51.
virtual void RegisterServerComponents () {
52.
//----- Self-register COM server upon loading.
53.
if ( FAILED(::DllRegisterServer ()) )
54.
acutPrintf (_RXST("Failed to register COM server.\n"))
;
55.
}
56.
57.
void getUcsToWcsMatrix(AcGeMatrix3d& m, AcDbDatabase* db)
58.
{
59.
ASSERT(db != NULL);
60.
61.
if (!acdbUcsMatrix(m, db)) {
62.
m.setToIdentity();
63.
ASSERT(0);
64.
}
65.
}
66.
67.
void ucsToWcs(AcGePoint3dArray& ptArray)
68.
{
69.
AcDbDatabase* db = acdbHostApplicationServices()>workingDatabase();
70.
ASSERT(db != NULL);
71.
72.
AcGeMatrix3d m;
73.
getUcsToWcsMatrix(m, db);
74.
75.
int len = ptArray.length();
76.
for (int i=0; i<len; i++)
77.
ptArray[i] = m * ptArray[i];
78.
}
79.

80.
81.

// ----- asdktest._test command (do not rename)


static void asdktest_test(void)
{
// Add your code for command asdktest._test here
int i;

82.

83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.

AcDbObjectId lineId;
AcDbObjectId ptId;
AcGePoint3d Pt;
AcDb3dPolyline *pLine;
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()>getSymbolTable(pBlockTable, AcDb::kForRead);

94.
95.
96.

AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRec
ord,AcDb::kForWrite);
97.
pBlockTable->close();
98.
99.
AcGeMatrix3d ucsToWcsMat;
100.
101.
acdbUcsMatrix(ucsToWcsMat);
102.
103.
AcGePoint3dArray vertices;
104.
105.
for(i=1;i=10;i++)
106.
{
107.
Pt.x=i;
108.
Pt.y=i;
109.
Pt.z=0.0;
110.
vertices.append(Pt);
111.
}
112.
113.
pLine = new AcDb3dPolyline(AcDb::k3dSimplePoly, ver
tices);
114.
pLine->setDatabaseDefaults();
115.
116.
pBlockTableRecord->appendAcDbEntity(lineId, pLine);
117.
118.
119.
120.
121.

122.

pBlockTableRecord->close();
pLine->close();
}
} ;

//---------------------------------------------------------------------------123.
IMPLEMENT_ARX_ENTRYPOINT(CtestApp)
124.
125.
ACED_ARXCOMMAND_ENTRY_AUTO(CtestApp, asdktest, _test, test,
ACRX_CMD_TRANSPARENT, NULL)

Das könnte Ihnen auch gefallen