Reply

Display configuration settings for sub-assembly help needed.

In the Solid Edge assembly you are able to select a sub assembly and change its display configuration. This works really good. But when I try to do the same with the Solid Edge API then it does not. Important to know is that is I change display configurations by API in the active assembly it’s working like it should. When i use this code the display config of the sub assembly change in the menu but is not visible applied. I hope i'm doing something wrong here and there is a solution.

 

Below is my example code:

 

    Private SE_App As SolidEdgeFramework.Application

    Private SE_ASM As SolidEdgeAssembly.AssemblyDocument

    Private SE_Occurrences As SolidEdgeAssembly.Occurrences

 

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        'Connecting to Solid Edge active ASM

        SE_App = Marshal.GetActiveObject("SolidEdge.Application")

        SE_ASM = SE_App.ActiveDocument

        SE_Occurrences = SE_ASM.Occurrences

 

        Dim SE_ASM_OccurrenceDocument As SolidEdgeAssembly.AssemblyDocument

        Dim SE_Configurations As SolidEdgeAssembly.Configurations

        'Looping through the occurrences to check if the display configuration "Parts"or "Uitgewerkt" exists. If we find one we add it to and datagridview on the form.

        For Each Occ As SolidEdgeAssembly.Occurrence In SE_Occurrences

            SE_ASM_OccurrenceDocument = Occ.PartDocument

            SE_Configurations = SE_ASM_OccurrenceDocument.Configurations

            For Each SE_Configuration As SolidEdgeAssembly.Configuration In SE_Configurations

                If SE_Configuration.Name = "Parts" Or SE_Configuration.Name = "Uitgewerkt" Then

                    DataGridView_Occurrences.Rows.Add()

                    Dim NewRow As DataGridViewRow = DataGridView_Occurrences.Rows.Item(DataGridView_Occurrences.Rows.GetLastRow(DataGridViewElementStates.Visible))

                    NewRow.Cells.Item(0).Value = Occ.Name

                    NewRow.Cells.Item(3).Value = Occ.Index

                End If

            Next

        Next

    End Sub

 

    Private Sub Button_Ok_Click(sender As Object, e As EventArgs) Handles Button_Ok.Click

        'on the form you can choose which display configuration you want to show.

        'When OK we loop trough each row to see if we have to apply a certain display configuration

        For Each row As DataGridViewRow In Me.DataGridView_Occurrences.Rows

            Dim SE_ASM_OccurrenceDocument As SolidEdgeAssembly.AssemblyDocument

            Dim SE_Configurations As SolidEdgeAssembly.Configurations

            'Selecting the right occurrence

            SE_ASM_OccurrenceDocument = SE_Occurrences.Item(row.Cells.Item(0).Value).OccurrenceDocument

            SE_Configurations = SE_ASM_OccurrenceDocument.Configurations

            If row.Cells.Item(1).Value.ToString = "True" Then

                Try

                    For Each SE_configuration As SolidEdgeAssembly.Configuration In SE_Configurations

                        If SE_configuration.Name = "Part" Then

                            SE_configuration.Apply()

                            Exit For

                        End If

                    Next

                Catch ex As Exception

                    MsgBox(ex.Message)

                End Try

            ElseIf row.Cells.Item(2).Value.ToString = "True" Then

                Try

                    For Each SE_configuration As SolidEdgeAssembly.Configuration In SE_Configurations

                        If SE_configuration.Name = "Uitgewerkt" Then

                            SE_configuration.Apply()

                        End If

                    Next

                Catch ex As Exception

                    MsgBox(ex.Message)

                End Try

            End If

        Next

    End Sub

 

8 REPLIES

Re: Display configuration settings for sub-assembly help needed.

[ Edited ]

I just had a quick look at this.

 

I suspect that SE is doing a lot more 'under the hood' when you select a configuration for a subassembly. An assembly config file is not set up to support/store 'nested' configurations.

 

There's a very good chance that when you select a config for a subassembly through the UI, SE looks at the details of that config and then updates the shown/hidden occurrences in the top level assembly.

 

The active config for the top level assembly goes blank after selecting a subassy config, maybe to indicate that the current top level config is no longer 'valid'.

 

You may have to try and implement the same in your automation.

Re: Display configuration settings for sub-assembly help needed.

[ Edited ]

In the SE UI, IPA-ing into the subassy, selecting the configuration, then returning to the top level assy achieves the desired result as well. This might be a cheap and nasty workaround?

Re: Display configuration settings for sub-assembly help needed.

Thx so far i will look into this

Re: Display configuration settings for sub-assembly help needed.

Hi  eff-caap,
 
To try and save you the time of digging thru the command constants. I had a similar problem and needed to cycle thru an assembly and all subassemblies then only update sheetmetal parts. These are the steps that worked for me.
 
1. Use this to select the occurence you want to edit -> objOccurence.Select(True)
 
2. Use this to place the selected occurence in to edit in assembly -> objApp.StartCommand(57872)
 
3. Then place a pause in the code to allow for the command to run -> System.Threading.Thread.Sleep(1000)
 
4.  Assign the objOccurence.OccurrenceDocument to a document type for the occurence your editing
 
5. Run any code you want as if the occurence is the open file

6. Then run this command to exit back out -> objApp.StartCommand(40013)
 
I hope this help.

Re: Display configuration settings for sub-assembly help needed.

[ Edited ]

Or make life a bit easier for yourself with command constants...

 

seApp.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyEditActivateembeddedorlinkedobject)

 

'do stuff

 

seApp.StartCommand(SolidEdgeConstants.SolidEdgeCommandConstants.seAssemblySelectCommand)

 

 

 

 

Re: Display configuration settings for sub-assembly help needed.

I Will try to check it out next week. I will let you know! Thx for the reply.

Met vriendelijke groet,

Eef de Klerk

CAAP

Re: Display configuration settings for sub-assembly help needed.

Hi,

 

I tried the given solution but it doesn't work for me. I added a reselect of the occ because he lost its active selectset. I hope i'm making a mistake. Do you have a working sample?

 

Below a part of the code:

 

 

If row.Cells.Item(1).Value.ToString = "True" Then
Try
SE_App.ActiveSelectSet.RemoveAll()
SE_App.ActiveSelectSet.Add(SE_Occurrences.Item(row.Cells.Item(0).Value))
SE_App.StartCommand(57872)
System.Threading.Thread.Sleep(500)
SE_Configurations = SE_App.ActiveDocument.Configurations
For Each SE_configuration As SolidEdgeAssembly.Configuration In SE_Configurations
If SE_configuration.Name = "Part" Then
SE_App.ActiveSelectSet.RemoveAll()
SE_App.ActiveSelectSet.Add(SE_Occurrences.Item(row.Cells.Item(0).Value))
SE_configuration.Apply()
SE_App.StartCommand(40013)
Exit For
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try

Re: Display configuration settings for sub-assembly help needed.

You shouldn't need to have anything selected when you apply the configuration in the subassembly. This isn't necessary when doing the same thing though the UI.