Reply

Retriving Custom Properties of an assembly occurence

[ Edited ]

 

Hi all

I am new to Solid Egde Programming and to this community. I want to retrive the properties under the "Custom" Tab of Document File Properties through VB?

I will be grate to recieve the any help in this regards.

Thanks In Advance

Regards                                                                                                       

Noman Syed

 

Posted by: Noman Syed
Post date: 11/14/2007 1:10:10 AM

2 REPLIES

RE: Retriving Custom Properties of an assembly occurence

[ Edited ]

 

Noman,

See the following code and attachment.

 Imports SolidEdgeAssemblyImports SolidEdgeFrameworkImports System.Runtime.InteropServicesModule Module1 Sub Main() Dim objApp As SolidEdgeFramework.Application Dim objAssembly As SolidEdgeAssembly.AssemblyDocument Dim objOccurrences As SolidEdgeAssembly.Occurrences Dim objOccurrence As SolidEdgeAssembly.Occurrence objApp = Marshal.GetActiveObject("SolidEdge.Application") 'I used "C:\Program Files\Solid Edge V20\Training\Coffee Pot.asm" objAssembly = objApp.ActiveDocument objOccurrences = objAssembly.Occurrences For Each objOccurrence In objOccurrences ProcessOccurrence(objOccurrence) Next End Sub Sub ProcessOccurrence(ByVal objOccurrence As SolidEdgeAssembly.Occurrence) Dim objSubOccurrences As SolidEdgeAssembly.SubOccurrences = Nothing Dim objSubOccurrence As SolidEdgeAssembly.SubOccurrence = Nothing Try ' 1st level of an assembly are of type SolidEdgeAssembly.Occurrence. GetDocumentCustomProperty(objOccurrence.OccurrenceDocument, "CUSTOM NAME FIELD") ' 2st level and lower of an assembly are of type SolidEdgeAssembly.SubOccurrence. objSubOccurrences = objOccurrence.SubOccurrences If Not (objSubOccurrences Is Nothing) Then For Each objSubOccurrence In objSubOccurrences 'Recursive call to walk the assembly tree ProcessSubOccurrenceSubOccurrences(objSubOccurrence) Next End If Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub Sub ProcessSubOccurrenceSubOccurrences(ByVal objSubOccurrence As SolidEdgeAssembly.SubOccurrence) Dim objSubOccurrenceSubOccurrences As SolidEdgeAssembly.SubOccurrences = Nothing Dim objSubOccurrenceSubOccurrence As SolidEdgeAssembly.SubOccurrence = Nothing GetDocumentCustomProperty(objSubOccurrence.SubOccurrenceDocument, "CUSTOM NAME FIELD") objSubOccurrenceSubOccurrences = objSubOccurrence.SubOccurrences If Not (objSubOccurrenceSubOccurrences Is Nothing) Then For Each objSubOccurrenceSubOccurrence In objSubOccurrenceSubOccurrences GetDocumentCustomProperty(objSubOccurrenceSubOccurrence.SubOccurrenceDocument, "CUSTOM NAME FIELD") Next End If End Sub Sub GetDocumentCustomProperty(ByVal objDocument As SolidEdgeFramework.SolidEdgeDocument, ByVal propertyName As String) Dim objPropertySets As SolidEdgeFramework.PropertySets = Nothing Dim objProperties As SolidEdgeFramework.Properties = Nothing Dim objProperty As SolidEdgeFramework.Property = Nothing Try objPropertySets = objDocument.Properties objProperties = objPropertySets.Item("Custom") objProperty = objProperties.Item(propertyName) Console.WriteLine(String.Format("{0}: {1} = {2}", objDocument.Name, propertyName, objProperty.Value.ToString())) Catch ex As Exception Console.WriteLine(ex.Message) End Try End SubEnd Module

 

Posted by: Jason Newell
Post date: 11/18/2007 8:29:29 PM

RE: Retriving Custom Properties of an assembly occurence

[ Edited ]

 

Jason:

Thank you very much

Regards

Noman Syed

 

Posted by: Noman Syed
Post date: 11/21/2007 3:37:44 AM