Help: Highlight Selected Body (Select one in view then it'll highlight in all other views) using API/iLogic

Help: Highlight Selected Body (Select one in view then it'll highlight in all other views) using API/iLogic

ngdnam88
Advocate Advocate
307 Views
4 Replies
Message 1 of 5

Help: Highlight Selected Body (Select one in view then it'll highlight in all other views) using API/iLogic

ngdnam88
Advocate
Advocate

Dears,

Please help me a code by iLogic/API/VBA that can: Highlight Selected Body (Select one (red arrow) in any view then it'll highlight (green arrows) in all other views) in Drawing.

ngnam1988_0-1671169222691.png

The 3D Model can be done by:

+ Part with MultiSolid-Bodies (.ipt)

+ Part with MultiSolid-Bodies but put inside an iAssembly (.iam)
Thank you very much!

0 Likes
308 Views
4 Replies
Replies (4)
Message 2 of 5

Michael.Navara
Advisor
Advisor

This is a minimalistic sample, how to highlight picked body in all views on current sheet.

 

Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick curve")
Dim pickedCurveSegment As DrawingCurveSegment = pick

Dim pickedDrawingCurve As DrawingCurve = pickedCurveSegment.Parent
Dim modelGeometry As Object = pickedDrawingCurve.ModelGeometry
Dim edge As Edge = modelGeometry
Dim surfaceBody As SurfaceBody = edge.Parent

Dim sheet As Sheet = pickedDrawingCurve.Parent.Parent
Dim drawing As DrawingDocument = sheet.Parent

Dim hSet As HighlightSet = drawing.CreateHighlightSet()
hSet.Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

For Each drwView As DrawingView In sheet.DrawingViews
    Dim bodyCurves As DrawingCurvesEnumerator = drwView.DrawingCurves(surfaceBody)
    Dim curveSegmentsCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection()
    For Each bodyCurve As DrawingCurve In bodyCurves
        For Each bodyCurveSegment As DrawingCurveSegment In bodyCurve.Segments
            curveSegmentsCollection.Add(bodyCurveSegment)
        Next
    Next

    hSet.AddMultipleItems(curveSegmentsCollection)
Next
Message 3 of 5

ngdnam88
Advocate
Advocate

Thanks @Michael.Navara 
Your code can run in normal (standard) part/assembly but got an error in iPart/iAssembly

ngnam1988_0-1671179957357.png

I'm trying understand your code. Thanks for your help!

0 Likes
Message 4 of 5

Michael.Navara
Advisor
Advisor

May be. It is just a sample 'how to'. You can upgrade the code for iParts/iAssemblies as well.

0 Likes
Message 5 of 5

ngdnam88
Advocate
Advocate
It's very difficult with me, but I'll try to do...
Thank you very much!
0 Likes