Reply

Writing Custom File Properties to Models/Assemblies

[ Edited ]

 

Hello All,

I have been set the task of designing a small exe file to run in Solid edge that will add some custom file properties to the model / assembly.

I did some very very basic programming as school using VB and i am using VB6 for this as that is what is available to me.

What i desire is that when the exe is executed a window pops up with several text boxes which the user enters the relevant data into and then click a command button which accepts the data and writes it to the Custom file properties. Some of the custom properties are component and sequence number.

I have designed the form but have no idea how to program the code.

If any one could give me any assistance in how to go about programming this it would be very much appreciated. I have looked at the programming with solid edge help but its all greek to me. Talk about being thrown in at the deep end

Many Thanks

IB

 

Posted by: Ian Braid
Post date: 7/27/2008 11:32:24 PM

2 REPLIES

RE: Writing Custom File Properties to Models/Assemblies

[ Edited ]

 

IB,

I don't have VB6 anymore so it's hard for me to give you a good example.  Here is a VBA example that I wrote for you though.

 ' Add reference to Solid Edge File Properties Object Library (PropAuto.dll)Sub Example(fileName As String) Dim objPropertySets As SolidEdgeFileProperties.PropertySets Dim objProperties As SolidEdgeFileProperties.Properties Dim objProperty As SolidEdgeFileProperties.Property Dim objValue As Object Set objPropertySets = New SolidEdgeFileProperties.PropertySets ' Open the file for modification Call objPropertySets.Open(fileName, False) ' Open the 'Custom' property sets Set objProperties = objPropertySets.Item("Custom") ' Get a particular property Set objProperty = objProperties.Item("My Custom Property") ' Get the value. Can be Integer, String, Date or Boolean objValue = objProperty.Value ' Assign a new value objProperty.Value = "My Value" ' Save changes objPropertySets.Save ' Close property sets objPropertySets.Close ' Free COM objects Set objProperty = Nothing Set objProperties = Nothing Set objPropertySets = Nothing End Sub

 

Posted by: Jason Newell
Post date: 8/3/2008 7:38:15 PM

RE: Writing Custom File Properties to Models/Assemblies

[ Edited ]

 

Fantastic jason but i have a slight problem.I have altered the code so it links to the file i want to add the properties to and the properties i want to add but i get and error saying subscript out of range on the line highligthed in bold. Any ideas what causes this or have i altered the code wrong??

PS i have added the SE reference.

Many thanks

IB

 

Private Sub CommandButton1_Click()

' Add reference to Solid Edge File Properties Object Library (PropAuto.dll)

    Dim objPropertySets As SolidEdgeFileProperties.PropertySets

    Dim objProperties As SolidEdgeFileProperties.Properties

    Dim objProperty As SolidEdgeFileProperties.Property

    Dim objValue As Object

 

    Set objPropertySets = New SolidEdgeFileProperties.PropertySets

 

    ' Open the file for modification

    Call objPropertySets.Open("C:\Documents and Settings\My Documents\Templates\Model Template.par", False)

 

    ' Open the 'Custom' property sets

    Set objProperties = objPropertySets.Item("Custom")

 

    ' Get a particular property

    Set objProperty = objProperties.Item("Component")

 

    ' Get the value.  Can be Integer, String, Date or Boolean

    objValue = objProperty.Value

 

    ' Assign a new value

    objProperty.Value = "1256358"

 

    ' Save changes

    objPropertySets.Save

 

    ' Close property sets

    objPropertySets.Close

 

    ' Free COM objects

    Set objProperty = Nothing

    Set objProperties = Nothing

    Set objPropertySets = Nothing

 

End Sub

 

Posted by: Ian Braid
Post date: 8/5/2008 3:01:03 AM