bool ArxEntityHelper::SetEntitiesColor2( const AcDbObjectIdArray& objIds, const AcArray<Adesk::UInt16>& colors ) { AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return false; bool ret = true; // 默认返回true int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForWrite ) ) { actrTransactionManager->abortTransaction(); ret = false; break; } AcDbEntity* pEnt = AcDbEntity::cast( pObj ); if( pEnt == 0 ) { actrTransactionManager->abortTransaction(); ret = false; break; } pEnt->setColorIndex( colors[i] ); // 恢复原先的颜色 } actrTransactionManager->endTransaction(); return ret; }
void OnlyOneSelectFilter::ssgetAddFilter ( int ssgetFlags, AcEdSelectionSetService& service, const AcDbObjectIdArray& selectionSet, const AcDbObjectIdArray& subSelectionSet ) { //acutPrintf(_T("\n ssgetAddFilter==> select set: %d"), selectionSet.length()); //acutPrintf(_T("\n ssgetAddFilter==> subselect set: %d\n"), subSelectionSet.length()); //AcEdSSGetFilter::ssgetAddFilter (ssgetFlags, service, selectionSet, subSelectionSet) ; if( selectionSet.length() == 0 ) { if( subSelectionSet.length() > 1 ) { int len = subSelectionSet.length(); for( int i = 0; i < len - 1; i++ ) { Acad::ErrorStatus es = service.remove( i ); } } } else { int len = subSelectionSet.length(); for( int i = 0; i < len; i++ ) { Acad::ErrorStatus es = service.remove( i ); } } }
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(); }
int getAllSymbolRecordsIds(AcRxClass* pTableClass, AcDbObjectIdArray & idaAll) { CLogger::Print(_T("*Call: getAllSymbolRecordsIds()")); Acad::ErrorStatus es; idaAll.setLogicalLength(0); AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase(); AcDbSymbolTable* pSymbolTable = NULL; if (AcRx::kEqual == pTableClass->comparedTo(AcDbBlockTable::desc())) { CLogger::Print(_T("> This is BlockTable!")); es = pDb->getBlockTable(pSymbolTable, AcDb::kForRead); } else if (AcRx::kEqual == pTableClass->comparedTo(AcDbLayerTable::desc())) { CLogger::Print(_T("> This is LayerTable!")); es = pDb->getLayerTable(pSymbolTable, AcDb::kForRead); } else if (AcRx::kEqual == pTableClass->comparedTo(AcDbLinetypeTable::desc())) { CLogger::Print(_T("> This is LinetypeTable!")); es = pDb->getLinetypeTable(pSymbolTable, AcDb::kForRead); } else if (AcRx::kEqual == pTableClass->comparedTo(AcDbTextStyleTable::desc())) { CLogger::Print(_T("> This is TextStyleTable!")); es = pDb->getTextStyleTable(pSymbolTable, AcDb::kForRead); } else { CLogger::Print(_T("*Exit: getAllSymbolRecordsIds() - This kind of SymbolTable is not supported!")); return -1; } if (Acad::eOk != es) { CLogger::Print(_T("*Exit: getAllSymbolRecordsIds() - Fail to get SymbolTable!")); return -1; } //------------ // Get the SymbolTable's iterator. AcDbSymbolTableIterator* pSymbolTableIter = NULL; es = pSymbolTable->newIterator(pSymbolTableIter); pSymbolTable->close(); if (Acad::eOk != es) { CLogger::Print(_T("*Exit: getAllSymbolRecordsIds() - Fail to get the SymbolTable's iterator!")); return -1; } //------------ // Steps through the SymbolTable's records. // Then get the SymbolTableRecord's ObjectID. for (; !pSymbolTableIter->done(); pSymbolTableIter->step()) { AcDbObjectId idObj = AcDbObjectId::kNull; if (Acad::eOk == pSymbolTableIter->getRecordId(idObj)) idaAll.append(idObj); } delete pSymbolTableIter; CLogger::Print(_T("*Exit: getAllSymbolRecordsIds() - Count: %02d"), idaAll.length()); return idaAll.length(); }
void DrawCmd::UpdateAllWindStationData() { // 查找所有的测风站 // 将所在宿主上的面积、风速、风量数据读取到测风站中 AcDbObjectIdArray objIds; DrawHelper::FindMineGEs( _T( "WindStation" ), objIds ); if( objIds.isEmpty() ) return; AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return; AcDbObjectIdArray geObjIds; int len = objIds.length(); bool ret = true; for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForRead ) ) { ret = false; break; } TagGE* pTag = TagGE::cast( pObj ); if( pTag == 0 ) { ret = false; break; } geObjIds.append( pTag->getRelatedGE() ); } actrTransactionManager->endTransaction(); if( !ret ) { geObjIds.removeAll(); } else { //assert(objIds.length() == geObjIds.length()); int len = objIds.length(); for( int i = 0; i < len; i++ ) { ReadWriteData( geObjIds[i], _T( "断面面积" ), objIds[i], _T( "测试断面面积" ) ); ReadWriteData( geObjIds[i], _T( "风速" ), objIds[i], _T( "测试风速" ) ); ReadWriteData( geObjIds[i], _T( "风量" ), objIds[i], _T( "测试风量" ) ); } } }
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); } }
static void YCROYCRO_CG_AddRegion() { ads_name ss; int rt = acedSSGet(NULL, NULL, NULL, NULL, ss); AcDbObjectIdArray objIds; if (rt == RTNORM) { long 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); AcDbObjectIdArray regionIds; regionIds = CCreateEnt::CreateRegion(objIds); int number = regionIds.length(); if (number > 0) { acutPrintf(_T("\n已经创建%d个面域!"), number); } else { acutPrintf(_T("\n创建0个面域!")); } }
void DrawHelper::ConfigDraw( const CString& geType, const CString& drawName ) { MineGEDraw* pDraw = MineGEDrawSystem::GetInstance()->getGEDraw( geType, drawName ); if( pDraw == 0 ) return; // 该绘制效果不存在 pDraw->configExtraParams(); // 配置附加参数 AcDbObjectIdArray objIds; ArxDataTool::GetEntsByType( geType, objIds, false ); if( objIds.isEmpty() ) return; // dwg图形中没有任何geType类型图元 AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return; int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds.at( i ), AcDb::kForWrite ) ) continue; MineGE* pGE = MineGE::cast( pObj ); if( pGE == 0 ) continue; pGE->configDraw( pDraw->isA()->name() ); // 更新extra param pGE->recordGraphicsModified( true ); // 更新图形 } actrTransactionManager->endTransaction(); AcRxClass* pClass = AcRxClass::cast( acrxClassDictionary->at( geType ) ); if( pClass != 0 && pClass->isDerivedFrom( LinkedGE::desc() ) ) { UpdateLinkedGE( objIds ); } }
void DrawHelper::SwitchDraw( const CString& geType, const CString& drawName ) { // 设置当前可视化效果 if( !SetCurDraw( geType, drawName ) ) return; // 更新所有指定类型的图元 AcDbObjectIdArray objIds; ArxDataTool::GetEntsByType( geType, objIds, false ); if( objIds.isEmpty() ) return; // dwg图形中没有任何MineGE类型图元 // 将所有geType类型图元的绘制效果更新 AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return; int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds.at( i ), AcDb::kForWrite ) ) continue; MineGE* pGE = MineGE::cast( pObj ); if( pGE == 0 ) continue; pGE->updateDraw(); // 更细可视化效果指针 //pGE->recordGraphicsModified(true); // 更新图形 } actrTransactionManager->endTransaction(); AcRxClass* pClass = AcRxClass::cast( acrxClassDictionary->at( geType ) ); if( pClass != 0 && pClass->isDerivedFrom( LinkedGE::desc() ) ) { UpdateLinkedGE( objIds ); } }
bool ArxEntityHelper::SelectEntities( const AcDbObjectIdArray& objIds ) { //acedSSSetFirst(NULL, NULL); if( objIds.isEmpty() ) return false; ads_name ss; //创建一个空的选择集 if(RTNORM != acedSSAdd( NULL, NULL, ss )) return false; bool ret = true; for(int i=0;i<objIds.length();i++) { ads_name ename; if( Acad::eOk != acdbGetAdsName( ename, objIds[i] ) ) { ret = false;; break; } if( RTNORM != acedSSAdd( ename, ss, ss ) ) // 添加到选择集 { ret = false;; break; } } if(ret) { acedSSSetFirst( ss, NULL ); // 高亮选中 } acedSSFree( ss ); // 释放选择集 return ret; }
bool ArxEntityHelper::SetEntitiesColor( AcDbObjectIdArray& objIds, unsigned short colorIndex ) { AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return false; bool ret = true; // 默认返回true int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForWrite ) ) { actrTransactionManager->abortTransaction(); ret = false; break; } AcDbEntity* pGE = AcDbEntity::cast( pObj ); if( pGE == 0 ) { actrTransactionManager->abortTransaction(); ret = false; break; } // 设置颜色 pGE->setColorIndex( colorIndex ); } actrTransactionManager->endTransaction(); return ret; }
// 从图元的扩展词典中查找数据对象 static void GetDataObjectFromExtDict( AcDbObjectIdArray& dbObjIds ) { AcDbObjectIdArray allObjIds; ArxDataTool::GetEntsByType( _T( "MineGE" ), allObjIds, true ); // 判断是否数据对象DataObject // 且类型名称==type if( allObjIds.isEmpty() ) return; AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return; int len = allObjIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, allObjIds[i], AcDb::kForRead ) ) continue; MineGE* pGE = MineGE::cast( pObj ); if( pGE == 0 ) continue; AcDbObjectId dbObjId = pGE->getDataObject(); if( !dbObjId.isNull() ) { dbObjIds.append( dbObjId ); } } actrTransactionManager->endTransaction(); }
bool ArxEntityHelper::GetEntitiesColor( const AcDbObjectIdArray& objIds, AcArray<Adesk::UInt16>& colors ) { AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return false; bool ret = true; // 默认返回true int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForRead ) ) { actrTransactionManager->abortTransaction(); ret = false; colors.removeAll(); // 清空 break; } AcDbEntity* pEnt = AcDbEntity::cast( pObj ); if( pEnt == 0 ) { actrTransactionManager->abortTransaction(); ret = false; colors.removeAll(); // 清空 break; } Adesk::UInt16 ci = pEnt->colorIndex(); colors.append( ci ); // 记录原有的颜色 } actrTransactionManager->endTransaction(); return ret; }
void ArxEntityHelper::ZoomToEntities( const AcDbObjectIdArray& objIds ) { AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return; AcDbExtents exts; int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForRead ) ) continue; AcDbEntity* pEnt = AcDbEntity::cast( pObj ); if( pEnt == 0 ) continue; AcDbExtents extents; if( Acad::eOk != pEnt->getGeomExtents( extents ) ) continue; exts.addPoint( extents.minPoint() ); exts.addPoint( extents.maxPoint() ); } actrTransactionManager->endTransaction(); AcGePoint3d minPt = exts.minPoint(); AcGePoint3d maxPt = exts.maxPoint(); if( minPt.x <= maxPt.x && minPt.y <= maxPt.y && minPt.z <= maxPt.z ) { ZoomEntity_Helper( minPt, maxPt ); } }
static void UpdateLinkedGE( const AcDbObjectIdArray& objIds ) { int len = objIds.length(); for( int i = 0; i < len; i++ ) { DrawHelper::LinkedGEJunctionClosure2( objIds[i] ); } }
static void FindWindStationHosts( const AcDbObjectIdArray& objIds, AcDbObjectIdArray& hosts ) { FWSHelper fws; int len = objIds.length(); for( int i = 0; i < len; i++ ) { hosts.append( fws.doFWS( objIds[i] ) ); } }
void UIHelper::DisplayDataByDoubleClick() { //acutPrintf(_T("\n双击自定义...")); AcDbObjectIdArray objIds; ArxUtilHelper::GetPickSetEntity( objIds ); if( objIds.length() != 1 ) return; // 显示属性对话框 PropertyDataDlgHelper::DisplayPropertyDataDlg( objIds[0] ); }
void ArxEntityHelper::EraseObjects2( const AcDbObjectIdArray& objIds, Adesk::Boolean erasing ) { if( objIds.isEmpty() ) return; int len = objIds.length(); for( int i = 0; i < len; i++ ) { EraseObject2( objIds[i], erasing ); } }
void DrawCmd::DrawFanTag() { AcDbObjectIdArray fanIds; DrawHelper::FindMineGEs(_T("LocalFan"),fanIds); int len = fanIds.length(); for (int i = 0; i < len; i++) { FanTagGEDrawed(fanIds[i]); } }
static bool GetFuncs(const CString& type, AcStringArray& funcs, AcDbObjectIdArray& objIds) { DrawHelper::FindMineGEs(type, objIds); int GENum = objIds.length(); if (GENum <= 0) { //AfxMessageBox(_T("系统中未发现钻孔!")); return false; } return FuncFieldHelper::GetFuncsByType(type,funcs); }
void DrawCmd::DrawEffectRanGE() { AcDbObjectIdArray ttunels; DrawHelper::FindMineGEs(_T("TTunnel"),ttunels); int len = ttunels.length(); if(ttunels.isEmpty()) return; for (int i = 0; i < len; i++) { EffectRanDrawed(ttunels[i]); } }
void BuildGoafPolygonArray( const AcDbObjectIdArray& objIds, AcGePoint3dArray& polygons, AcDbIntArray& polygon_counts ) { for( int i = 0; i < objIds.length(); i++ ) { // 获取采空区的多边形 AcGePoint3dArray polygon; GetGoafPolygon( objIds[i], polygon ); polygons.append( polygon ); polygon_counts.append( polygon.length() ); } }
void DrawCmd::DrawQTagGE() { AcDbObjectIdArray chims; DrawHelper::FindMineGEs(_T("Chimney"),chims); int len = chims.length(); //acutPrintf(_T("\n风筒数:%d"),len); if(chims.isEmpty()) return; for (int i = 0; i < len; i++) { QTagGEDrawed(chims[i]); } }
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(); } } }
static void UpdateEdge( const AcDbObjectIdArray& objIds ) { AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return; int n = objIds.length(); for( int i = 0; i < n; i++ ) { AcDbObjectId objId = objIds.at( i ); LinkedGE* pEdge = OpenEdge2( pTrans, objId, AcDb::kForWrite ); pEdge->recordGraphicsModified( true ); // 标签图形已经修改,需要更新图形 } actrTransactionManager->endTransaction(); }
void ArxEntityHelper::EraseObjects( const AcDbObjectIdArray& objIds, Adesk::Boolean erasing ) { if( objIds.isEmpty() ) return; AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return; int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForWrite, !erasing ) ) continue; pObj->erase( erasing ); // (反)删除图元 } actrTransactionManager->endTransaction(); }
void MySSGetFilter::ssgetAddFilter(int ssgetFlags, AcEdSelectionSetService &service, const AcDbObjectIdArray& selectionSet, const AcDbObjectIdArray& subSelectionSet) { if (m_color_index < 0) return; for (int i = 0; i < subSelectionSet.length(); ++i) { if (!canBeSelected(subSelectionSet[i])) { service.remove(i); continue; } if (!m_select_by_group) { high_light(subSelectionSet[i]); } else { } } }
ArxDbgUiDlgGenericDefId::ArxDbgUiDlgGenericDefId(CWnd* parent, SdStrObjIdList& entries, const AcDbObjectIdArray& currentValues, bool allowNone) : CAcUiDialog(ArxDbgUiDlgGenericDefId::IDD, parent, ArxDbgApp::getApp()->dllInstance()), m_entries(entries), m_hasVaries(false), m_hasNone(allowNone), m_curIndex(0) { if (allowNone == false) { ASSERT(entries.Count() != 0); } //{{AFX_DATA_INIT(ArxDbgUiDlgGenericDefId) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // walk through array and see if they all match or if they vary AcDbObjectId tmpId; int len = currentValues.length(); for (int i=0; i<len; i++) { if (i == 0) tmpId = currentValues[i]; else { if (tmpId != currentValues[i]) { m_hasVaries = TRUE; break; } } } // if it varied, add a new entry into list and make this the // current index if (m_hasVaries) { m_entries.AddTail(AcadString::varies1, AcDbObjectId::kNull); tmpId = AcDbObjectId::kNull; } // if it didn't vary and allowNone was on, then current selection // will be *NONE* if (allowNone) m_entries.AddTail(AcadString::none, AcDbObjectId::kNull); // get index for current entry int index; if (m_entries.GetIndexFor(tmpId, index)) m_curIndex = index; }
void ArxDbgUiTdcPersistentReactors::attachObjReactors(const AcDbObjectIdArray& objIds) { Acad::ErrorStatus es; AcDbObject* obj; 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 = acdbOpenAcDbObject(obj, objIds[i], AcDb::kForWrite, true); if (es == Acad::eOk) { prId = getPersistentObjReactor(objIds[i].database(), true); if (ArxDbgUiTdmReactors::hasPersistentReactor(obj, prId)) { ArxDbgUtils::alertBox(_T("That object already has the reactor attached.")); } else { obj->addPersistentReactor(prId); es = acdbOpenObject(peReactor, prId, AcDb::kForWrite); if (es == Acad::eOk) { peReactor->attachTo(obj->objectId()); peReactor->close(); } else { CString str; str.Format(_T("ERROR: Could not update backward reference in reactor: (%s)"), ArxDbgUtils::rxErrorStr(es)); ArxDbgUtils::stopAlertBox(str); } } obj->close(); } else { ArxDbgUtils::rxErrorMsg(es); } } else { ArxDbgUtils::rxErrorAlert(es); } } }
static void CleanAllFieldFromDataObject( const AcDbObjectIdArray& objIds ) { AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return; int len = objIds.length(); for( int i = 0; i < len; i++ ) { AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForWrite ) ) continue; DataObject* pDO = DataObject::cast( pObj ); if( pDO == 0 ) continue; pDO->clearAll(); // 删除所有数据 } actrTransactionManager->endTransaction(); }