TheSwamp
Code Red => VB(A) => Topic started by: Tyke on February 15, 2010, 03:41:28 AM
-
Hi,
I have a drawing with two viewports in Model space.
In one of the viewports the user zooms onto an object using any of the normal zoom functions.
How can I, in VBA, get the final scale factor the user zoomed in to and then apply it to the second viewport so that the two viewports have the same zoom factor.
The second part would appear to be solved with:
ZoomScaled Zoomfactor, acZoomScaledRelative
but I can't seem to get the scale factor.
Does anyone have any ideas?
-
you will have to get the viewport scale factor for the current VP. Let me see if I have code for that.
-
I can't find any properties that would seem to hold the viewport scale.
I've tried using the height property but that doesn't work either.
-
I can't find any properties that would seem to hold the viewport scale.
I've tried using the height property but that doesn't work either.
I don't use this language, but must be a way to find the properties or methods exposed, not even a help file?.
The Viewport class -have a CustomScale property - read/write
-
OK guys we have a partial solution. It copies the view in one viewport to the other, with the same view scale.
One quirk it still has is that the views in both viewports jump a quarter of the screen width to the left.
Sub CopyViewPort()
Dim objViewPort As AcadViewport
Dim objCurrentViewport As AcadViewport
Dim vpCentre(0 To 1) As Double
Dim dblViewSize As Double
Dim dblCVPHeight As Double
Dim dblCVPWidth As Double
Dim dblCVPScale As Double
Set objCurrentViewport = ThisDrawing.ActiveViewport
Set objViewPort = ThisDrawing.ActiveViewport
' get centre of current viewport
vpCentre(0) = ThisDrawing.GetVariable("ViewCtr")(0)
vpCentre(1) = ThisDrawing.GetVariable("ViewCtr")(1)
'get current vp scale
dblCVPHeight = objCurrentViewport.Height
dblCVPWidth = objCurrentViewport.Width
dblCVPScale = dblCVPWidth / dblCVPHeight
' get sysvar ViewSize
dblViewSize = ThisDrawing.GetVariable("ViewSize")
For Each objViewPort In ThisDrawing.Viewports
ThisDrawing.ActiveViewport = objViewPort
objViewPort.Center = vpCentre
objViewPort.Height = dblViewSize
objViewPort.Width = dblViewSize * dblCVPScale
Next
ThisDrawing.ActiveViewport = objCurrentViewport
' regen in all viewports
ThisDrawing.Regen acAllViewports
End Sub
Thanks for all of your help and I hope someone can make use of it.
-
Try setting the centre after messing w/ the ht and width
-
@ Bryco
That did it. Great, now it works super.
Thanks Bryco for your help and all the others too.