Drawing view scale + SW VBA
Drawing view scale + SW VBA
(OP)
I want to check each drawing view in my drawing on theire scale and make it 1:1 if necesarry.
How ??
This i got:
Dim Mloopdoorfeaturetree As SldWorks.Feature
Dim Mtellerviewport
Dim Msoort, MSubsoort, Msubsoort2, Mschaalview
Set Mloopdoorfeaturetree = swModel.FirstFeature
Mtellerviewport = 0
While Not Mloopdoorfeaturetree Is Nothing
Msoort = Mloopdoorfeaturetree.GetTypeName
If Msoort = "DrSheet" Then
Set MSubsoort = pdoorfeaturetree.GetFirstSubFeature
While Not MSubsoort Is Nothing
Msubsoort2 = MSubsoort.GetTypeName
If Msubsoort2 = "AbsoluteView" Then
Set SelMgr = swModel.SelectionManager
boolstatus = swModel.ActivateView(Msubsoort2)
boolstatus = swModel.Extension.SelectByID2(Msubsoort2, "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
Mtellerviewport = Mtellerviewport + 1
End If
Set MSubsoort = MSubsoort.GetNextSubFeature
Wend
MsgBox Mtellerviewport & " viewports in de tekening."
End If
Set Mloopdoorfeaturetree = Mloopdoorfeaturetree.GetNextFeature
Wend
so i count the numbers of viewports in my drawing, but how can i check theire scale ?
How ??
This i got:
Dim Mloopdoorfeaturetree As SldWorks.Feature
Dim Mtellerviewport
Dim Msoort, MSubsoort, Msubsoort2, Mschaalview
Set Mloopdoorfeaturetree = swModel.FirstFeature
Mtellerviewport = 0
While Not Mloopdoorfeaturetree Is Nothing
Msoort = Mloopdoorfeaturetree.GetTypeName
If Msoort = "DrSheet" Then
Set MSubsoort = pdoorfeaturetree.GetFirstSubFeature
While Not MSubsoort Is Nothing
Msubsoort2 = MSubsoort.GetTypeName
If Msubsoort2 = "AbsoluteView" Then
Set SelMgr = swModel.SelectionManager
boolstatus = swModel.ActivateView(Msubsoort2)
boolstatus = swModel.Extension.SelectByID2(Msubsoort2, "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
Mtellerviewport = Mtellerviewport + 1
End If
Set MSubsoort = MSubsoort.GetNextSubFeature
Wend
MsgBox Mtellerviewport & " viewports in de tekening."
End If
Set Mloopdoorfeaturetree = Mloopdoorfeaturetree.GetNextFeature
Wend
so i count the numbers of viewports in my drawing, but how can i check theire scale ?






RE: Drawing view scale + SW VBA
http:/
Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
sw.fcsuper.com
Co-moderator of Solidworks Yahoo! Group
RE: Drawing view scale + SW VBA
It will add the View Scale note to any pre-selected view(s). There is a better description of it (called Label View Scale) at:
http://sw
To avoid having to select the views yourself, use the below macro that will automatically to select each view, and then the macro will make a sub-call to the downloaded macro above...
I got most of this straight from the SW API Help, the rest from the macro recorder:
CODE
'Get Drawing View Names and Types Example (VB)
'This example shows how to the names and types of all of the drawing views on the current sheet.
'---------------------------------------
'
' Preconditions: Drawing document is open.
'
' Postconditions: None
'
'---------------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim swView As SldWorks.View
Dim bRet As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
'First selection is always the sheet.
Set swView = swDraw.GetFirstView
Debug.Print "File = " & swModel.GetPathName
Debug.Print " " & swSheet.GetName
'Get the first view.
Set swView = swView.GetNextView
While (Not (swView Is Nothing))
Debug.Print " " & swView.GetName2 & " [" & swView.Type & "]"
'***START: Added Code to select view and call other macro***
If (InStr(swView.GetName2, "*") = 0) Then
'Select View
swModel.ClearSelection2 True
bRet = swModel.ActivateView(swView.GetName2)
bRet = swModel.Extension.SelectByID2(swView.GetName2, "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
'Call other macro
swApp.RunMacro ("C:\Program Files\SolidWorks\macros\AddViewScale.swp"), "AddViewScale1", "main"
End If
'***END: Added Code to select view and call other macro***
Set swView = swView.GetNextView
Wend
End Sub
Later,
Ken
RE: Drawing view scale + SW VBA
Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
sw.fcsuper.com
Co-moderator of Solidworks Yahoo! Group
RE: Drawing view scale + SW VBA
View, scale
View, ScaleDecimal
View, ScaleRatio
There are sample macros with each topic. You can still use the above code to iterate thru the views. What 33456 shows would actually iterate thru features in the feature tree...which may not be very efficient depending on model size/complexity.
Ken
RE: Drawing view scale + SW VBA
Check out my macro and fill in te code for getting the scale end set it to 1:1
http