- 积分
- 1665
- 明经币
- 个
- 注册时间
- 2003-3-31
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
AcDbObjectId blockId; int retCode = 0; AcDbBlockTable *pBlockTable = NULL; AcDbBlockTableRecord* pBlockRecord = new AcDbBlockTableRecord; pBlockRecord->setName("样式"); AcGePoint3d basePoint(asPnt3d(pt)); pBlockRecord->setOrigin(basePoint); acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pBlockTable, AcDb::kForWrite); pBlockTable->add(blockId, pBlockRecord); pBlockTable->close();
AcDbPolyline *pPoly=new AcDbPolyline(); //形成闭合多段线 已经定义pd1,pd2,pd3; pPolyA->addVertexAt(0,pd1,0,-1,-1); pPolyA->addVertexAt(1,pd2,0,-1,-1); pPolyA->addVertexAt(2,pd3,0,-1,-1); pPolyA->setClosed(Adesk::kTrue);
AcDbObjectId Id; pBlockRecord->appendAcDbEntity(IdA, pPoly); pPoly->close(); AcDbObjectIdArray IdArr; IdArr.append(IdA);
AcGeVector3d normal(0,0,1); AcDbHatch *p_AcDbHatch1=new AcDbHatch(); p_AcDbHatch1->setNormal(normal); p_AcDbHatch1->setElevation(0.0); p_AcDbHatch1->setAssociative(true); p_AcDbHatch1->setPatternScale(5); p_AcDbHatch1->evaluateHatch(false);
if(Acad::eOk!=p_AcDbHatch1->appendLoop(AcDbHatch::kDefault ,IdArr)) { delete p_AcDbHatch1; return ; }
//执行下面这条语句时候出现错误提示。AutoCAD运行挺长时间才出现错误提示
//用VC调试,好像是进程已经Exit(0)终止了 if( Acad::eOk!=p_AcDbHatch1->setPattern(AcDbHatch::kPreDefined,"SOLID")) { delete p_AcDbHatch1; return ; } if( Acad::eOk!=p_AcDbHatch1->setHatchStyle(AcDbHatch::kNormal)) { delete p_AcDbHatch1; return ; } if(Acad::eOk!=p_AcDbHatch1->evaluateHatch(false)) {
delete p_AcDbHatch1; return ; } AcDbObjectId HatchId1; pBlockRecord->appendAcDbEntity(HatchId1,p_AcDbHatch1); p_AcDbHatch1->close();
上面是定义块的一部分代码,在当前文档中使用没有问题,但是用executeInApplicationContext(void (*procAddr)(void *)pFunc,void *pData ) const = 0;
函数切换文档,打开另一个文件,时候,在pFunc函数中使用,执行上述代码出现的错误;新文档已经设置了当前文档和活动文档,并且设置了写保护,加入实体没有问题。
请帮忙分析一下,是什么原因引起? |
|