- UID
- 186670
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2004-10-24
- 最后登录
- 1970-1-1
|
发表于 2006-8-20 17:35:59
|
显示全部楼层
我这里假设 图层的名字为 "testLayer"为例子以说明:
void HYTEST()
{
// Note: we add the layer's name is 'TestLayer'...
char layerName[20]="TestLayer";
// First ,check the drawing there is or not have the 'DASHED' linetype
AcDbLinetypeTable *pLinetypeTable;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLinetypeTable,AcDb::kForRead);
if(!pLinetypeTable->has("Dashed"))
{
acutPrintf("\n**Add linetype 'Dashed'");
pLinetypeTable->close();
if(acdbHostApplicationServices()->workingDatabase()->loadLineTypeFile("DASHED","ACADISO.LIN")!=Acad::eOk)
{
acutPrintf("\n**Error on load linetype 'Dashed'...");
return;
}
}
else
pLinetypeTable->close();
// Second ,add the new layer to the drawing and set the layer linetype to 'Dashed'
AcDbLayerTable *pLayerTable;
AcDbObjectId eId;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLinetypeTable,AcDb::kForRead);
pLinetypeTable->getAt("Dashed",eId);
pLinetypeTable->close();
if(pLayerTable->has(layerName))
{
acutPrintf("\n**Error,the layer exist...");
pLayerTable->close();
return;
}
AcDbLayerTableRecord *pNewLayer=new AcDbLayerTableRecord();
pNewLayer->setName(layerName);
pNewLayer->setLinetypeObjectId(eId);
pLayerTable->add(pNewLayer);
pNewLayer->close();
pLayerTable->close();
} |
|