Zooming

Zooming

Anonymous
Not applicable
611 Views
15 Replies
Message 1 of 16

Zooming

Anonymous
Not applicable
I want to save the current view in the active viewport, prompt for some
picks (allowing the user to zoom/pan at will), then reset the active
viewport to the saved view. When I coded this, restoring the view forced a
regen. I don't want that.

Is there a way to save the current zoom scale and reset it when I am
finished? I know there is a zoom scale but I'm not sure which Acad variable
holds this current value. Any help would be appreciated.

Keith
0 Likes
612 Views
15 Replies
Replies (15)
Message 2 of 16

Anonymous
Not applicable
Check the Viewport object's CustomScale property.
--
John Goodfellow
irtf'nm
use 'microtouch' in address to email

"Keith" wrote in message
news:FD809212B3CE44847E95D38BE7291DB2@in.WebX.maYIadrTaRb...
> I want to save the current view in the active viewport, prompt for some
> picks (allowing the user to zoom/pan at will), then reset the active
> viewport to the saved view. When I coded this, restoring the view forced
a
> regen. I don't want that.
>
> Is there a way to save the current zoom scale and reset it when I am
> finished? I know there is a zoom scale but I'm not sure which Acad
variable
> holds this current value. Any help would be appreciated.
>
> Keith
>
>
0 Likes
Message 3 of 16

Anonymous
Not applicable
When trying:

Dim CurrentZoomScale As Variant
CurrentZoomScale = ThisDrawing.ActiveViewport.CustomScale
MsgBox CurrentZoomScale

I get the "Object doesn't support this property or method" error. Where can
I find this property?

Thanks,
Keith

John Goodfellow wrote in message
news:63BF1CAFDB0C2488D34FD0ACFC1F16AC@in.WebX.maYIadrTaRb...
> Check the Viewport object's CustomScale property.
> --
> John Goodfellow
> irtf'nm
> use 'microtouch' in address to email
>
> "Keith" wrote in message
> news:FD809212B3CE44847E95D38BE7291DB2@in.WebX.maYIadrTaRb...
> > I want to save the current view in the active viewport, prompt for some
> > picks (allowing the user to zoom/pan at will), then reset the active
> > viewport to the saved view. When I coded this, restoring the view
forced
> a
> > regen. I don't want that.
> >
> > Is there a way to save the current zoom scale and reset it when I am
> > finished? I know there is a zoom scale but I'm not sure which Acad
> variable
> > holds this current value. Any help would be appreciated.
> >
> > Keith
> >
> >
>
0 Likes
Message 4 of 16

Anonymous
Not applicable
Well, that was a guess. CustomScale is a property of the PViewport object
only. It may not be what you are looking for. I use it to read the scale
of a PViewport so I can adjust dimension line seperation distances back in
modelspace. Maybe you could work around the problem with the REGENAUTO
setting and the REGENMODE system variable?
--
John Goodfellow
irtf'nm
use 'microtouch' in address to email

"Keith" wrote in message
news:DA0CAD38F3978C282A7BAA6237D99740@in.WebX.maYIadrTaRb...
> When trying:
>
> Dim CurrentZoomScale As Variant
> CurrentZoomScale = ThisDrawing.ActiveViewport.CustomScale
> MsgBox CurrentZoomScale
>
> I get the "Object doesn't support this property or method" error. Where
can
> I find this property?
>
> Thanks,
> Keith
>
> John Goodfellow wrote in message
> news:63BF1CAFDB0C2488D34FD0ACFC1F16AC@in.WebX.maYIadrTaRb...
> > Check the Viewport object's CustomScale property.
> > --
> > John Goodfellow
> > irtf'nm
> > use 'microtouch' in address to email
> >
> > "Keith" wrote in message
> > news:FD809212B3CE44847E95D38BE7291DB2@in.WebX.maYIadrTaRb...
> > > I want to save the current view in the active viewport, prompt for
some
> > > picks (allowing the user to zoom/pan at will), then reset the active
> > > viewport to the saved view. When I coded this, restoring the view
> forced
> > a
> > > regen. I don't want that.
> > >
> > > Is there a way to save the current zoom scale and reset it when I am
> > > finished? I know there is a zoom scale but I'm not sure which Acad
> > variable
> > > holds this current value. Any help would be appreciated.
> > >
> > > Keith
> > >
> > >
> >
>
>
0 Likes
Message 5 of 16

Anonymous
Not applicable
Well, thanks for the guess. Anyone else?

Turning the regenauto off still resulted in a regen when restoring the view.
Thanks anyways.

Surely the zoom previous gets its scale factor from somewhere.?.?.?

Keith

John Goodfellow wrote in message
news:721C0284ACB4A5549CF56B1F502A8E6E@in.WebX.maYIadrTaRb...
> Well, that was a guess. CustomScale is a property of the PViewport object
> only. It may not be what you are looking for. I use it to read the scale
> of a PViewport so I can adjust dimension line seperation distances back in
> modelspace. Maybe you could work around the problem with the REGENAUTO
> setting and the REGENMODE system variable?
> --
> John Goodfellow
> irtf'nm
> use 'microtouch' in address to email
>
> "Keith" wrote in message
> news:DA0CAD38F3978C282A7BAA6237D99740@in.WebX.maYIadrTaRb...
> > When trying:
> >
> > Dim CurrentZoomScale As Variant
> > CurrentZoomScale = ThisDrawing.ActiveViewport.CustomScale
> > MsgBox CurrentZoomScale
> >
> > I get the "Object doesn't support this property or method" error. Where
> can
> > I find this property?
> >
> > Thanks,
> > Keith
> >
> > John Goodfellow wrote in message
> > news:63BF1CAFDB0C2488D34FD0ACFC1F16AC@in.WebX.maYIadrTaRb...
> > > Check the Viewport object's CustomScale property.
> > > --
> > > John Goodfellow
> > > irtf'nm
> > > use 'microtouch' in address to email
> > >
> > > "Keith" wrote in message
> > > news:FD809212B3CE44847E95D38BE7291DB2@in.WebX.maYIadrTaRb...
> > > > I want to save the current view in the active viewport, prompt for
> some
> > > > picks (allowing the user to zoom/pan at will), then reset the active
> > > > viewport to the saved view. When I coded this, restoring the view
> > forced
> > > a
> > > > regen. I don't want that.
> > > >
> > > > Is there a way to save the current zoom scale and reset it when I am
> > > > finished? I know there is a zoom scale but I'm not sure which Acad
> > > variable
> > > > holds this current value. Any help would be appreciated.
> > > >
> > > > Keith
> > > >
> > > >
> > >
> >
> >
>
0 Likes
Message 6 of 16

Anonymous
Not applicable
Got this reply going through tech support (after 5 days):

>Thank you for contacting the Developer Consulting Group.

>I am sorry to say that the regeneration cannot be avoided while using the
activex methods. As a workaround you might look at using >the 'SendCommand'
method as follows:
>ThisDrawing.SendCommand "-view r viewname" & vbCr



Keith wrote in message
news:1625DCDBFD92A672E8794D05CDF8F02A@in.WebX.maYIadrTaRb...
> Well, thanks for the guess. Anyone else?
>
> Turning the regenauto off still resulted in a regen when restoring the
view.
> Thanks anyways.
>
> Surely the zoom previous gets its scale factor from somewhere.?.?.?
>
> Keith
>
> John Goodfellow wrote in message
> news:721C0284ACB4A5549CF56B1F502A8E6E@in.WebX.maYIadrTaRb...
> > Well, that was a guess. CustomScale is a property of the PViewport
object
> > only. It may not be what you are looking for. I use it to read the
scale
> > of a PViewport so I can adjust dimension line seperation distances back
in
> > modelspace. Maybe you could work around the problem with the REGENAUTO
> > setting and the REGENMODE system variable?
> > --
> > John Goodfellow
> > irtf'nm
> > use 'microtouch' in address to email
> >
> > "Keith" wrote in message
> > news:DA0CAD38F3978C282A7BAA6237D99740@in.WebX.maYIadrTaRb...
> > > When trying:
> > >
> > > Dim CurrentZoomScale As Variant
> > > CurrentZoomScale = ThisDrawing.ActiveViewport.CustomScale
> > > MsgBox CurrentZoomScale
> > >
> > > I get the "Object doesn't support this property or method" error.
Where
> > can
> > > I find this property?
> > >
> > > Thanks,
> > > Keith
> > >
> > > John Goodfellow wrote in message
> > > news:63BF1CAFDB0C2488D34FD0ACFC1F16AC@in.WebX.maYIadrTaRb...
> > > > Check the Viewport object's CustomScale property.
> > > > --
> > > > John Goodfellow
> > > > irtf'nm
> > > > use 'microtouch' in address to email
> > > >
> > > > "Keith" wrote in message
> > > > news:FD809212B3CE44847E95D38BE7291DB2@in.WebX.maYIadrTaRb...
> > > > > I want to save the current view in the active viewport, prompt for
> > some
> > > > > picks (allowing the user to zoom/pan at will), then reset the
active
> > > > > viewport to the saved view. When I coded this, restoring the view
> > > forced
> > > > a
> > > > > regen. I don't want that.
> > > > >
> > > > > Is there a way to save the current zoom scale and reset it when I
am
> > > > > finished? I know there is a zoom scale but I'm not sure which
Acad
> > > > variable
> > > > > holds this current value. Any help would be appreciated.
> > > > >
> > > > > Keith
> > > > >
> > > > >
> > > >
> > >
> > >
> >
>
>
0 Likes
Message 7 of 16

Anonymous
Not applicable
Now, I'm simply trying to determine which viewport is current so I can save
the correct variables to restore the view when my routine is finished. This
routine, when run with 3 viewports displayed, gives me the same result no
matter which viewport is active. I need help.

Sub whichviewport()
Dim vwprt As AcadViewport
Set vwprt = ThisDrawing.ActiveViewport
MsgBox "name: " & vwprt.Name & vbCr & "direction: x" &
vwprt.Direction(0) & " y" & vwprt.Direction(1) & " z" & vwprt.Direction(2)
& vbCr & "lower left: x" & vwprt.LowerLeftCorner(0) & " y" &
vwprt.LowerLeftCorner(0) & vbCr & "upper right: x" &
vwprt.UpperRightCorner(0) & " y" & vwprt.UpperRightCorner(1) & vbCr &
"viewport center: x" & vwprt.center(0) & " y" & vwprt.center(1)
End Sub

Keith wrote in message
news:FD809212B3CE44847E95D38BE7291DB2@in.WebX.maYIadrTaRb...
> I want to save the current view in the active viewport, prompt for some
> picks (allowing the user to zoom/pan at will), then reset the active
> viewport to the saved view. When I coded this, restoring the view forced
a
> regen. I don't want that.
>
> Is there a way to save the current zoom scale and reset it when I am
> finished? I know there is a zoom scale but I'm not sure which Acad
variable
> holds this current value. Any help would be appreciated.
>
> Keith
>
>
0 Likes
Message 8 of 16

Anonymous
Not applicable
Keith, I've been watching this thread for a while as it was along the same
lines as something that I have been trying to do with lisp. If you don't
want to actually save a view, then restore it, check out the thread
"Viewport Tools!" on 5/29/01 in nntp://autocesk.autocad.customization .
Specifically look at the functions (getViewData) and (putView). You'll
still have to use SendCommand, because it's a lisp routine, but at least you
won't have to actually save a view.
--
Bobby C. Jones

"Keith" wrote in message
news:3A5BF385FE5422BDB5C602A286733D05@in.WebX.maYIadrTaRb...
> Got this reply going through tech support (after 5 days):
>
> >Thank you for contacting the Developer Consulting Group.
>
> >I am sorry to say that the regeneration cannot be avoided while using the
> activex methods. As a workaround you might look at using >the
'SendCommand'
> method as follows:
> >ThisDrawing.SendCommand "-view r viewname" & vbCr
0 Likes
Message 9 of 16

Anonymous
Not applicable
that's nntp://autodesk.autocad.customization
--
Bobby C. Jones
0 Likes
Message 10 of 16

Anonymous
Not applicable
Thanks, Bobby

Those routines are not very long so I copied them here. Since that code is
Lisp, I don't understand it. Can this code be converted to VBA? It looks
like you extract the DXF group code values and use them. Is that correct?
Where do you determine the current viewport?

;;;Arguments - ActiveX Viewport object
;;;Retval - A list of data suitable to pass to
;;;the (setview) function
(defun getViewData (vlaObj / entlst)
(setq entlst (entget (vlax-vla-object->ename vlaObj)))
(mapcar '(lambda (x y) (cons x (cdr (assoc y entlst))))
'(40 10 11 12 42 43 44 50 110 111 112 79 146)
'(45 12 16 17 42 43 44 51 110 111 112 79 146)
) ;_ end of mapcar
) ;_ end of defun

;;;Arguments - ActiveX Viewport object;
;;;'view' data list as returned by (getViewData) or
;;;(tblsearch "view" viewName)
(defun putView (vlaObj viewData)
(setview viewData
(cdr (assoc 69 (entget (vlax-vla-object->ename vlaObj))))
) ;_ end of setview
) ;_ end of defun

Bobby Jones wrote in message
news:AC6EC3CBDCD376955B8FC3D4FC9D54DA@in.WebX.maYIadrTaRb...
> Keith, I've been watching this thread for a while as it was along the same
> lines as something that I have been trying to do with lisp. If you don't
> want to actually save a view, then restore it, check out the thread
> "Viewport Tools!" on 5/29/01 in nntp://autocesk.autocad.customization .
> Specifically look at the functions (getViewData) and (putView). You'll
> still have to use SendCommand, because it's a lisp routine, but at least
you
> won't have to actually save a view.
> --
> Bobby C. Jones
>
> "Keith" wrote in message
> news:3A5BF385FE5422BDB5C602A286733D05@in.WebX.maYIadrTaRb...
> > Got this reply going through tech support (after 5 days):
> >
> > >Thank you for contacting the Developer Consulting Group.
> >
> > >I am sorry to say that the regeneration cannot be avoided while using
the
> > activex methods. As a workaround you might look at using >the
> 'SendCommand'
> > method as follows:
> > >ThisDrawing.SendCommand "-view r viewname" & vbCr
>
>
>
0 Likes
Message 11 of 16

Anonymous
Not applicable
Keith, My understanding of sharing info between VBA and lisp is limited, so
maybe someone could help us with that part, but I'll break down exactly
what's going on in these routines. First of all these routines are
utilities and therefore they do not retrieve the viewport objects
themselves, they are passed from another function. The first line of
getViewData:

(defun getViewData (vlaObj / entlst)
defines the 'procedure' getViewData and sets the variable vlaObj, local to
the procedure, as an argument that will be passed to the procedure and sets
the scope of the variable entlst as local to the procedure. The procedure
expects a valid psViewport object to be passed to it and it will be assigned
to the vlaObj variable.

The next line converts the viewport object into an entity name that lisp
functions will understand, gets the DXF association list from the entity,
and assigns that information to the variable entlst
(setq entlst (entget (vlax-vla-object->ename vlaObj)))

The next function takes the dxf association list of the viewport and
converts it into an association list that matches the association list of a
view entity with the same view as the viewport. It doesn't create the view,
it just gathers the information that the view would contain if it existed.
(mapcar '(lambda (x y) (cons x (cdr (assoc y entlst))))
'(40 10 11 12 42 43 44 50 110 111 112 79 146)
'(45 12 16 17 42 43 44 51 110 111 112 79 146)
) ;_ end of mapcar

All lisp functions, or almost all, return a value. The getViewData function
returns the newly created data list of our imaginary view. The putView
function takes that data and applies it to another psViewport object so that
it changes the view to match. So you would call the putView something like
this:

(putView vpObjectToChangeView viewData)

They work together like so:
(setq viewData (getViewData vpObjectWithDesiredView))
(putView vpObjectToChange viewData)
or simply
(putView vpObjectToChange (getViewData vpObjectWithDesiredView))

Now what I don't know is how easy it is to pass viewport objects stored in
VBA variables to lisp functions. I'm not a VBA programmer, but I lurk in
this group because I do access the ActiveX object model via lisp and a lot
of what is discussed here in this NG applies to me also. I'm willing to bet
that someone knows how to make this work. Good luck
--
Bobby C. Jones

"Keith" wrote in message
news:73A289740F2720A433CB5DEC1F10D7D5@in.WebX.maYIadrTaRb...
> Thanks, Bobby
>
> Those routines are not very long so I copied them here. Since that code
is
> Lisp, I don't understand it. Can this code be converted to VBA? It looks
> like you extract the DXF group code values and use them. Is that correct?
> Where do you determine the current viewport?
>
> ;;;Arguments - ActiveX Viewport object
> ;;;Retval - A list of data suitable to pass to
> ;;;the (setview) function
> (defun getViewData (vlaObj / entlst)
> (setq entlst (entget (vlax-vla-object->ename vlaObj)))
> (mapcar '(lambda (x y) (cons x (cdr (assoc y entlst))))
> '(40 10 11 12 42 43 44 50 110 111 112 79 146)
> '(45 12 16 17 42 43 44 51 110 111 112 79 146)
> ) ;_ end of mapcar
> ) ;_ end of defun
>
> ;;;Arguments - ActiveX Viewport object;
> ;;;'view' data list as returned by (getViewData) or
> ;;;(tblsearch "view" viewName)
> (defun putView (vlaObj viewData)
> (setview viewData
> (cdr (assoc 69 (entget (vlax-vla-object->ename vlaObj))))
> ) ;_ end of setview
> ) ;_ end of defun
0 Likes
Message 12 of 16

Anonymous
Not applicable
Your process sounds like what I'm after. I just need to know how to do it
in VBA. The lisp command vports returns a list of values representing the
'location' of each visible viewport window. The first in the list is the
current window:

"The current viewport's descriptor is always first in the list. In the
previous example, viewport number 5 is the current viewport."

Does anyone know how to get these 'descriptors' in VBA?



Bobby Jones wrote in message
news:7CE0006E16B9116392FC627C2B62EF74@in.WebX.maYIadrTaRb...
> Keith, My understanding of sharing info between VBA and lisp is limited,
so
> maybe someone could help us with that part, but I'll break down exactly
> what's going on in these routines. First of all these routines are
> utilities and therefore they do not retrieve the viewport objects
> themselves, they are passed from another function. The first line of
> getViewData:
>
> (defun getViewData (vlaObj / entlst)
> defines the 'procedure' getViewData and sets the variable vlaObj, local to
> the procedure, as an argument that will be passed to the procedure and
sets
> the scope of the variable entlst as local to the procedure. The procedure
> expects a valid psViewport object to be passed to it and it will be
assigned
> to the vlaObj variable.
>
> The next line converts the viewport object into an entity name that lisp
> functions will understand, gets the DXF association list from the entity,
> and assigns that information to the variable entlst
> (setq entlst (entget (vlax-vla-object->ename vlaObj)))
>
> The next function takes the dxf association list of the viewport and
> converts it into an association list that matches the association list of
a
> view entity with the same view as the viewport. It doesn't create the
view,
> it just gathers the information that the view would contain if it existed.
> (mapcar '(lambda (x y) (cons x (cdr (assoc y entlst))))
> '(40 10 11 12 42 43 44 50 110 111 112 79 146)
> '(45 12 16 17 42 43 44 51 110 111 112 79 146)
> ) ;_ end of mapcar
>
> All lisp functions, or almost all, return a value. The getViewData
function
> returns the newly created data list of our imaginary view. The putView
> function takes that data and applies it to another psViewport object so
that
> it changes the view to match. So you would call the putView something
like
> this:
>
> (putView vpObjectToChangeView viewData)
>
> They work together like so:
> (setq viewData (getViewData vpObjectWithDesiredView))
> (putView vpObjectToChange viewData)
> or simply
> (putView vpObjectToChange (getViewData vpObjectWithDesiredView))
>
> Now what I don't know is how easy it is to pass viewport objects stored in
> VBA variables to lisp functions. I'm not a VBA programmer, but I lurk in
> this group because I do access the ActiveX object model via lisp and a lot
> of what is discussed here in this NG applies to me also. I'm willing to
bet
> that someone knows how to make this work. Good luck
> --
> Bobby C. Jones
>
> "Keith" wrote in message
> news:73A289740F2720A433CB5DEC1F10D7D5@in.WebX.maYIadrTaRb...
> > Thanks, Bobby
> >
> > Those routines are not very long so I copied them here. Since that code
> is
> > Lisp, I don't understand it. Can this code be converted to VBA? It
looks
> > like you extract the DXF group code values and use them. Is that
correct?
> > Where do you determine the current viewport?
> >
> > ;;;Arguments - ActiveX Viewport object
> > ;;;Retval - A list of data suitable to pass to
> > ;;;the (setview) function
> > (defun getViewData (vlaObj / entlst)
> > (setq entlst (entget (vlax-vla-object->ename vlaObj)))
> > (mapcar '(lambda (x y) (cons x (cdr (assoc y entlst))))
> > '(40 10 11 12 42 43 44 50 110 111 112 79 146)
> > '(45 12 16 17 42 43 44 51 110 111 112 79 146)
> > ) ;_ end of mapcar
> > ) ;_ end of defun
> >
> > ;;;Arguments - ActiveX Viewport object;
> > ;;;'view' data list as returned by (getViewData) or
> > ;;;(tblsearch "view" viewName)
> > (defun putView (vlaObj viewData)
> > (setview viewData
> > (cdr (assoc 69 (entget (vlax-vla-object->ename vlaObj))))
> > ) ;_ end of setview
> > ) ;_ end of defun
>
>
0 Likes
Message 13 of 16

Anonymous
Not applicable
Not sure this helps but a viewport has LowerLeftCorner and UpperRightCorner
properties in the form of 2D coords. Can those be used to do what you want
to do?

- Tom

"Keith" wrote in message
news:0525426CC46EACDE978853D4FD84B946@in.WebX.maYIadrTaRb...
> Your process sounds like what I'm after. I just need to know how to do it
> in VBA. The lisp command vports returns a list of values representing the
> 'location' of each visible viewport window. The first in the list is the
> current window:
>
> "The current viewport's descriptor is always first in the list. In the
> previous example, viewport number 5 is the current viewport."
>
> Does anyone know how to get these 'descriptors' in VBA?
> >
>
>
0 Likes
Message 14 of 16

Anonymous
Not applicable

"> Does anyone know how to get these 'descriptors' in VBA?


The current viewport id number is stored in the cvport sysvar. If you are
working 'in' the viewport, panning and zooming and picking like you stated,
then simply grab the cvport value.
--
Bobby C. Jones
0 Likes
Message 15 of 16

Anonymous
Not applicable
Thanks, I knew those were available. I didn't know the sys var CVPORT was!


Tom Gilmer wrote in message
news:948C7D9721DBD3D3B6369A6AB09A6819@in.WebX.maYIadrTaRb...
> Not sure this helps but a viewport has LowerLeftCorner and
UpperRightCorner
> properties in the form of 2D coords. Can those be used to do what you want
> to do?
>
> - Tom
>
> "Keith" wrote in message
> news:0525426CC46EACDE978853D4FD84B946@in.WebX.maYIadrTaRb...
> > Your process sounds like what I'm after. I just need to know how to do
it
> > in VBA. The lisp command vports returns a list of values representing
the
> > 'location' of each visible viewport window. The first in the list is
the
> > current window:
> >
> > "The current viewport's descriptor is always first in the list. In the
> > previous example, viewport number 5 is the current viewport."
> >
> > Does anyone know how to get these 'descriptors' in VBA?
> > >
> >
> >
>
>
0 Likes
Message 16 of 16

Anonymous
Not applicable
Thanks, Bobby. Didn't know about that one.


Bobby Jones wrote in message
news:B1E5D5C5617FD8E916BA914FCCEF730E@in.WebX.maYIadrTaRb...
>
> "> Does anyone know how to get these 'descriptors' in VBA?
>
>
> The current viewport id number is stored in the cvport sysvar. If you are
> working 'in' the viewport, panning and zooming and picking like you
stated,
> then simply grab the cvport value.
> --
> Bobby C. Jones
>
>
>
0 Likes