The Myriad of Solid Edge File Properties APIs

Accessing Solid Edge document properties to either read or modify is the most common activity performed on Solid Edge documents apart from when manipulating the content of the document itself.

Here’s a visual layout of the various properties logically grouped into 8 tabs.

01_FileProperties.png

From the API standpoint all of these are again grouped into property sets which do not necessarily correspond to the tabs in image above. They are grouped into 6 sets as below:

  1. SummaryInformation
  2. ExtendedSummaryInformation
  3. DocumentSummaryInformation
  4. ProjectInformation
  5. VersionHistory
  6. Custom
TipIcon.png

Note: There is no space within the set names.

The Solid Edge API provides several ways to access document properties.

  1. Adding a reference to the dedicated Solid Edge File Properties Object Library.
  2. Adding a reference to the Solid Edge Framework Type Library.
  3. Adding a reference to the Solid Edge Revision Manager (Design Manager) Object Library.

Whether Solid Edge is running or closed will make a difference when choosing one of these.

If Solid Edge is running and the file is open then you have already referenced the Framework library and can use it to access the file properties. Else if your application is using a reference just to the Revision (or Design) Manager library, file properties are available too.

Else, If your application is involved in purely manipulating file properties then a reference to the File Properties library is sufficient.

Case 1 (a): When Solid Edge is running: The Full Property Set

The code snippet below shows the complete flow starting from the Solid Edge object through accessing and changing the property Document Number from the available properties:

Dim objApp As SolidEdgeFramework.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("SolidEdge.Application")

Dim objPropSets As SolidEdgeFramework.PropertySets = Nothing Dim objProp As SolidEdgeFramework.Property = Nothing Dim objProps As SolidEdgeFramework.Properties = Nothing Dim objDocument As SolidEdgeFramework.SolidEdgeDocument = Nothing

objDocument = objApp.ActiveDocument objPropSets = objDocument.Properties For Each objProps In objPropSets If objProps.Name = "ProjectInformation" Then    For Each objProp In objProps    If objProp.Name = "Document Number" Then      objProp.Value = "Document123"      End If    Next End If Next

Case 1 (b): When Solid Edge is running: Only Key Properties

Dim objApp As SolidEdgeFramework.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("SolidEdge.Application")

Dim objDocument As SolidEdgeFramework.SolidEdgeDocument =

objApp.ActiveDocument 

Dim objSummaryInfo As SolidEdgeFramework.SummaryInfo = objDocument.SummaryInfo

At this moment you have access to the most common of the file properties:

02_SummaryInfo.png

Case 2: Solid Edge File Properties library

Alternatively, if you want to use a reference to the Solid Edge File Properties library, then a document need not be open in Solid Edge, nor Solid Edge be running.

Change the file properties directly like this:

TipIcon.png

 Note: The keyword New in the opening line. A new object for Solid Edge File Properties should be created.

Dim objPropSets As SolidEdgeFileProperties.PropertySets = New SolidEdgeFileProperties.PropertySets

Dim objProp As SolidEdgeFileProperties.Property = Nothing

Dim objProps As SolidEdgeFileProperties.Properties = Nothing

Dim sDocument As String = "C:TempTestfile.par"

objPropSets.Open(sDocument, False)

For Each objProps In objPropSets
    If objProps.Name = "ProjectInformation" Then
        For Each objProp In objProps
            If objProp.Name = "Document Number" Then
                objProp.Value = "Document123"
            End If
        Next
    End If
Next

objPropSets.Save() objPropSets.Close()

TipIcon.png

Note: In code snippet above,in the Open function, set the second argument to False to modify file property value and set it to True to prevent any modifications.

This covers the minimum basics of what you need to get started with Solid Edge file properties. I will soon upload VB.Net project files for the all the cases discussed above depending on the response. Watch this space for the attachments.

In the next installment or as an edit to the article above I will show how to create new custom properties, how to check if a custom property exists and many such tip-tricks.

If you have any further questions regarding accessing or manipulating file properties, do leave a comment below or search or post directly to the Developer forum.

~Tushar Suradkar

fb.png

Solid Edge Users Facebook Group – Let’s Sync

Comments

2 thoughts on “The Myriad of Solid Edge File Properties APIs
  • KentKeller

    This crashes Excel every single time. Any ideas?

    Dim objProps As SolidEdgeFileProperties.PropertySets
    Set objProps = New SolidEdgeFileProperties.PropertySets
    Set Foo = objProps.Open(“C:\Users\kkeller\Documents\TestCadVault\100\100000\100000-01.sldasm”, False) ‘This crashes Excel every single time

Leave a Reply