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
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
RE: Macro
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
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