|
View Code
1 static void lzxARX_AcDbDatabaseCreatePolyline(void)
2 {
3 //设置多段线的四个矢量
4 AcGePoint3dArray ptArr;
5 ptArr.setLogicalLength(4);
6 for (int i = 0; i < 4; i++)
7 {
8 ptArr[i].set((double)(i/2), (double)(i%2), 0.0);
9 }
10
11 //动态创建一个AcDb2dPolyline对象,在ptArr中给出四个顶点位置
12 //缺省的线宽为0
13 AcDb2dPolyline *pNewPline = new AcDb2dPolyline(AcDb::k2dSimplePoly, ptArr, 0.0, Adesk::kTrue);
14
15 //设置实体颜色
16 pNewPline->setColorIndex(3);
17
18 //获得块表对象指针
19 AcDbBlockTable *pBlockTable;
20 acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);
21
22 //获得模型空间块表记录指针
23 AcDbBlockTableRecord *pBlockTableRecord;
24 pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
25
26 pBlockTable->close();
27
28 //将多段线对象添加数据库中并获得其对象ID
29 AcDbObjectId plineObjId;
30 pBlockTableRecord->appendAcDbEntity(plineObjId, pNewPline);
31
32 pBlockTableRecord->close();
33
34 //设置多段线对象所在的层为0层
35 pNewPline->setLayer(L"0");
36
37 pNewPline->close();
38
39 iterate(plineObjId);
40 } |
|