The Myriad of Solid Edge File Properties APIs

Phenom
Phenom

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.pngNote: 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:\Temp\Testfile.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.pngNote: 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.pngSolid Edge Users Facebook Group - Let's Sync

Comments
Solution Partner Valued Contributor

Hi Tushar,

 

Can you please show an example using the Design Manager API?

I am sure the calls are more or less similar to what you have already shown but I constantly get errors just instantiating the objects. BTW, I am using ST9.

 

Also can you convert your Case 2 code to C#. I am familiar with C# and VB.net but couldn't get it to working using c#.

 

Thanks,

-Thilak Rao

Phenom

Hi Thilak:

 

I am still on ST8- no Design Manager, but I think it should be similar to the Revision Manager.

I wil give it a try.

   

For converting code to/from VB.Net/CSharp, I'd suggest using the online converter at:

http://converter.telerik.com/

 

Tushar

 

Solution Partner Valued Contributor

Hi Tushar,

 

Thanks for the quick response.

I think I had some quirks in my c# code but eventually it worked.

 

But the issue with Design Manager remains in VB.net and C#. So I think something is wrong in its COM registration or marshalling of the objects.

 

Thanks,

-Thilak Rao

Top Kudoed Posts