void Additional_Class::addXdata( AcDbObjectId entID, CString xdataStr, CString xdataNameStr ) { AcDbEntity * pEnt; struct resbuf * pRb; if(Acad::eOk != acdbOpenAcDbEntity(pEnt, entID, AcDb::kForWrite)) { pEnt->close(); return; } TCHAR * tempTchar = CString2TCHAR(xdataNameStr); //TCHAR strAppName[] = tempTchar; acdbRegApp(tempTchar); TCHAR * typeName = CString2TCHAR(xdataStr); struct resbuf * pTemp; pTemp = pEnt->xData(tempTchar); pRb = acutBuildList(AcDb::kDxfRegAppName, tempTchar, AcDb::kDxfXdAsciiString, typeName, RTNONE); pEnt->setXData(pRb); acutRelRb(pRb); pEnt->close(); return; }
// 查找连接点junctionPt关联的分支图元(包含隐形的图元) static void FindLinesByPoint( const AcGePoint3d& junctionPt, AcDbObjectIdArray& objIds ) { AcDbBlockTable* pBlkTbl; acdbHostApplicationServices()->workingDatabase()->getSymbolTable( pBlkTbl, AcDb::kForRead ); AcDbBlockTableRecord* pBlkTblRcd; pBlkTbl->getAt( ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForRead ); pBlkTbl->close(); AcDbBlockTableRecordIterator* pBlkTblRcdItr; pBlkTblRcd->newIterator( pBlkTblRcdItr ); for ( pBlkTblRcdItr->start(); !pBlkTblRcdItr->done(); pBlkTblRcdItr->step() ) { // 不采用transaction的方法查找LinkedGE, // 等价于排除当前正在以write状态编辑的LinkedGE // 重要(***) AcDbEntity* pEnt = 0; if( Acad::eOk != pBlkTblRcdItr->getEntity( pEnt, AcDb::kForRead ) ) continue; LinkedGE* pEdge = LinkedGE::cast( pEnt ); if( pEdge != 0 ) { AcGePoint3d startPt, endPt; pEdge->getSEPoint( startPt, endPt ); if( startPt == junctionPt || endPt == junctionPt ) { objIds.append( pEdge->objectId() ); } } pEnt->close(); } delete pBlkTblRcdItr; pBlkTblRcd->close(); }
void frgExtractTopologicalEntsFromLinesAlgm::_extract_vertices_from_lines(std::vector<Vertex2dsOnSegment2d> &seg_pnts_pairs, const AcDbObjectIdArray &ids) { AcDbEntity *entity = NULL; acedSetStatusBarProgressMeter(_T("正在提取每根线段上的节点..."), 0, ids.length()); for (int i = 0; i < ids.length(); i++) { acdbOpenAcDbEntity(entity, ids[i], AcDb::kForRead); if (entity == NULL) continue; if (entity->isA() != AcDbLine::desc()) { entity->close(); continue; } AcDbLine *line = (AcDbLine *)entity; Vertex2dsOnSegment2d stru; stru.seg.set(AcGePoint2d(line->startPoint().x, line->startPoint().y), AcGePoint2d(line->endPoint().x, line->endPoint().y)); entity->close(); _extract_from_seg(stru); seg_pnts_pairs.push_back(stru); acedSetStatusBarProgressMeterPos(i); } acedRestoreStatusBar(); }
void frgExtractTopologicalEntsFromLinesAlgm::_extract_from_seg(Vertex2dsOnSegment2d &stru) { // - 获取相关的线段(相交、重合) AcDbObjectIdArray ids; _search_related_segs(ids, stru.seg); // - 分为两类进行处理:相交和重叠 // -- 增加起点和终点 rlVertex2d *v = NULL; stru.vertex2ds.insert(std::make_pair(0.0, v)); stru.vertex2ds.insert(std::make_pair(1.0, v)); // -- 处理每一个线段 AcDbEntity *entity = NULL; for (int i = 0; i < ids.length(); i++) { acdbOpenAcDbEntity(entity, ids[i], AcDb::kForRead); if (entity == NULL) continue; if (entity->isA() != AcDbLine::desc()) { entity->close(); continue; } AcDbLine *_line = (AcDbLine *)entity; AcGeLineSeg2d _seg(AcGePoint2d(_line->startPoint().x, _line->startPoint().y), AcGePoint2d(_line->endPoint().x, _line->endPoint().y)); _line->close(); _extract_vertices(stru, _seg); } }
BOOL CDetailShow::OnInitDialog() { CAcUiDialog::OnInitDialog(); // TODO: 在此添加额外的初始化 long len = m_objIds.length(); //取得选择集的长度 //遍历选择集中的实体,将其打开并修改其颜色为红色 for (int i =0;i<len;i++) { ads_name entres; AcDbObjectId objId; AcDbEntity *obj; Acad::ErrorStatus es; es = acdbOpenAcDbEntity(obj, m_objIds[i], AcDb::kForRead, true); if (es == Acad::eOk) { LPCTSTR str; str = obj->isA()->name(); m_listBox.AddString(str); obj->close(); } } return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
void readDatabase() { // Use kFalse to create an empty database. AcDbDatabase *pDb = new AcDbDatabase(Adesk::kFalse); // Use readDwgFile to load the DWG file. acutPrintf(_T("\nRead file \"d:\\temp\\testfile.dwg\".")); if(Acad::eOk != pDb->readDwgFile(_T("d:\\temp\\testfile.dwg"))) return; // Get the BlockTable. AcDbBlockTable *pBTable = NULL; pDb->getSymbolTable(pBTable, AcDb::kForRead); // Get the ModelSpace. AcDbBlockTableRecord *pRecord = NULL; pBTable->getAt(ACDB_MODEL_SPACE, pRecord, AcDb::kForRead); pBTable->close(); // Get new iterator. AcDbBlockTableRecordIterator *pItr = NULL; pRecord->newIterator(pItr); AcDbEntity *pEnt = NULL; for (pItr->start(); !pItr->done(); pItr->step()) { pItr->getEntity(pEnt, AcDb::kForRead); acutPrintf(_T("\nclassname: %s"), (pEnt->isA())->name()); pEnt->close(); } pRecord->close(); delete pItr; delete pDb; }
static void CopyBack( AcDbEntity* pSrcEnt, const AcDbObjectId& objId ) { AcDbEntity* pEnt; acdbOpenAcDbEntity( pEnt, objId, AcDb::kForWrite ); pEnt->copyFrom( pSrcEnt ); pEnt->close(); }
// 使用常规的Open/Close机制 static void UpdateEntity2( const AcDbObjectId& objId ) { AcDbEntity* pEnt; if( Acad::eOk != acdbOpenObject( pEnt, objId, AcDb::kForWrite ) ) return; pEnt->recordGraphicsModified( true ); // 标签图元状态已修改,需要更新图形 pEnt->close(); }
CString Additional_Class::Get_Xdata(AcDbObjectId EntID, CString Xdata_Ref ) { AcDbEntity *pEnt; acdbOpenAcDbEntity(pEnt, EntID, AcDb::kForRead); struct resbuf *pRb; pRb = pEnt->xData(Xdata_Ref); if (pRb != NULL) { struct resbuf *pTemp; pTemp = pRb; pTemp = pTemp->rbnext; pEnt->close(); return pTemp->resval.rstring; } acutRelRb(pRb); pEnt->close(); return ""; }
// ----- AsdkSelectionFilterUI.SubentSel command (do not rename) static void AsdkSelectionFilterUI_SubentSel(void) { // we have to allow duplicates; otherwise, the xref would be selectable // only once (because the main entity is the one that counts). setAllowDuplicateSelection(curDoc(), true); ads_name sset, eName; AcDbObjectId id; // "_:n" gives us nested entities // if (RTNORM == acedSSGet("_:n", NULL, NULL, NULL, sset)) { acutPrintf("\n"); long len = 0; acedSSLength(sset, &len); for (long i = 0; i < len; i++)// For each entity in sset { resbuf *rb = NULL; // We use ssnamex() here, because the regular ssname() // would give only the main entity (the xref) // if (RTNORM == acedSSNameX(&rb, sset, i))//Get the sub entity { resbuf *rbWalk = rb; while (NULL != rbWalk) { if (RTENAME == rbWalk->restype) { eName[0] = rbWalk->resval.rlname[0]; eName[1] = rbWalk->resval.rlname[1]; if(Acad::eOk == acdbGetObjectId(id, eName)) { acutPrintf("Entity %d: <%x>", i, id.asOldId()); AcDbEntity *pEnt; if (Acad::eOk == acdbOpenObject(pEnt, id, AcDb::kForRead)) { acutPrintf("(%s)\n", pEnt->isA()->name()); pEnt->close(); } else acutPrintf("\nCouldn't open object"); } rbWalk = NULL; //force quit out of loop } else rbWalk = rbWalk->rbnext; } acutRelRb(rb); } } acedSSFree(sset); } setAllowDuplicateSelection(curDoc(), false); }
//------------------------------------------------------------------------------------------- // // 功能: 将从AcDbObject派生数据库对象保存到实体的扩展词典中 // // 作者:Qin H.X. // // 日期:200709 // // 历史: // 2007.10.08 修改 by Qin H.X. // //---------------------------------------------------------------------------------------------- // - CSCH081.AddAttribute command (do not rename) static void CSCH081AddAttribute(void) { AcDbObjectId dictObjId,eId, attId; AcDbDictionary* pDict; //选择管道(多义线) ads_name en; ads_point pt; if ( acedEntSel(_T("\n选择管道(多义线): "), en, pt)!= RTNORM) { acutPrintf(_T("\n选择失败,退出: ")); return ; } // 打开对象 acdbGetObjectId(eId, en); AcDbEntity * pEnt; acdbOpenObject(pEnt, eId, AcDb::kForWrite); if(!pEnt->isKindOf (AcDbPolyline::desc ())) { acutPrintf(_T("\n选择的不是管道(多义线),退出: " )); return ; } // 判断实体的扩展词典是否创建,如果没有则创建 dictObjId = pEnt->extensionDictionary(); if( dictObjId == AcDbObjectId::kNull ) { pEnt->createExtensionDictionary(); } // 获取实体的扩展词典 dictObjId = pEnt->extensionDictionary(); pEnt->close(); // 判断词典中的属性是否创建 CPipeAttribute* pAttribute; acdbOpenObject(pDict, dictObjId, AcDb::kForWrite); pDict->getAt (_T("属性"),attId); if(attId!= AcDbObjectId::kNull )//如果已经创建则输出数据 { acdbOpenObject(pAttribute, attId, AcDb::kForRead); acutPrintf(_T("\n管径:%4.2f " ),pAttribute->m_dRadius); acutPrintf(_T("\n壁厚:%4.2f " ),pAttribute->m_dThickness ); acutPrintf(_T("\n埋深:%4.2f " ),pAttribute->m_dDeep ); acutPrintf(_T("\n材质:%s " ),pAttribute->m_cMaterial ); } else { //没有则创建属性 pAttribute = new CPipeAttribute(); pDict->setAt(_T("属性"), pAttribute, attId); } //关闭对象 pDict->close(); pAttribute->close(); }
CCadEntity * CCadEntityFactory::GetCadEntity(AcDbObjectId & idEntity) { AcDbEntity * entity = 0; if (acdbOpenObject(entity, idEntity, AcDb::kForRead) != Acad::eOk) return 0; CCadEntity * cadEntity = CCadEntityFactory::GetCadEntity(entity); entity->close(); return cadEntity; }
bool MySSGetFilter::canBeSelected(AcDbObjectId id) const { bool ans = true; AcDbEntity * pEnt; if (acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead) == Acad::eOk) { ans = canBeSelected(pEnt); pEnt->close(); } return ans; }
//0,不显示属性,1,显示属性,2,显示属性默认值 void CZhfPalette::FilterDb(AcDbDatabase* pDb, int iFilterMode) { if (iFilterMode==1) { return ; } Acad::ErrorStatus es ; AcDbBlockTable* pBT = NULL ; pDb->getBlockTable(pBT, AcDb::kForRead); AcDbBlockTableRecord* pBTR = NULL; es = pBT->getAt(ACDB_MODEL_SPACE, pBTR, AcDb::kForWrite); pBT->close(); AcDbBlockTableRecordIterator* pIT; es = pBTR->newIterator(pIT) ; for (; !pIT->done(); pIT->step()) { AcDbEntity* pEnt = NULL ; if (Acad::eOk==pIT->getEntity(pEnt, AcDb::kForWrite)) { if (pEnt->isKindOf(AcDbAttributeDefinition::desc())) { AcDbAttributeDefinition *pAttDef = AcDbAttributeDefinition::cast(pEnt); if (iFilterMode==0) { pEnt->erase() ; } else if (iFilterMode>1) { if (pAttDef != NULL && !pAttDef->isConstant()) { // We have a non-constant attribute definition, // so build an attribute entity. CString strShowVal ; if (iFilterMode==2) { strShowVal = pAttDef->textString() ; } else if (iFilterMode==3) { strShowVal = pAttDef->prompt() ; //显示中文为乱码 } pAttDef->setTag(strShowVal) ; } } } pEnt->close() ; } } delete pIT; pBTR->close(); }
static AcDbEntity* CloneEntity( const AcDbObjectId& objId ) { AcDbEntity* pEnt; acdbOpenObject( pEnt, objId, AcDb::kForRead ); AcDbEntity* pClone = AcDbEntity::cast( pEnt->clone() ); pEnt->close(); return pClone; }
AcDbObjectIdArray Additional_Class::ObjectXdataFilter( CString XdataName, CString Xdata ) { //// 遍历所有图层符合规则的实体返回ID列表 AcDbObjectIdArray resID; //AcDbObjectIdArray tempIDList; AcDbBlockTable *pBlockTable = NULL; acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead); ////this->Open_BlockTable(pBlockTable, NREADMODE); AcDbBlockTableRecord *pBlockTableRecord = NULL; pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite); //AcDbObjectIterator pltr; AcDbBlockTableRecordIterator * pltr2; pBlockTableRecord->newIterator(pltr2); ////pBlockTable->newIterator(pltr); AcDbEntity * pEnt; CString tempStrEnt; for (pltr2->start(); !pltr2->done(); pltr2->step()) { //pltr2.getEntity() if(Acad::eOk == pltr2->getEntity(pEnt, AcDb::kForRead, false)) { pEnt->close(); tempStrEnt = Get_Xdata(pEnt->id(), XdataName); if (tempStrEnt == Xdata) { resID.append(pEnt->id()); } } //pEnt->close(); } pEnt->close(); pBlockTable->close(); pBlockTableRecord->close(); delete pltr2; return resID; }
void Jig3d::apply() throw(CmdException) { m_xform = m_xformTemp*m_xform; AcDbEntity* pE; if (acdbOpenObject(pE,m_int.m_idEntity,AcDb::kForWrite)==Acad::eOk) { Acad::ErrorStatus es; if ((es=pE->transformBy(m_xform))!=Acad::eOk) throw CmdException(es,"Transformation cannot be applied to object"); pE->close(); } }
static void shYDsysXDataDel() { ads_name ssName; if(RTNORM == acedSSGet(":S", NULL, NULL, NULL, ssName)) { AcDbObjectId tempObjId; ads_name ssTemp; long nLen=0; if(RTNORM != acedSSLength(ssName,&nLen)) return; for(int j=0; j<nLen; j++) { if(RTNORM == acedSSName(ssName,j,ssTemp)) continue; if(Acad::eOk != acdbGetObjectId(tempObjId, ssTemp)) continue; AcDbEntity* pEnt = NULL; if(Acad::eOk == acdbOpenObject(pEnt,tempObjId,AcDb::kForWrite)) { resbuf* pHead = pEnt->xData(NULL); if(pHead == NULL) { pEnt->close(); continue; } resbuf* pNext =pHead->rbnext; if(pNext == NULL) { acutRelRb(pHead); pEnt->close(); continue; } while(pNext != NULL) { acutRelRb(pHead); pHead = pNext; pNext = pNext->rbnext; } pEnt->setXData(NULL); pEnt->close(); } } acedSSFree(ssName); } }
bool ArxDbgUtils::isOnLockedLayer(AcDbObjectId& id, bool printMsg) { AcDbEntity* ent; Acad::ErrorStatus es = acdbOpenAcDbEntity(ent, id, AcDb::kForRead); if (es == Acad::eOk) { bool result = isOnLockedLayer(ent, printMsg); ent->close(); return result; } return true; // by default we "lock" data }
bool GetInsertPoint( const AcDbObjectId& objId, AcGePoint3d& pt ) { AcDbEntity* pEnt; if( Acad::eOk != acdbOpenObject( pEnt, objId, AcDb::kForRead ) ) return false; GasGeologyGE* pGE = GasGeologyGE::cast( pEnt ); bool ret = ( pGE != 0 ); if( ret ) { pt = pGE->getInsertPt(); } pEnt->close(); return ret; }
void ArxEntityHelper::TransformEntities2( const AcDbObjectIdArray& objIds, const AcGeMatrix3d& xform ) { if( objIds.isEmpty() ) return; int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbEntity* pEnt; if( Acad::eOk == acdbOpenAcDbEntity( pEnt, objIds[i], AcDb::kForWrite ) ) { pEnt->transformBy( xform ); pEnt->close(); } } }
Acad::ErrorStatus ArxDbgUtils::defineNewBlock(LPCTSTR blkName, AcDbBlockTableRecord*& newBlkRec, AcDbObjectId& newBlkRecId, AcDbDatabase* db) { ASSERT(db != NULL); AcDbBlockTable* blkTbl; Acad::ErrorStatus es = db->getSymbolTable(blkTbl, AcDb::kForWrite); if (es != Acad::eOk) return es; // if this block already exists, erase its contents first if (blkTbl->getAt(blkName, newBlkRec, AcDb::kForWrite) == Acad::eOk) { newBlkRecId = newBlkRec->objectId(); AcDbBlockTableRecordIterator* iter; es = newBlkRec->newIterator(iter); if (es != Acad::eOk) { ArxDbgUtils::rxErrorMsg(es); newBlkRec->close(); } else { AcDbEntity* ent; for (; !iter->done(); iter->step()) { if (iter->getEntity(ent, AcDb::kForWrite) == Acad::eOk) { ent->erase(); ent->close(); } } delete iter; } } else { // create a new block table record and add it to the block table newBlkRec = new AcDbBlockTableRecord; newBlkRec->setPathName(AcadString::nullStr); // constructor doesn't do it properly es = newBlkRec->setName(blkName); if (es == Acad::eOk) es = blkTbl->add(newBlkRecId, newBlkRec); if (es != Acad::eOk) { ArxDbgUtils::rxErrorMsg(es); delete newBlkRec; } } blkTbl->close(); // doesn't need to be open anymore return es; }
AcGePoint3d Additional_Class::Get_CenterPt( AcDbObjectId ObjID ) { AcDbEntity *pEnt = NULL; AcGePoint3d ptMax, ptMin, ptRes; ptRes.set(0,0,0); if (Acad::eOk == acdbOpenAcDbEntity(pEnt, ObjID, AcDb::kForWrite)) { AcDbExtents pEntExtent; pEnt->getGeomExtents(pEntExtent); ptMax = pEntExtent.maxPoint(); ptMin = pEntExtent.minPoint(); ptRes.x = (ptMax.x + ptMin.x)/2; ptRes.y = (ptMax.y + ptMin.y)/2; ptRes.z = (ptMax.z + ptMin.z)/2; } pEnt->close(); return ptRes; }
Acad::ErrorStatus ArxDbgUtils::cloneAndXformObjects(AcDbDatabase* db, const AcDbObjectIdArray& entsToClone, const AcDbObjectId& ownerBlockId, const AcGeMatrix3d& xformMat, bool debugSpeak) { ASSERT(db != NULL); AcDbIdMapping idMap; Acad::ErrorStatus es = db->deepCloneObjects( const_cast<AcDbObjectIdArray&>(entsToClone), const_cast<AcDbObjectId&>(ownerBlockId), idMap); if (es != Acad::eOk) { ArxDbgUtils::rxErrorMsg(es); return es; } AcDbEntity* clonedEnt; AcDbIdPair idPair; AcDbIdMappingIter iter(idMap); for (iter.start(); !iter.done(); iter.next()) { if (!iter.getMap(idPair)) return Acad::eInvalidInput; if (idPair.isCloned()) { es = acdbOpenAcDbEntity(clonedEnt, idPair.value(), AcDb::kForWrite); if (es == Acad::eOk) { if (idPair.isPrimary()) { if (debugSpeak) acutPrintf(_T("\nCloned And Transformed: %s"), ArxDbgUtils::objToClassStr(clonedEnt)); clonedEnt->transformBy(xformMat); } else if (debugSpeak) acutPrintf(_T("\nCloned: %s"), ArxDbgUtils::objToClassStr(clonedEnt)); clonedEnt->close(); } else ArxDbgUtils::rxErrorMsg(es); } } return Acad::eOk; }
Acad::ErrorStatus AsdkBody::dwgInFields(AcDbDwgFiler* filer) { assertWriteEnabled(); Acad::ErrorStatus es; if ((es = AcDbEntity::dwgInFields(filer)) != Acad::eOk) return es; switch (filer->filerType()) { case AcDb::kCopyFiler: case AcDb::kDeepCloneFiler: case AcDb::kWblockCloneFiler: { void *i, *j; filer->readAddress(&i); filer->readAddress(&j); AcDbStub* stub = (AcDbStub*)i; AcDbEntity* ent = (AsdkBody*)j; if (NULL != stub) acdbOpenAcDbEntity(ent, AcDbObjectId(stub), AcDb::kForRead, Adesk::kTrue); m_3dGeom = ((AsdkBody*)ent)->m_3dGeom.copy(); if (NULL != stub) ent->close(); } break; case AcDb::kFileFiler: case AcDb::kUndoFiler: case AcDb::kPageFiler: m_3dGeom = Body::restore( &DwgFilerCallBack( filer ) ); break; default: break; } return filer->filerStatus(); }
void ArxDbgUiTdcPersistentReactors::detachSelectedObjs(const AcDbObjectIdArray& objIds) { Acad::ErrorStatus es; AcDbEntity* ent; ArxDbgPersistentObjReactor* peReactor; AcDbObjectId prId; ArxDbgDocLockWrite docLock; // these potentially came from other documents int len = objIds.length(); for (int i=0; i<len; i++) { es = docLock.lock(objIds[i].database()); // lock the document associated with this database if (es == Acad::eOk) { es = acdbOpenAcDbEntity(ent, objIds[i], AcDb::kForWrite, true); if (es == Acad::eOk) { prId = getPersistentObjReactor(objIds[i].database(), true); ent->removePersistentReactor(prId); es = acdbOpenObject(peReactor, prId, AcDb::kForWrite); if (es == Acad::eOk) { peReactor->detachFrom(ent->objectId()); peReactor->close(); } else { CString str; str.Format(_T("ERROR: Could not update backward reference in reactor: (%s)"), ArxDbgUtils::rxErrorStr(es)); ArxDbgUtils::stopAlertBox(str); } ent->close(); } else { ArxDbgUtils::rxErrorAlert(es); } } else { ArxDbgUtils::rxErrorAlert(es); } } }
void ArxDbgDbAdeskLogo::drawRefLine(AcGiCommonDraw* drawContext) { AcDbEntity* ent; Acad::ErrorStatus es = acdbOpenAcDbEntity(ent, m_arbitraryRefEnt, AcDb::kForRead); if (es == Acad::eOk) { AcGePoint3d toPt; getReferenceAttachmentPoint(ent, toPt); ent->close(); AcGePoint3d pts[2]; pts[0] = location(); pts[1] = toPt; Adesk::UInt16 curColor = drawContext->subEntityTraits().color(); drawContext->subEntityTraits().setColor(1); drawContext->rawGeometry()->polyline(2, pts); drawContext->subEntityTraits().setColor(curColor); } }
AcDbObjectId CArxHelper::CreateBlock(const AcDbVoidPtrArray& arrEnt, const CString& strName) { AcDbObjectId blockId = AcDbObjectId::kNull; AcDbBlockTableRecord* pBlockTableRecord = new AcDbBlockTableRecord(); pBlockTableRecord->setName(strName); pBlockTableRecord->setOrigin(AcGePoint3d::kOrigin); for (int i = 0; i < arrEnt.length(); ++ i) { AcDbEntity* pEntity = (AcDbEntity*)arrEnt.at(i); pBlockTableRecord->appendAcDbEntity(pEntity); pEntity->close(); } AcDbBlockTable* pBlockTable = NULL; acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForWrite); pBlockTable->add(blockId,pBlockTableRecord); pBlockTableRecord->close(); pBlockTable->close(); return blockId; }
void asdktest3 () { //----- Create a line and a circle (memory only) AcDbLine *pLine =new AcDbLine (AcGePoint3d (), AcGePoint3d (100, 100, -100)) ; AcDbCircle *pCircle =new AcDbCircle (AcGePoint3d (50, 50, 0), AcGeVector3d (0, 0, 1) , 25.0) ; //----- Create a region from the circle AcDbVoidPtrArray arr1, arr2 ; arr1.append (pCircle) ; AcDbRegion::createFromCurves (arr1, arr2) ; AcDbRegion *pRegion =(AcDbRegion *)arr2.at (0) ; delete pCircle ; //----- Add the line and the region objects to the collector //----- NB: Remember those object are memory objects only AsdkHlrCollector collector ; collector.setDeleteState (true) ; collector.addEntity (pLine) ; collector.addEntity (pRegion) ; //----- Process hidden line removal AsdkHlrEngine hlr (AcGePoint3d (50, 50,0), AcGeVector3d (0, 0, 1), kEntity | kBlock | kShowAll | kProject | kHonorInternals) ; hlr.run (collector) ; //----- To easily see the result, we do append resulting entities to the current database //----- and use the color convention used in command 'TEST1' int n =collector.mOutputData.logicalLength () ; for ( int i =0 ; i < n ; i++ ) { AsdkHlrData *p =collector.mOutputData [i] ; AcDbEntity *pEnt =p->getResultEntity () ; AsdkHlrData::Visibility vis =p->getVisibility () ; if ( vis == AsdkHlrData::kVisible ) pEnt->setColorIndex (1) ; else pEnt->setColorIndex (5) ; AcDbObjectId id ; if ( postToDatabase (NULL, pEnt, id) != Acad::eOk ) { acutPrintf (_T("Failed to add entity to current space.\n")) ; break ; } //----- Entity originator path AcDbObjectIdArray ids =p->getObjectIds () ; if ( ids.logicalLength () > 0 ) { acutPrintf (ACRX_T("\n%ld, "), pEnt->objectId ().asOldId ()) ; for ( int j =0 ; j < ids.logicalLength () ; j++ ) { acutPrintf (ACRX_T("%ld, "), ids.at (j).asOldId ()) ; } } pEnt->close () ; } }
// This function has the user select an entity and then // calls the reflectedEnergy() function in the protocol // extension class attached to that entity's class. // void energy() { AcDbEntity *pEnt; AcDbObjectId pEntId; ads_name en; ads_point pt; if (acedEntSel("\nSelect an Entity: ", en, pt) != RTNORM) { acutPrintf("Nothing Selected\n"); return; } acdbGetObjectId(pEntId, en); acdbOpenObject(pEnt, pEntId, AcDb::kForRead); // call the protocol extension class's method // double eTemp = ACRX_X_CALL(pEnt, AsdkEntTemperature)->reflectedEnergy(pEnt); acutPrintf("\nEnergy == %f\n", eTemp); pEnt->close(); }