[MSCE c++] 参数化构件读取关联的元素

问题描述:一个智能实体构件ID为75313,使用裁剪功能后变成俩个参数化构件 75322和75324。

                 在实际视图中看到俩个构件,但是使用代码扫描能扫描出三个构件,如何过滤构件75313.

有用过以下代码,大致思路是判断构件是否是参数化构件,读取参数化构件中信息。但是返回的chrild .GetElementId都为0,没有预期的75313

ElementHandle(75322,ACTIVEMODEL)
if (Bentley::DgnPlatform::SmartFeature::SmartFeatureElement::IsSmartFeature(EH))
{
ElementAgenda ea;
Bentley::DgnPlatform::SmartFeature::SmartFeatureElement::DropToLegacy(ea,EH);
if (ea.GetCount() > 0)
{
for (int y = 0; y < ea.GetCount(); y++)
{
ElementHandle chrild = *(ea.GetFirstP()+y);
swprintf(currMsg2, L"参数化构件特征ID=%d\n", chrild .GetElementId());
mdlOutput_messageU(currMsg2);

}

}

  • 我用如下扫描代码可以只扫描出两个参数化实体。

    int OnScanCallback(ElementRefP elmRef, CallbackArgP callbackArg, ScanCriteriaP scP)
    {
    	WPrintfString wStr(L"id:%d, type:%d\n", elmRef->GetElementId(), elmRef->GetElementType());
    	mdlDialog_dmsgsPrint(wStr);
    	return SUCCESS;
    }
    void userScanFunc()
    {
    	ScanCriteriaP scP = mdlScanCriteria_create();
    	mdlScanCriteria_setModel(scP, ACTIVEMODEL);
    	mdlScanCriteria_setDrawnElements(scP);
    	mdlScanCriteria_setElementTypeTest(scP, NULL, 0);  // Clear all types
    	mdlScanCriteria_addSingleElementTypeTest(scP, 106);  // 106 = extended element, includes parametric solid
    	mdlScanCriteria_setReturnType(scP, MSSCANCRIT_ITERATE_ELMREF, 0, 0);
    	mdlScanCriteria_setElemRefCallback(scP, (PFScanElemRefCallback)OnScanCallback, NULL);
    	mdlScanCriteria_scan(scP, NULL, NULL, NULL);
    	mdlScanCriteria_free(scP);
    }

    执行结果如下:



    Answer Verified By: 彭 浩南