Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
m.joudivand
in reply to: m.joudivand

Here we go, I managed to convert the iLogic code to it's corresponding API version.

Option Explicit

Sub PartSelection()


'Select drawing curve of the part
Dim oPick As DrawingCurveSegment
Set oPick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick drawing curve")

'Get assembly occurrene which the selected DrawingCurveSegment belongs to
Dim curveSegment As DrawingCurveSegment
Set curveSegment = oPick



Dim parentCurve As DrawingCurve
Set parentCurve = curveSegment.Parent
Dim someProxy As EdgeProxy 'changed
Set someProxy = parentCurve.ModelGeometry
Dim partOcc As ComponentOccurrence
Set partOcc = someProxy.ContainingOccurrence

'Get AssemblyDocument referenced by DrawingView
Dim dView As drawingView 'needs to be checked
Set dView = parentCurve.Parent
Dim viewAsm As AssemblyDocument
Set viewAsm = dView.ReferencedDocumentDescriptor.ReferencedDocument

'Get all occurrences which has the same ComponentDefinition
Dim allInstancesOfPartOcc As ComponentOccurrencesEnumerator
Set allInstancesOfPartOcc = viewAsm.ComponentDefinition.Occurrences.AllLeafOccurrences(partOcc.Definition)


'Get all DrawingCurveSegments of each part instance
'and convert them to ObjectCollection
Dim occDrawingCurvesCollection As ObjectCollection
Set occDrawingCurvesCollection = ThisApplication.TransientObjects.CreateObjectCollection()

Dim occ As ComponentOccurrence

For Each occ In allInstancesOfPartOcc
    Dim occDrawingCurves As DrawingCurvesEnumerator
    Set occDrawingCurves = dView.DrawingCurves(occ)
    
    Dim occDrawingCurve As DrawingCurve
    For Each occDrawingCurve In occDrawingCurves
    
    Dim occDrawingCurveSegment As DrawingCurveSegment
        For Each occDrawingCurveSegment In occDrawingCurve.Segments
            Call occDrawingCurvesCollection.Add(occDrawingCurveSegment)
        Next
    Next
Next

'Do something useful with occDrawingCurvesCollection

'Select all DrawingCurveSegments of the occ in the DrawingView
Dim drawingDoc As DrawingDocument
Set drawingDoc = dView.Parent.Parent
Call drawingDoc.SelectSet.SelectMultiple(occDrawingCurvesCollection)

End Sub