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: wfajber

Hi @wfajber 

Thanks for your comprehensive explanations.

I figured it out, actually my problem was in defining suitable Object type for the "someProxy" variable.

I defined the object as EdgeProxy which matches the variable's type (see below).

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
            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

'drawingDoc.SelectSet.SelectMultiple (occDrawingCurvesCollection)

End Sub

 

To be honest, I have problem with defining object types for different purpose since there are many objects in the library. @wfajber are you able to let me know how I can attribute objects to the variables? Is there a pathway to learn it?

To be mentioned the code is not working yet and has some bugs, I need to fix it as well.

Waiting for your helpful reply

Sincerely yours

Mohammad