×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Highlight drawing component in graphics view

Highlight drawing component in graphics view

Highlight drawing component in graphics view

(OP)
Has anyone else noticed that 2008 (I think) dropped the functionality that when you select a component in the design tree of an assembly drawing (.slddrw) it used to draw a brownish box around the component?  This really helped in figuring out what was what.  I really miss it.

So guess what.  I wrote a macro.  Surprised?  smile

This macro will highlight all the edges in the graphics area (visible or not) of the components selected in the feature tree.  Subassemblies are OK too.  Anything else that is selected (hole features, planes, sketches, etc) will be ignored.  Unfortunately, it won't do silhouette edges, so if you have a sphere or a torus or some other topological oddity then it won't show up.

Now I just need to find an unused shortcut key....

CODE

Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swDwg As SldWorks.DrawingDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim NumSels As Long
Dim swDwgComp As SldWorks.DrawingComponent
Dim swComp As SldWorks.Component2
Dim i As Long



Sub main()

Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
If swDoc.GetType <> swDocDRAWING Then
    Exit Sub
End If
Set swDwg = swDoc
Set swSelMgr = swDoc.SelectionManager
NumSels = swSelMgr.GetSelectedObjectCount2(-1)
'MsgBox NumSels & " selections made"
For i = 1 To NumSels
    If swSelMgr.GetSelectedObjectType3(i, -1) = swSelCOMPONENTS Then
        Set swDwgComp = swSelMgr.GetSelectedObject6(i, -1)
        Set swComp = swDwgComp.Component
        If swComp.GetModelDoc.GetType = swDocASSEMBLY Then
            Call HighlightAssy(swComp, swDwg.ActiveDrawingView)
        Else
            Call HighlightPart(swComp)
        End If
    End If
Next i
'MsgBox swDwg.ActiveDrawingView.Name
End Sub
Sub HighlightPart(ByVal myComp As SldWorks.Component2)

Dim CompBods As Variant
Dim BodEdges As Variant
Dim j As Long
Dim k As Long

CompBods = myComp.GetBodies2(swAllBodies)
For j = 0 To UBound(CompBods)
    BodEdges = CompBods(j).GetEdges
    On Error GoTo TRYFACES
    For k = 0 To UBound(BodEdges)
        BodEdges(k).Highlight True
    Next k
DIDFACES:
Next j

Debug.Print "Highlighted " & myComp.Name2
Exit Sub

TRYFACES:
BodEdges = CompBods(j).GetFaces
For k = 0 To UBound(BodEdges)
    BodEdges(k).Highlight True
Next k
Resume DIDFACES

End Sub

Sub HighlightAssy(ByVal myAssyComp As SldWorks.Component2, myView As SldWorks.View)
Dim j As Long
Dim AssyChildren As Variant
Dim myDwgComp As SldWorks.DrawingComponent

AssyChildren = myAssyComp.GetChildren
For j = 0 To UBound(AssyChildren)
    If (AssyChildren(j).GetSuppression = swComponentResolved) Or (AssyChildren(j).GetSuppression = swComponentFullyResolved) Then
        If AssyChildren(j).GetModelDoc.GetType = swDocASSEMBLY Then
            Debug.Print "Get children of " & AssyChildren(j).Name2
            HighlightAssy AssyChildren(j), myView
        Else
            HighlightPart AssyChildren(j)
        End If
    Else
        Debug.Print AssyChildren(j).Name & " Not resolved"
    End If
Next j

End Sub

-handleman, CSWP (The new, easy test)

RE: Highlight drawing component in graphics view

How about turning the appropriate option instead of writing a macro? ;)

In the display/selection options, check in the box that says "dynamic highlight from graphic view".

On the plus side, props on not letting a problem bother you! Just write a couple of lines of codes and keep on working! I wish I could do that!
 

RE: Highlight drawing component in graphics view

(OP)
Actually, "dynamic highlight from graphics view" highlights edges and faces of components as you mouse over them in a drawing view, part, or assembly context.  I already have that enabled.  And I re-enable it every time I import an IGES file, since importing one turns the option off.

No, this macro highlights the edges in an assembly drawing view of the components selected in the feature manager design tree.  SW used to do this with a brownish box drawn around the components in the graphics area.  It doesn't anymore - at least not on our machines.   

-handleman, CSWP (The new, easy test)

RE: Highlight drawing component in graphics view

My SW08-SP4 install still shows the orange/brown box around an assy component when selected from the FM; and it is enabled/disabled by the Dynamic highlight from graphics view option. Strange!

cheers

RE: Highlight drawing component in graphics view

(OP)
I suppose it could be a graphics issue.  If so it's the only one I've encountered (or noticed anyway) with our current setup of card and SW certified driver, and the change seemed to coincide with installation of 2008.  Maybe I need to go ahead and get us updated to the latest SP and/or try a different driver.

-handleman, CSWP (The new, easy test)

RE: Highlight drawing component in graphics view

Could that function be affected by different mouse driver settings?

cheers

RE: Highlight drawing component in graphics view

Quote (The ever-so-wise handleman):

And I re-enable it every time I import an IGES file, since importing one turns the option off.

Is that what toggles this option off???!!!  I've seen this for years, but never been able to track it down.  Good find.  Thanks.

Joe
SW Office 2006 SP5.1
P4 3.0Ghz 1GB
ATI FireGL X1

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources