Mehmet Gultepe wrote:
I tried to make a macro that checks each view on the Sheet Scale or not to eliminate the human error when you are save it as dxf. I know when you save it to dxf it warns you but we still miss that sometimes.
Are you looking for a macro to set scale of each view to sheet scale? This can create issue for views which are created with different scale value like detail views.
no because of the reason you mentioned. We dont use detail view on that sheet but sometimes we use views off the sheet scale. That’s why I want a macro that checks each view equals to sheet scale or not and show that in a mesage box. Like “all views are sheet scaled” or “view 4 is not sheet scaled” or “2 items are not sheet scaled” if there is only one item off the sheet scale you would know and ignore the message.
we use this specific sheet for tooling or cnc programing. When we do the dxf and if we dont notice that it’s not sheet scaled we end up having wrong size tooling or cutting wrong size material. That’s why I want designers and document checkers have less human error and they dont have to go thru each view, save them time with this macro.
So I found swView.UseSheetScale. That helped a lot to figure this out. I also find out that if you use swView.UseSheetScale = True for changing it to sheet scale, it doesn't change detail view scale. This macro worked perfectly. Some views are on the user defined scale but when you change sheet scale it doesn't update those views so this macro detect those views too.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim boolstatus As Boolean
Dim currentSheet As Sheet
Dim swDraw As SldWorks.DrawingDoc
Dim X As Integer
Dim Y As Integer
Dim swScale As Double
Dim bRet As Boolean
Dim vSheetProps As Variant
X = 0
Y = -1
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set currentSheet = swModel.GetCurrentSheet
Set swView = swModel.GetFirstView
Do While Not swView Is Nothing
If Not swView.UseSheetScale = False Then
X = X + 1
Y = Y + 1
Set swView = swView.GetNextView
If X = 0 Then
MsgBox "All views are sheet scaled"
MsgBox ("number of the views are not sheet scaled: " & X)
'MsgBox ("number of the view Y:" & Y)
Here's another macro I made to figure out if views are not on Sheet Scale.
Option Explicit Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swDraw As SldWorks.DrawingDoc Dim strMessage As String Dim dblSheetScale As Double Dim dblScale As Double Sub main() strMessage = "The following views are not on Sheet Scale: " & vbNewLine Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swDraw = swModel If Not swDraw Is Nothing Then SheetScale End If MsgBox strMessage End Sub Function SheetScale() Dim swView As SldWorks.View Dim vViews As Variant Dim i As Integer Dim boolSheetScaleCheck As Boolean vViews = swDraw.GetViews vViews = vViews(0) ' Get Sheet Scale dblSheetScale = vViews(0).ScaleDecimal For i = 0 To UBound(vViews) Set swView = vViews(i) boolSheetScaleCheck = swView.UseSheetScale dblScale = swView.ScaleDecimal ' Check if view is not on Sheet Scale and its Scale not equals to Sheet Scale If boolSheetScaleCheck = False And dblSheetScale <> dblScale Then strMessage = strMessage & vbTab & swView.GetName2 & "." & vbNewLine End If Next i End Function
Attached are two macro that would check all views on active sheet or all sheets and report the views that are not set to use parent scale or sheet scale. The macro would skip the section views and detail views. The macro would create a txt file named "View Scale Info" on the desktop and would add the name of the views which are not set to use sheet scale or parent view scale. The macro would also list the view scale along with their names.