Files
Difference between IView::GetXform and IView::GetViewXform
Code
'This macro demonstrates the difference between IView::GetXform and _
IView::GetViewXform
'Precondition: Drawing with a single drawing view is open
'Postcondition: See immediate window
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim vTransform As Variant
Dim i As Integer
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swView = swDraw.GetFirstView
Set swView = swView.GetNextView
'Location of drw view center relative to sheet origin
vTransform = swView.GetXform
Debug.Print "IView::GetXform"
For i = 0 To UBound(vTransform)
Debug.Print Round(vTransform(i), 6)
Next i
'Transform from model space origin to drawing space origin
'In other words, get the model origin location w.r.t. the drawing origin
vTransform = swView.GetViewXform
Debug.Print "IView::GetViewXform"
For i = 0 To UBound(vTransform)
Debug.Print Round(vTransform(i), 6)
Next i
End Sub
'Notes: IView::GetXform returns an array of three doubles. The first two values _
are X and Y location, and the third value is the scale.
'IView::GetViewXform returns an array of 13 doubles:
' [0-8] is a 3x3 of the view rotation
' [9-11] is a 1x3 of translation (9 = x, 10 = y)
' [12] is the scaling of the transformation