Add-in - Create assembly configurations from query

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

I try to create an add'in that will create assembly configurations using query result.

 

Display doesn't update so configuration aren't correct.

 

Can you help me with this problem.

 

        If Not ListQuery Is Nothing Then
            Dim ObjAsm As SolidEdgeAssembly.AssemblyDocument = Nothing
            Dim Configs As SolidEdgeAssembly.Configurations = Nothing
            Dim Config As SolidEdgeAssembly.Configuration = Nothing
            Dim Queries As SolidEdgeAssembly.Queries = Nothing
            Dim Query As SolidEdgeAssembly.Query = Nothing
            Dim NbOcc As Integer = 0
            Try
                ObjAsm = DirectCast(MyAddIn.Instance.Application.ActiveDocument, SolidEdgeAssembly.AssemblyDocument)
                Configs = ObjAsm.Configurations
                Queries = ObjAsm.Queries

                For Each ElemQuery As Query In ListQuery
                    If ElemQuery.Process Then
                        Try
                            'Get the Query
                            Query = Nothing
                            For i = 1 To Queries.Count
                                If Queries.QueryName(Queries.Item(i)) = ElemQuery.Nom Then
                                    Query = Queries.Item(i)
                                    Exit For
                                End If
                            Next
                            If Not Query Is Nothing Then
                                'Execute Query
                                NbOcc = Query.MatchesCount
                            End If

                            If Not NbOcc = 0 Then
                                'Show Only
                                MyAddIn.Instance.Application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyAssemblyToolsShowOnly)
                                ObjAsm.UpdatePathfinder(SolidEdgeAssembly.AssemblyPathfinderUpdateConstants.seUpdate)
 
                                MyAddIn.Instance.Application.DoIdle()

                                'Get the configuration
                                Config = Nothing
                                For i = 1 To Configs.Count
                                    If Configs.Item(i).Name = ElemQuery.Nom Then
                                        Config = Configs.Item(i)
                                        Exit For
                                    End If
                                Next

                                If Config Is Nothing Then
                                    Config = Configs.Add(ElemQuery.Nom)
                                    Config.Save()
                                Else
                                    Config.Update()
                                End If

                            End If

                        Catch ex As Exception
                            Continue For
                        End Try
                    End If
                Next
            Catch ex As Exception
                ObjAsm = Nothing
                Configs = Nothing
                Config = Nothing
                Queries = Nothing
                Query = Nothing

            End Try
            ObjAsm = Nothing
            Configs = Nothing
            Config = Nothing
            Queries = Nothing
            Query = Nothing

        End If

 

Thanks.

 

Romuald


Romuald BERTIN