Document properties and multiple Languages

PLM World Member Genius PLM World Member Genius
PLM World Member Genius

We have a macro that we have used for over a decade which gets and sets properties of a Solid Edge document object.  An example is getting the Template from SummaryInformation.

 

We now want to use this same macro at our site in China, which is using Solid Edge install with Chinese language.  In our code we have always used the Property name to retrieve it, however this name is different in the Chinese install.

 

Does anyone know the best way to handle this?  One option would be to use the index number of the property from the SummaryInformation properties, but I've never been a fan of hard coding an index number for fear of it changing.

 

Here is an example of code:

Set oProp = objDraftdoc.Properties
Set oSummaryInfoProps = oProp("SummaryInformation")
Set oTemplateProperty = oSummaryInfoProps("Template")

 

When that last line is executed I get a subscript out of range error because the value is "应用程序名" and not "Template".

 

Thanks.

Carl Breving

S&C Electric Co

3 REPLIES

Re: Document properties and multiple Languages

PLM World Member Genius PLM World Member Genius
PLM World Member Genius

This is what was suggested by Development.

 

For the well-known properties, such as those in the SummaryInfo property set, you should look up properties by ID.  Use the PropertyByID () API on the appropriate Properties object and use the property IDs listed in the PropertyIDs enumerated type.  The SummaryInfo Template ID is 7.  This is what we use internally, i.e. we always look up properties by IDexcept for the custom properties, which don’t have predefined IDs.

 

Property PropertyByID(PropID As Long) As Object

    read-only

    Member of SolidEdgeFileProperties.Properties

 

Const igSumInfoTemplate = 7

    Member of SolidEdgeFileProperties.PropertyIDs

Re: Document properties and multiple Languages

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

I have the same problem and thought to something like this but didn't really understood how to use the different methods.

Is there a reference in the help about the properties IDs ?

Re: Document properties and multiple Languages

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

The help on that topic is very basic and without any sample, but you would mainly do the following:

' Access the file properties of the active document
Dim doc As SolidEdgeDocument = objApp.ActiveDocument
Dim props As SolidEdgeFramework.PropertySets = doc.Properties

' Access the SummaryInformation properties
Dim sumInfo As SolidEdgeFramework.Properties = props.Item("SummaryInformation")
Dim prop As SolidEdgeFramework.Property = sumInfo.PropertyByID(SolidEdgeFileProperties.PropertyIDs.igSumInfoTemplate)
Console.WriteLine("Name: " & prop.Name & ",   Value: " & prop.Value.ToString())

' Access the Custom properties
Dim custProps As SolidEdgeFramework.Properties = props.Item("Custom")
prop = custProps.Item("Density") ' Here, we always need to access the property by name!!
Console.WriteLine("Name: " & prop.Name & ",   Value: " & prop.Value.ToString())

instead of accessing the property by name like this sample:

' Access the file properties of the active document
Dim doc As SolidEdgeDocument = objApp.ActiveDocument
Dim props As SolidEdgeFramework.PropertySets = doc.Properties

' Access the SummaryInformation properties
Dim sumInfo As SolidEdgeFramework.Properties = props.Item("SummaryInformation")
Dim prop As SolidEdgeFramework.Property = sumInfo.Item("Template") ' This will fail on non-English installations of SE!
Console.WriteLine("Name: " & prop.Name & ",   Value: " & prop.Value.ToString())

' Access the Custom properties
Dim custProps As SolidEdgeFramework.Properties = props.Item("Custom")
prop = custProps.Item("Density") ' Here, we always need to access the property by name!!
Console.WriteLine("Name: " & prop.Name & ",   Value: " & prop.Value.ToString())

Make sure that you use the PropertyIDs enumeration defined in the Solid Edge File Properties Object Library, when accessing the property by ID. Doing so, your code will work independend of the installed SE language!

Remember, that the custom properties and the property sets themselves ALWAYS need to be accessed by name.