插入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>
这个自定义属性怎么使用代码添加?
InstanceLabelSpecification也是个ECClass,创建一个实例调用SetCustomAttribute添加。
var specification = new InstanceLabelSpecification("false").CreatePopulatedCustomAttributeInstance(); ecClass.SetCustomAttribute(specification);
我这样加的,没有构造的也试了,都没有效果!
构造函数的那个参数是要传递宿主ECClass的属性名,如下图所示:
如果我不想让元素显示任何ECClass的属性名呢?