Macro for tangent edges and high quality views
Macro for tangent edges and high quality views
I'm in the need of finding a fast way for turning on the tangent edges of a drawing, and it would be great if I could also set the quality of the view as high. Does anybody have a macro for this?. I know I can set the quality of the view as high through the task scheduler but I can't find any other way for turning on the edges than manually.
Thanks
Thanks
Re: Macro for tangent edges and high quality views
Do you want to turn on the tangent edge for ALL existing drawing view?
This most probably will require iterate through all your view
Or do you want to turn the tangent edge for all new drawing view created?
This normally just involve turning on a system setting
This most probably will require iterate through all your view
Or do you want to turn the tangent edge for all new drawing view created?
This normally just involve turning on a system setting
Far too many items in the world are designed, constructed and foisted upon us with no understanding-or even care-for how we will use them.
Re: Macro for tangent edges and high quality views
I have a client that sends me every drawing like that, so i need to convert every view of every drawing..
Zhen-Wei Tee wrote: ↑Mon Oct 24, 2022 7:34 pm Do you want to turn on the tangent edge for ALL existing drawing view?
This most probably will require iterate through all your view
Or do you want to turn the tangent edge for all new drawing view created?
This normally just involve turning on a system setting
Re: Macro for tangent edges and high quality views
I drafted a quick macro that change the tangent edge display to TangentEdge with Font and also change the view quality to high
Change the line in red to change setting
Change the line in red to change setting
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim i As Integer
Dim j As Integer
Dim vViews As Variant
Dim swView As SldWorks.View
Dim swModView As SldWorks.ModelView
Dim bRet As Boolean
Sub main()
Set swApp = Application.SldWorks
try_:
On Error GoTo catch_:
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "Please open a drawing first.", vbCritical, "ERROR"
End
End If
If swModel.GetType() = swDocDRAWING Then
Set swDraw = swModel
SetTangentEdge swDraw
GoTo finally_
Else
MsgBox "Macro only works on drawing.", vbCritical, "ERROR"
Set swModel = Nothing
End
End If
catch_:
swApp.SendMsgToUser2 Err.Description, swMessageBoxIcon_e.swMbStop, swMessageBoxBtn_e.swMbOk
finally_:
Set swModel = Nothing
End Sub
Sub SetTangentEdge(draw As SldWorks.DrawingDoc)
vSheets = draw.GetViews
For i = 0 To UBound(vSheets)
vViews = vSheets(i)
For j = 0 To UBound(vViews)
Set swView = vViews(j)
'Display tangent setting:
'swTangentEdgesHidden
'swTangentEdgesVisible
'swTangentEdgesVisibleAndFonted
swView.SetDisplayTangentEdges2 swTangentEdgesVisibleAndFonted
'SetDisplayMode3(UseParent, Mode, Facetted, Edges)
'facetted set to false to use precise (HLR)
bRet = swView.SetDisplayMode3(swView.GetUseParentDisplayMode, swView.GetDisplayMode2, False, swView.GetDisplayEdgesInShadedMode)
Next
Next
End Sub
Far too many items in the world are designed, constructed and foisted upon us with no understanding-or even care-for how we will use them.
Re: Macro for tangent edges and high quality views
It works just perfect!.
Thank you very much.
Thank you very much.
Re: Macro for tangent edges and high quality views
Well done! It worked perfectly here too. Thank you!
Re: Macro for tangent edges and high quality views
Any chance there is a way to set this to exclude any ISOMETRIC Views?
Re: Macro for tangent edges and high quality views
this depends on HOW the isoview is created...
As far as i know, solidworks does not differentiate whether the view is iso/trimetric/dimetric/etc. It could only identify whether it is named view or projected view...
However,
If the is created as a "standalone view" (Model view → Select Isometric and place view), the iso view is a named view and uses true dimension by default. So you should be able to use a standard IF condition to determine whether it is a stanalone iso view and exclude it. However, this does not work if the isoview is created by projecting off a standard view
https://help.solidworks.com/2012/englis ... sions.html
https://help.solidworks.com/2012/englis ... pes_e.html
macro snippet example below
Sub SetTangentEdge(draw As SldWorks.DrawingDoc)
vSheets = draw.GetViews
For i = 0 To UBound(vSheets)
vViews = vSheets(i)
For j = 0 To UBound(vViews)
Set swView = vViews(j)
If swView.Type = swDrawingNamedView And swView.ProjectedDimensions = False Then
'Skip if standalone isoview
Else
'Display tangent setting:
'swTangentEdgesHidden
'swTangentEdgesVisible
'swTangentEdgesVisibleAndFonted
swView.SetDisplayTangentEdges2 swTangentEdgesVisibleAndFonted
'SetDisplayMode3(UseParent, Mode, Facetted, Edges)
'facetted set to false to use precise (HLR)
bRet = swView.SetDisplayMode3(swView.GetUseParentDisplayMode, swView.GetDisplayMode2, False, swView.GetDisplayEdgesInShadedMode)
'swView.SetDisplayTangentEdges2 swTangentEdgesVisibleAndFonted
End If
Next
Next
End Sub
Far too many items in the world are designed, constructed and foisted upon us with no understanding-or even care-for how we will use them.
Re: Macro for tangent edges and high quality views
GetOrientationName method should help in finding the view pre defined name only if it has been created independently.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger