|
- void cmdHatch()
- {
- ads采用name sset = { 0,0 };
- AcDbObjectIdArray outsideIds; // IDs of outer curve(s)/region
- AcDbObjectIdArray holeIds; // IDs of inner text(s)/pline(s)/region that shall create ONE hole.
- acutPrintf(采用T("\nSelect entities that form the outer conture: "));
- if (acedSSGet(NULL, NULL, NULL, NULL, sset) == RTNORM)
- {
- outsideIds.setLogicalLength(0);
- Selset2ObjIdArray(sset, outsideIds);
- acedSSFree(sset);
- }
- else
- return;
- Acad::ErrorStatus es;
- AcDbDatabase* db = acdbHostApplicationServices()->workingDatabase();
- AcDbHatch* hatch = new AcDbHatch();
- hatch->setDatabaseDefaults(db);
- es = hatch->appendLoop(AcDbHatch::kExternal, outsideIds);
- int stat = RTNORM;
- while (stat==RTNORM)
- {
- acutPrintf(采用T("\nSelect entities that form one inner hole: "));
- stat = acedSSGet(NULL, NULL, NULL, NULL, sset);
- if (stat == RTNORM)
- {
- holeIds.setLogicalLength(0);
- Selset2ObjIdArray(sset, holeIds);
- acedSSFree(sset);
- es = hatch->appendLoop(AcDbHatch::kDefault, holeIds);
- }
- }
- hatch->evaluateHatch();
- postToDb(db, hatch);
- }
- long Selset2ObjIdArray(ads采用name sset, AcDbObjectIdArray& objIdArr) {
- Adesk::Int32 selSetLen = 0, i;
- if (acedSSLength(sset, &selSetLen) != RTNORM)
- return -1;
- ads采用name ename;
- AcDbObjectId objId;
- for (i = 0; i < selSetLen; i++) {
- if (acedSSName(sset, i, ename) == RTNORM) {
- if (acdbGetObjectId(objId, ename) == Acad::eOk)
- objIdArr.append(objId);
- }
- }
- return selSetLen;
- }
复制代码 |
|