- 积分
- 434
- 明经币
- 个
- 注册时间
- 2009-2-18
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
AcDbObjectId CCreateEnt::CreatLayer (char layername[100],int nNewColor,int Weight,char linetype[50]) { // 获得当前图形的层表 AcDbLayerTable *pLayerTbl; acdbHostApplicationServices()->workingDatabase() ->getLayerTable(pLayerTbl, AcDb::kForWrite);
// 创建新的层表记录 AcDbObjectId layerTblRcdId; AcDbLayerTableRecord *pLayerTblRcd; pLayerTblRcd = new AcDbLayerTableRecord(); pLayerTblRcd->setName(layername); AcCmColor color; color.setColorIndex(nNewColor); pLayerTblRcd->setColor(color); AcDb::ineWeight lineWeight =(AcDb::ineWeight)Weight; pLayerTblRcd->setLineWeight(lineWeight); AcDbLinetypeTable *pLinetypeTbl; acdbHostApplicationServices()->workingDatabase() ->getLinetypeTable(pLinetypeTbl, AcDb::kForWrite); AcDbObjectId linetypeId; pLinetypeTbl->getAt(linetype, linetypeId); pLayerTblRcd->setLinetypeObjectId(linetypeId);
// 将新建的层表记录添加到层表中
pLayerTbl->add(layerTblRcdId, pLayerTblRcd); pLayerTbl->close(); pLayerTblRcd->close(); return layerTblRcdId; }
这是 我 编写的 创建图层的 函数,我在调用时如果调用一次 运行可以成功,但当调用2次 或多次的时候 CAD就运行错误,请 高手给解决一下! 谢谢了! 以下我是的调用过程,在下初学者,请多多指教! char name2[]="02"; char name3[]="03"; char linetype1[]="CENTER"; char linetype2[]="DASHED"; char linetype3[]="Continuous"; CCreateEnt::CreatLayer(name1,1,0,linetype1); CCreateEnt::CreatLayer(name2,50,0,linetype2); CCreateEnt::CreatLayer(name3,100,30,linetype3); |
|