[C++\C# MSCE] 获得隔离集所有元素

符老师  ,如何获得隔离集里面所有元素(这些元素不一定选中,SelectionSetManager这个不能用)   求符老师指导

Parents Reply Children
  • 是的。这也是我最近发现的问题。ORD软件错误地使用了字典模型,将许多图形元素都放入了字典模型中。在ScanCritiera中无论用setModel设置到哪个具体的图形模型,字典模型中的元素都会被扫描出来的。



  • Andy,你好!

    我又让我们公司专门负责ORD产品的工程师帮我创建了一个ORD的DGN,发现在其字典模型中并没有普通的几何元素。但我手头有其他单位用户提供的ORD的DGN确实发现了这种怪异情况。不知道您的DGN是否正常?

    你可以在你的DGN中执行如下函数,查看列出的结果中是否有平普通的图形元素,比如Type为6的Shape等。

    void fileAnalyze(WCharCP unparsed)
        {
        DgnFileP pDgnFile = ISessionMgr::GetActiveDgnFile();
    
        //Only ControlElements in DictionaryModel
        DgnModelR dictionaryModel = pDgnFile->GetDictionaryModel();
        UInt32 nCntAll = dictionaryModel.GetElementCount(DgnModelSections::All);
        UInt32 nCntDic = dictionaryModel.GetElementCount(DgnModelSections::Dictionary);
        UInt32 nCntMod = dictionaryModel.GetElementCount(DgnModelSections::Model);
        UInt32 nCntCtrl = dictionaryModel.GetElementCount(DgnModelSections::ControlElements);
        UInt32 nCntGrp = dictionaryModel.GetElementCount(DgnModelSections::GraphicElements);
        WString myString, elDescr;
        myString.Sprintf(L"DictionaryModel: nCntAll=%d, nCntDic=%d, nCntMod=%d, nCtrl=%d, nCntGrp=%d", nCntAll, nCntDic, nCntMod, nCntCtrl, nCntGrp);
        mdlDialog_dmsgsPrint(myString.GetWCharCP());
    
    	int cnt = 0;
        PersistentElementRefList *pElemRefList = dictionaryModel.GetControlElementsP();
        for (PersistentElementRefP const& elemRef : *pElemRefList)
            {
            ElementHandle eh(elemRef);
            eh.GetHandler().GetDescription(eh, elDescr, 100);
            myString.Sprintf(L"ElemType = %s(%d), ElementId=%d", 
                elDescr.GetWCharCP(), elemRef->GetElementType(), elemRef->GetElementId());
            mdlDialog_dmsgsPrint(myString.GetWCharCP());
    		if (cnt++ > 300)
    			break;
            }
        }
    



    Answer Verified By: Andy 

  • 我新建了一个可以的  用这个代码可以