插入EC属性后,怎么才能不显示ecclass名称,下面是我的代码
var ecSchema = new ECSchema("TestSchema", 1, 1, "zfgk"); var ecClass = new ECClass("TestClass"); var specification = new InstanceLabelSpecification("false").CreatePopulatedCustomAttributeInstance(); ecClass.SetCustomAttribute(specification); ecClass.Add(new ECProperty("TestProperty", ECObjects.StringType)); ecSchema.AddClass(ecClass); var status = DgnECManager.Manager.ImportSchema(ecSchema, ActiveDgnFile, new ImportSchemaOptions()); if (status == SchemaImportStatus.Success) { ECXAttributes.AppendInstance(element, ecClass.CreateInstance()); dgnElementSetTool.DoExitTool(); }
在你的ECSchema定义中,在ECClass下增加如下的InstanceLabelSpecification定义后即可。
<ECCustomAttributes>
<InstanceLabelSpecification xmlns="Bentley_Standard_CustomAttributes.01.02" />
</ECCustomAttributes>
<?xml version="1.0" encoding="utf-16"?> <ECSchema schemaName="BanFengProperty" nameSpacePrefix="zfgk" version="1.0" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.2.0"> <ECSchemaReference name="Bentley_Standard_CustomAttributes" version="01.13" prefix="bsca" /> <ECSchemaReference name="EditorCustomAttributes" version="01.03" prefix="beca" /> <ECClass typeName="BanFeng" displayLabel="板缝参数" isStruct="True" isDomainClass="True"> <ECCustomAttributes> <InstanceLabelSpecification xmlns="Bentley_Standard_CustomAttributes.01.13" /> </ECCustomAttributes> <ECProperty propertyName="BanFengType" typeName="string" displayLabel="板缝类型" /> <ECProperty propertyName="Length" typeName="double" displayLabel="长度" /> <ECProperty propertyName="Length2" typeName="double" displayLabel="长度2"> <ECCustomAttributes> <HideProperty xmlns="EditorCustomAttributes.01.03"> <If2D>True</If2D> <If3D>True</If3D> </HideProperty> </ECCustomAttributes> </ECProperty> <ECProperty propertyName="Length3" typeName="double" displayLabel="长度3" /> <ECProperty propertyName="Length4" typeName="double" displayLabel="长度4" /> </ECClass> </ECSchema>
现在已经是这种格式了,但是还是显示,怎么解决?
请升级到最新版的Mstn上测试,老版本的ItemIdentifiesHost这个ECClass可能还没有添加ShouldIdentifyHost这个ECProperty,如果必须在老版本上的话,您可以试试跳过设置ShouldIdentifyHost属性这一步看看是否有效。
CE10 UP10上还是不行
我是在U14上测试的
请问最后是怎么解决的呢?
升级到最新版的Mstn,然后用我上边这条回复里边的办法就可以了。示例代码中的ecClass就是您自己的ECClass。
HongQiang Guo said:用如下代码给自己的ECClass添加一个ItemIdentifiesHost的CustomAttribute的属性,并设置其ShouldIdentifyHost属性为false即可。 Fullscreen
用如下代码给自己的ECClass添加一个ItemIdentifiesHost的CustomAttribute的属性,并设置其ShouldIdentifyHost属性为false即可。