我是获取ECProperty的"Category"这个CustomAttribute,取其“DisplayLabel”或者"Standard"来确定属性的类别名称。
但是在OPM中获取属性时发现有几个属性获取的类别名称,和OPM界面上显示的不一样。
然后我通过这个帖子[MSCE C++]请问怎么判断一条属性是否会在界面中显示? - ◆ 二次开发(MicroStation编程, ProjectWise编程等) - Bentley 中国优先社区 - Bentley Communities中提到的方法获取了元素的ECSchema并写成XML文件。
我就发现这个属性的类别名称在OPM界面上显示为“标签信息”
而我通过"Category"这个CustomAttribute,取到的“DisplayLabel”是“General Info”。
而ECSchema导出的XML文件中这个属性的ECClass的名称是"PIPING_NETWORK_SEGMENT" 显示标签是"Segment"
<ECClass typeName="PIPING_NETWORK_SEGMENT" description="Group of component under pipeline" displayLabel="Segment" isStruct="false" isDomainClass="true" isCustomAttributeClass="false"> <BaseClass>NAMED_ITEM</BaseClass> <!-------中间还有一些ECProperty被我省略-----> <ECProperty propertyName="DEVICE_TYPE_CODE" typeName="string" description="code uses to describe the type of component." displayLabel="Device Type Code" readOnly="false"/> </ECClass>
请问各位老师,为什么会是这种现象?我要怎么操作才能获取到和界面显示一致的类别名称?
往”PIPING_NETWORK_SEGMENT“的BaseClass里边试着找一下看看,还有一种可能您这里看到的"Device Type Code“属性是"PIPING_NETWORK_SEGMENT"这个ECClass的子类继承的属性,子类里边设置了类别。
老师,我往”PIPING_NETWORK_SEGMENT“的BaseClass里边找了一下没有发现,包括它继承的OpenPlant.01.08.ecschema.xml文件中的类也没有。文件中也没有找到"PIPING_NETWORK_SEGMENT"的子类,如果是在其他文件继承了,那也很难找到。
我还尝试在文件中和“C:\ProgramData\Bentley\OpenPlant CONNECT Edition\Configuration\Workspaces\OpenPlantExample\WorkSets\Metric\Standards\OpenPlant\Schemas”这个文件夹下所有文件中搜寻“标签信息”这个关键字。也没有找到任何结果。
试试下图所示的这个函数,参数传true,对返回的集合迭代一下,看是否有“Category”。
老师,我试了使用这个接口。返回的集合中并没有“Category”。
Name:DIAMETER, DisplayLabel:Diameter CustomAttributes Name:UnitSpecification, DisplayLabel:UnitSpecification Property: Name:DimensionName, DisplayLabel:DimensionName Value:L Property: Name:KindOfQuantityName, DisplayLabel:KindOfQuantityName Value:DIAMETER Property: Name:UnitName, DisplayLabel:UnitName Value:MILLIMETRE Property: Name:AllowableUnits, DisplayLabel:AllowableUnits Value:<Programmer Error: Attempted to get string value from ECN::ECValue that is not a string.> Name:DisplayUnitSpecification, DisplayLabel:DisplayUnitSpecification Property: Name:DisplayFormatString, DisplayLabel:DisplayFormatString Value:G6 Property: Name:DisplayFormatKey, DisplayLabel:DisplayFormatKey Value:(null) Property: Name:DisplayUnitName, DisplayLabel:DisplayUnitName Value:MILLIMETRE Name:LENGTH_TAN_TAN, DisplayLabel:Length Tan Tan CustomAttributes Name:UnitSpecification, DisplayLabel:UnitSpecification Property: Name:DimensionName, DisplayLabel:DimensionName Value:L Property: Name:KindOfQuantityName, DisplayLabel:KindOfQuantityName Value:LENGTH Property: Name:UnitName, DisplayLabel:UnitName Value:MILLIMETRE Property: Name:AllowableUnits, DisplayLabel:AllowableUnits Value:<Programmer Error: Attempted to get string value from ECN::ECValue that is not a string.> Name:DisplayUnitSpecification, DisplayLabel:DisplayUnitSpecification Property: Name:DisplayFormatString, DisplayLabel:DisplayFormatString Value:G6 Property: Name:DisplayFormatKey, DisplayLabel:DisplayFormatKey Value:(null) Property: Name:DisplayUnitName, DisplayLabel:DisplayUnitName Value:MILLIMETRE Name:HEAD_TYPE, DisplayLabel:Head Type CustomAttributes Name:HEAD2_TYPE, DisplayLabel:Head 2 type CustomAttributes
传入true和false我都试了。返回的结果是一样的。
估计也是OPM的特殊性导致的。我和郭老师都是在纯MS环境下做的测试
老师,所以MSCE的SDK对于OPM等专业软件的特有信息并不能百分百处理是吗?
这主要依赖于这些专业软件是否完全采用了MS中规定好的技术,如果是自己又搞出了一套独立的了,那MS的SDK当然就无能为力了。