EC属性赋值

<ECProperty propertyName="Name" typeName="string">
            <ECCustomAttributes>
                <PreviousNameArray xmlns="Bentley_Standard_CustomAttributes.01.00">
                    <PreviousNames>
                        <PreviousName>
                            <OldName />
                            <SchemaFullNameKey>TestSchema.01.00</SchemaFullNameKey>
                            <IsNewInThisVersion>True</IsNewInThisVersion>
                        </PreviousName>
                    </PreviousNames>
                    <PreviousNameAlreadySaved>True</PreviousNameAlreadySaved>
                </PreviousNameArray>
                <PropertyPriority xmlns="EditorCustomAttributes.01.00">
                    <Priority>100</Priority>
                </PropertyPriority>
            </ECCustomAttributes>
        </ECProperty>
这是符老师的xml文件其中一段,帮助我成功为元素新建属性,但是在使用符老师提示的PropertyHandler为属性赋值时弹出“不可用”错误,没有初始值的自定义属性无法使用SetValue赋初始值吗?急求,望指导!测试代码如下
Sub test()
    Dim oPH As PropertyHandler
    Set oPH = CreatePropertyHandler(ActiveModelReference.GetElementByID(DLongFromLong(32358)))
    oPH.SelectByAccessString "mingCheng"
    oPH.SetValue "12"
End Sub

Parents
  • 从你粘贴出来的ECSchema.XML中看到的ECProperty的名称是"Name",而你的代码中SelectByAccessString后指定的名称是"mingCheng",这两个名称不匹配。请查看一下是否是这个原因?



  • 我这个xml粘贴自您给的文件!疏忽了,我使用的是我另写的xml,并没有不匹配,如下:

            <ECProperty propertyName="mingCheng" typeName="String" displayLabel="名称">
                <ECCustomAttributes>
                    <PreviousNameArray xmlns="Bentley_Standard_CustomAttributes.01.00">
                        <PreviousNames>
                            <PreviousName>
                                <OldName />
                                <SchemaFullNameKey>TestSchema.01.00</SchemaFullNameKey>
                                <IsNewInThisVersion>True</IsNewInThisVersion>
                            </PreviousName>
                        </PreviousNames>
                        <PreviousNameAlreadySaved>True</PreviousNameAlreadySaved>
                    </PreviousNameArray>
                    <PropertyPriority xmlns="EditorCustomAttributes.01.00">
                        <Priority>100</Priority>
                    </PropertyPriority>
                </ECCustomAttributes>
            </ECProperty>

Reply
  • 我这个xml粘贴自您给的文件!疏忽了,我使用的是我另写的xml,并没有不匹配,如下:

            <ECProperty propertyName="mingCheng" typeName="String" displayLabel="名称">
                <ECCustomAttributes>
                    <PreviousNameArray xmlns="Bentley_Standard_CustomAttributes.01.00">
                        <PreviousNames>
                            <PreviousName>
                                <OldName />
                                <SchemaFullNameKey>TestSchema.01.00</SchemaFullNameKey>
                                <IsNewInThisVersion>True</IsNewInThisVersion>
                            </PreviousName>
                        </PreviousNames>
                        <PreviousNameAlreadySaved>True</PreviousNameAlreadySaved>
                    </PreviousNameArray>
                    <PropertyPriority xmlns="EditorCustomAttributes.01.00">
                        <Priority>100</Priority>
                    </PropertyPriority>
                </ECCustomAttributes>
            </ECProperty>

Children