objectARX 填充 AcDbHatch
操作:
1. 画三条边组成闭合曲线,三角形;
2. 输入命令,选择三条边,回车完成填充;
static void MyGroupMyCommand6() {// Put your command code hereacutPrintf(TEXT("\nHello world! make padding"));// 只读方式打开处于活动状态的图形数据库块表AcDbBlockTable *pTable;acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pTable, AcDb::kForRead);// 只写方式打开模型空间所在块表记录AcDbBlockTableRecord *pRecord;pTable->getAt(ACDB_MODEL_SPACE, pRecord, AcDb::kForWrite);// 创建一条原点到点(100,100,0)的直线AcDbLine *pLine = new AcDbLine(AcGePoint3d(100, 10, 0), AcGePoint3d(10, 100, 0));pRecord->appendAcDbEntity(pLine);// 创建一条原点到点(100,100,0)的直线AcDbLine *pLine1 = new AcDbLine(AcGePoint3d(100, 10, 0), AcGePoint3d(50, 50, 0));pRecord->appendAcDbEntity(pLine1);// 创建一条原点到点(100,100,0)的直线AcDbLine *pLine2 = new AcDbLine(AcGePoint3d(10, 100, 0), AcGePoint3d(50, 50, 0));pRecord->appendAcDbEntity(pLine2);// 提示用户选择填充边界ads_name ss;int rt = acedSSGet(NULL, NULL, NULL, NULL, ss);// 初始化填充边界的ID数组AcDbObjectIdArray objIds;if (rt == RTNORM){int length;acedSSLength(ss, &length);for (int i = 0; i < length; i++){ads_name ent;acedSSName(ss, i, ent);AcDbObjectId objId;acdbGetObjectId(objId, ent);objIds.append(objId);}}acedSSFree(ss); // 释放选择集Acad::ErrorStatus es;AcDbHatch *pHatch = new AcDbHatch();// 设置填充平面AcGeVector3d normal(0, 0, 1);pHatch->setNormal(normal);pHatch->setElevation(0);// 设置关联性pHatch->setAssociative(true);// 设置填充图案pHatch->setPattern(AcDbHatch::kPreDefined, _T("SOLID"));// 添加填充边界es = pHatch->appendLoop(AcDbHatch::kExternal, objIds);// 显示填充对象es = pHatch->evaluateHatch();// 添加到模型空间AcDbObjectId hatchId;pRecord->appendAcDbEntity(hatchId,pHatch);// 如果是关联性的填充,将填充对象与边界绑定,以便使其能获得边界对象修改的通知AcDbEntity *pEnt;for (int i = 0; i < objIds.length(); i++){es = acdbOpenAcDbEntity(pEnt, objIds[i],AcDb::kForWrite);if (es == Acad::eOk){// 添加一个永久反应器pEnt->addPersistentReactor(hatchId);pEnt->close();}} pLine->close();pLine1->close();pLine2->close();pRecord->close();pTable->close();}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!