assemblygroups.add --> How to use ?

Hello,

 

I want to write a tool, to group occurrences of an assembly, which are reference, in a Group.

For this I use the code

 

‘Check that the Environment is Assemlby

If Not objSEApp.ActiveEnvironment = "Assembly" Then

            MsgBox("Falsche Umgebung")

            Exit Sub

        End If

 

        objDocAssembly = objSEApp.ActiveDocument

        objOccurences = objDocAssembly.Occurrences

        objSelectSet = objDocAssembly.SelectSet

        For i = 1 To objOccurences.Count

            objOccurence = objOccurences.Item(i)

            If objOccurence.DisplayAsReference = True Then

                objSelectSet.Add(objOccurence)

            End If

        Next

        objGroups = objDocAssembly.AssemblyGroups

        objGroups.add( Integer ; SystemArray)

 

My problem is that I don’t know, what to fill in for the Integer and the SystemArray in the command Add(System.Int32, ref System.Object)

 

Best regards

 

Michael

 

 

 

Posted by: Michael Leesing
Post date: 1/25/2012 1:16:39 AM

2 REPLIES

RE: assemblygroups.add --> How to use ?

Hi Miele,

 

according to the API help an array of objects (occurrence objects in your case) is required as second parameter and the first parameter tells the count of objects of that given array.

 

 

Posted by: Wolfgang Kunert
Post date: 1/25/2012 10:11:20 PM

RE: assemblygroups.add --> How to use ?

Hello Wolfgang,

 

I am not sure, how to create the array of occurrence objects to give it to the command. At least I try it so, but it doesn’t work. I get an exception.

 

Dim objoccrenceColl() As SolidEdgeAssembly.Occurrence

Dim i, Anzahl As Integer

Dim objDocAssembly As SolidEdgeAssembly.AssemblyDocument

Dim objOccurences As SolidEdgeAssembly.Occurrences

Dim objOccurence As SolidEdgeAssembly.Occurrence

Dim objSelectSet As SolidEdgeFramework.SelectSet

‘………….

 

Anzahl = 0

 

For i = 1 To objOccurences.Count

     objOccurence = objOccurences.Item(i)

     If objOccurence.DisplayAsReference = True Then

         ReDim Preserve objoccrenceColl(Anzahl)

         objoccrenceColl(Anzahl) = objOccurence

         objSelectSet.Add(objOccurence)

         Anzahl += 1

    End If

Next

 

objGroups.Add(Anzahl - 1, objoccrenceColl)

 

'########

 

Maybe you know a solution?

 

Best regards Michael

 

 

Posted by: Michael Leesing
Post date: 1/26/2012 6:15:35 PM