×
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

Macro

Macro

(OP)
Hi,

I was trying to create a macro this morning.
I want to select edges in a drawing view and then run the macro.

It would change the edge to "Show" with a line type of Phantom and a line width of 0.

When I run the macro I made, it only changes to "Show" the first edge I select and then finishes.

I've been reading API docs all day & can't seem to figure out what I need.

Here's what I thought would work.
Anybody know what I'm missing?

Dim swApp As Object
Dim Part As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Part.ShowEdge
Part.SetLineStyle "HIDDEN"
Part.SetLineWidth 0
End Sub

Thanks

RE: Macro

Look at help on Selection Manager.  Apparently with the calls you are using you must cycle through all the selected edges and set each one individually.

RE: Macro

(OP)
I've been trying that too.
I get my message box for each edge selected, but I don't know how to change the line then.

Option Explicit
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim SelObj As Object
Dim ObjType As Variant
Dim SelEdge As Object
Dim EdgeName As String


Sub main()
Dim i As Integer
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager()

For i = 1 To SelMgr.GetSelectedObjectCount
    Set SelObj = SelMgr.GetSelectedObject5(i)
    ObjType = SelMgr.GetSelectedObjectType(i)
    If (ObjType = 1) Then
    swApp.SendMsgToUser (ObjType & " = ObjType")
    Part.ShowEdge
    Part.SetLineStyle "HIDDEN"
    
    
    End If
    
      
Next i


'Part.ShowEdge
'Part.SetLineStyle "HIDDEN"
End Sub

RE: Macro

Cooner001,

I had some time to experiment tonight with your first marco.  I was not familar with the three API calls in your code.  It appears that Part.ShowEdge is the culprit.  If I comment out that line and run the macro, all the lines selected will turn hidden.  Are the edges you are selecting hidden?  If not, take out the Part.ShowEdge call.  

One question for you.  Where did you find out the correct value used with the SetLineStyle should be "HIDDEN" and not swLineHIDDEN as defined in API help (I only have SW2004 at home)?  It was obvious, when looking at what the input value was suppose to be, that a string value was required but, help indicates a integer constant from swLineStyles_e should be used?

Regards,

Regg
 

RE: Macro

Use the Selection Manager to collect the selections into an array or collection.  The iterate through the array/collection items for each.

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