Hello:
I want to zoom to a window using predefined coordinates on a Drawing. A assume Z is 0.
As an example, for an A-size drawing I want to zoom from 0,0 to 10,7.5
I have this code, but every example I have viewed is about getting the coordinate values from the pick point. I do not want to pick a point.
Private Sub ZoomToRegion(_MatchDrawingFile As String, _Drawing As DrawingDoc, _swModel As ModelDoc2)
' Get Drawing Size
Dim adFile As IEdmFile7 = VAULT.GetFileFromPath(_MatchDrawingFile)
Dim PaperSize As String = Nothing
PaperSize = ReadPaperSize(adFile, _MatchDrawingFile)
Dim swSelMgr As SelectionMgr = _swModel.SelectionManager
Dim swMathUtil As MathUtility = SWAPP.GetMathUtility
Dim oSelPt1, oSelPt2 As Object
Dim swSelPt1, swSelPt2 As MathPoint
swSelPt1.ArrayData(0) = 0.00
swSelPt1.ArrayData(1) = 0.00
swSelPt1.ArrayData(2) = 0.00
swSelPt2.ArrayData(2) = 0.00
Select Case PaperSize
Case "A"
swSelPt2.ArrayData(0) = 0.254 ' 10"
swSelPt2.ArrayData(1) = 0.1905 ' 7.5"
Case "B"
swSelPt2.ArrayData(0) = 0.4064 ' 16"
swSelPt2.ArrayData(1) = 0.254 ' 10"
Case "C"
swSelPt2.ArrayData(0) = 0.5842 ' 23"
swSelPt2.ArrayData(1) = 0.4318 ' 17"
Case "D"
swSelPt2.ArrayData(0) = 0.889 ' 35"
swSelPt2.ArrayData(1) = 0.5842 ' 23"
End Select
_swModel.ViewZoomTo2(swSelPt1.ArrayData(0), swSelPt1.ArrayData(1), swSelPt1.ArrayData(2), swSelPt2.ArrayData(0), swSelPt2.ArrayData(1), swSelPt2.ArrayData(2))
End Sub
Interesting...
Does any of this code work? What language is it? Looks like VBA, but VBA variable names must start with a letter and cannot start with an underscore.
You got a lot of crap in in there that you don't need.
Looks like you're trying to get paper size from PDM for some reason. Can't help you with that.
Size is hard-coded below:
Private Sub ZoomToRegion()
' Get Drawing Size. You're gonna have to figure this one out.
'Dim adFile As IEdmFile7 = VAULT.GetFileFromPath(_MatchDrawingFile)
Dim PaperSize As String
'PaperSize = ReadPaperSize(adFile, _MatchDrawingFile)
PaperSize = "C"
Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
x1 = 0
y1 = 0
Select Case PaperSize
Case "A"
x2 = 0.254 ' 10"
y2 = 0.1905 ' 7.5"
Case "B"
x2 = 0.4064 ' 16"
y2 = 0.254 ' 10"
Case "C"
x2 = 0.5842 ' 23"
y2 = 0.4318 ' 17"
Case Else
x2 = 0.889 ' 35"
y2 = 0.5842 ' 23"
End Select
Application.SldWorks.ActiveDoc.ViewZoomTo2 x1, y1, 0, x2, y2, 0
End Sub