Page 1 of 1

Macro for tangent edges and high quality views

Posted: Mon Oct 24, 2022 4:30 pm
by nuevahola
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

Re: Macro for tangent edges and high quality views

Posted: Mon Oct 24, 2022 7:34 pm
by zwei
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

Posted: Tue Oct 25, 2022 4:48 am
by nuevahola
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

Posted: Tue Oct 25, 2022 7:41 am
by zwei
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
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

Re: Macro for tangent edges and high quality views

Posted: Tue Oct 25, 2022 8:37 am
by nuevahola
It works just perfect!.

Thank you very much.

Re: Macro for tangent edges and high quality views

Posted: Fri Dec 02, 2022 9:50 am
by Cimthog
Well done! It worked perfectly here too. Thank you!

Re: Macro for tangent edges and high quality views

Posted: Wed May 03, 2023 1:36 pm
by sooz
Any chance there is a way to set this to exclude any ISOMETRIC Views?

Re: Macro for tangent edges and high quality views

Posted: Wed May 03, 2023 6:34 pm
by zwei
sooz wrote: Wed May 03, 2023 1:36 pm Any chance there is a way to set this to exclude any ISOMETRIC 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

Re: Macro for tangent edges and high quality views

Posted: Thu May 04, 2023 2:07 am
by gupta9665
GetOrientationName method should help in finding the view pre defined name only if it has been created independently.