Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

More than one file multi-selection sequentially question

Pioneer
Pioneer

Hello? Edge API Developers..


I made up the code as below,

The waxes quickly make a quick sheet drawing of only the parts I have selected in the assembly.

but... Only one will be processed.

Debugging mode (1 STEP) processing was performed in a normal sequence.
However, only one will be processed as a whole.

Please review the code. 

What did you do wrong?

 

(...Don't you happen to support multi-selection?...ㅠㅠ)

 

 

 Dim i As Integer

        Try
            objapp = Marshal.GetActiveObject("SolidEdge.Application")
            objPart = TryCast(objapp.ActiveDocument, SolidEdgePart.PartDocument)
            objasm = TryCast(objapp.ActiveDocument, SolidEdgeAssembly.AssemblyDocument)
            Objsm = TryCast(objapp.ActiveDocument, SolidEdgePart.SheetMetalDocument)
            objdoc = objapp.ActiveDocument

            If objapp.ActiveSelectSet.Count >= 2 Then

                For i = objapp.ActiveSelectSet.Count To 1 Step -1

                    If objapp.ActiveSelectSet.Item(i).Type = igReference Then
                        objdoc = objapp.ActiveSelectSet.Item(i).Object.OccurrenceDocument

                    ElseIf objapp.ActiveSelectSet.Item(i).Type = igSubAssembly Then
                        objdoc = objapp.ActiveSelectSet.Item(i).OccurrenceDocument

                    ElseIf objapp.ActiveSelectSet.Item(i).Type = igPart Then
                        objdoc = objapp.ActiveSelectSet.Item(i).OccurrenceDocument

                        pathname = objdoc.Path
                        Partname = objdoc.FullName
                        DFTname = IO.Path.ChangeExtension(Partname, "DFT")
                        objdoc = objapp.Documents.Open(Path33 + "__Quick Sheet XY.DFT")
                        objdoc.PopulateQuicksheetTemplate(Partname)
                        objdoc.SaveAs(DFTname)

                    End If

                Next i

            End If

        Catch

        End Try

 

4 REPLIES 4

Re: More than one file multi-selection sequentially question

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

Hi,

 

You lost the reference to the active document when you open your draft.

Code should be something like this :

        Dim objapp As SolidEdgeFramework.Application = Nothing
        Dim ObjDoc As SolidEdgeFramework.SolidEdgeDocument = Nothing
        Dim ObjDraft As SolidEdgeDraft.DraftDocument = Nothing

        Dim i As Integer

        Try
            objapp = Marshal.GetActiveObject("SolidEdge.Application")
            ObjDoc = objapp.ActiveDocument

            If objapp.ActiveSelectSet.Count >= 2 Then

                For i = objapp.ActiveSelectSet.Count To 1 Step -1

                    If objapp.ActiveSelectSet.Item(i).Type = igReference Then
                        objdoc = objapp.ActiveSelectSet.Item(i).Object.OccurrenceDocument

                    ElseIf objapp.ActiveSelectSet.Item(i).Type = igSubAssembly Then
                        objdoc = objapp.ActiveSelectSet.Item(i).OccurrenceDocument

                    ElseIf objapp.ActiveSelectSet.Item(i).Type = igPart Then
                        objdoc = objapp.ActiveSelectSet.Item(i).OccurrenceDocument

                        Dim pathname As String = ObjDoc.Path
                        Dim Partname As String = ObjDoc.FullName
                        Dim DFTname As String = IO.Path.ChangeExtension(Partname, "DFT")
                        ObjDraft = objapp.Documents.Open(Path33 + "__Quick Sheet XY.DFT")
                        ObjDraft.PopulateQuicksheetTemplate(Partname)
                        ObjDraft.SaveAs(DFTname)
                        ObjDraft.Close(False)

                        If Not ObjDraft Is Nothing Then
                            Marshal.ReleaseComObject(ObjDraft)
                            ObjDraft = Nothing
                        End If

                    End If

                Next i

            End If

        Catch

        End Try

Regards,

 

Romuald

Re: More than one file multi-selection sequentially question

Pioneer
Pioneer

Hi @LordCoy 
Thank you for your reply.

2 parts were selected and tested in the assembly environment with the above code.

It's only one run, and it's not going to work anymore.
It's the same as the test.

Re: More than one file multi-selection sequentially question

Legend
Legend

@Hclee1 

 

objapp.Documents.Open creates a new objapp.ActiveSelectSet.

Maybe objasm.SelectSet works.

 

Regards

Gerald Haberl

Re: More than one file multi-selection sequentially question

Experimenter
Experimenter

I suggest simply assigning the selectset to a variable and then processing its items. This guarantees that the same selectset will be referenced in the loop, since the activeselectset changes once the draft document gets opened, as mentioned above.

 

If objapp.ActiveSelectSet.Count >= 2 Then
                
Dim selset as SelectSet = objApp.ActiveSelectSet
For i = selset.Count To 1 Step -1
If selset.Item(i).Type = igReference Then objdoc = objapp.ActiveSelectSet.Item(i).Object.OccurrenceDocument ElseIf selset.Item(i).Type = igSubAssembly Then objdoc = objapp.ActiveSelectSet.Item(i).OccurrenceDocument ElseIf selset.Item(i).Type = igPart Then objdoc = objapp.ActiveSelectSet.Item(i).OccurrenceDocument pathname = objdoc.Path Partname = objdoc.FullName DFTname = IO.Path.ChangeExtension(Partname, "DFT") objdoc = objapp.Documents.Open(Path33 + "__Quick Sheet XY.DFT") objdoc.PopulateQuicksheetTemplate(Partname) objdoc.SaveAs(DFTname) End If Next i End If  

 

Regards,

 

pbuhrer

SE ST10