Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Viewport Scale From Paper Space Only??

14 views
Skip to first unread message

Peter Farrell

unread,
Oct 26, 1999, 3:00:00 AM10/26/99
to
I'm working on a few viewport tools,
Trim Viewport,
Break Viewport,
Scale Viewport,
Resize Viewport,
etc....

Is there anyway to get the scale of the viewport without, toggling
into model space in some form? Trans requires the viewport to be active, the viewctr/viewsize method does as well...

P. Farrell


Eugene N. Kilmer

unread,
Oct 26, 1999, 3:00:00 AM10/26/99
to
Mr. Farrell,

Both R14 and A2K have an Express tool that will give you the scale of a
viewport from either modelspace or paperspace. If you're already inside the
viewport, VPSCALE will automatically spit out the paperspace to modelspace
scale. If not, you will be prompted to select the viewport.

--
Eugene N. Kilmer
Owner/Mag Drafting


Frank Oquendo

unread,
Oct 26, 1999, 3:00:00 AM10/26/99
to
The following snippet shows how to calculate the viewport scale. You'll
probably want to replace the ENTSEL call with a TBLOBJNAME call to automte
the process:

(defun c:vpscale ()
(setq e (car (entsel "\nSelect a viewport: "))
elist (entget e '("ACAD"))
pscale (cdr (assoc 41 elist))
xdata (cdr (nth 0 (cdr (assoc -3 elist))))
c 0
)
(foreach n xdata
(if (= (car n) 1040)
(progn
(setq c (1+ c))
(if (= c 2)
(setq mscale (cdr n))
)
)
)
)
(/ pscale mscale)
)

Peter Farrell <pfar...@bellatlantic.net> wrote in message
news:7v55le$c3...@adesknews2.autodesk.com...

Peter Farrell

unread,
Oct 26, 1999, 3:00:00 AM10/26/99
to
Thanks, I think it was a case of brain freeze...
I didn't even bother to look at the extended data!
My old vpdata routine used a jump back and forth into
the viewport, instead of xdata.

Thanks, all better.

P.Farrell

Tony Tanzillo

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
The current modelspace viewport scale can be found
with this (from Paper or Model space).

(defun xpfact ()
(caddr (trans '(0 0 1) 2 3))
)

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.t...@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/

Frank Oquendo

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
Absolutely correct. The only reason I even came up with the alternative
solution is he stated that requiring the viewport to be active was a problem
for him.

Tony Tanzillo <tony.t...@worldnet.att.net> wrote in message
news:3816FE0E...@worldnet.att.net...

Peter Farrell

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
Carefully worded answer, but not the scale of a viewport from paper space only. This gives the scale of the active model space
viewport
or recently active viewport.

1. Out of curiosity where is this recently active viewport information stored.
2. is there an equally elegant means to acquire the scale of
any viewport you pick *from paperspace only*. Frank's answer
was good, is there a better one?

P. Farrell

Frank Oquendo

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
I think you may have misunderstood Tony's response. It works fine from
paperspace. It simply reports the scale of the active viewport. It would be
simple enough to walk through the available viewports to find the one you're
looking for and set it active prior to calling xpfact.

Peter Farrell <pfar...@bellatlantic.net> wrote in message

news:7v7861$gq...@adesknews2.autodesk.com...

Peter Farrell

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
No I did not misunderstand...

I do not know how to make a viewport active short of toggling to model space, and setting the current viewport, which is not an
acceptable solution
in this case, from *paperspace only* is the key factor here as you noted.

P. Farrell


Jaysen Long

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
I don't know how _elegant_ it is, but here's my version...

(defun c:vpscalefactor ( / epk elist)
(if (eq 1 (getvar "tilemode"))
(prompt "\n** Command not allowed unless TILEMODE is set to 0 **")
(if (eq 1 (getvar "cvport"))
(while (or (setq epk (entsel "\nSelect VIEWPORT: "))
(eq 7 (getvar "errno"))
)
(if (and epk (setq elist (entget (car epk) '("ACAD"))))
(if (eq "VIEWPORT" (cdr (assoc 0 elist)))
(prompt
(strcat
"\nVIEWPORT scale is 1:"
(rtos (/ (cdr (nth 7 (cadr (assoc -3 elist)))) (cdr (assoc
41 elist))))
)
)
(prompt (strcat "\nInvalid selection: " (cdr (assoc 0 elist))))
)
)
)
(prompt (strcat "\nVIEWPORT scale is 1:" (rtos (last (trans '(0 0 1) 3
2)))))
)
)
(princ)
)

Jaysen

Peter Farrell wrote in message <7v7861$gq...@adesknews2.autodesk.com>...
<snip>

Tony Tanzillo

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
That's correct, the viewport must be active.

What precisely is the reason why you can't
switch to MSPACE to make a selected viewport
active?

(PS "not an acceptable solution" is not an
acceptable answer).

--

Peter Farrell

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
Tony Tanzillo <tony.t...@worldnet.att.net> wrote in message news:38175EDF...@worldnet.att.net...

> That's correct, the viewport must be active.
>
> What precisely is the reason why you can't
> switch to MSPACE to make a selected viewport
> active?

In my case, I am reading the Viewport scale as part of a right click
menu, and the MSPACE method causes the viewport to unselect.
Its just a matter of consistency with (noun-verb) commands.
In other words the user expects the entity to remain highlighted, not
to unhighlight, not to flicker, etc. until a command is actually entered.

I ended up using the xdata method to resolve the issue.

P. Farrell

Frank Oquendo

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
Nicely done! Didn't know about that one. Thanks.

Art Cooney <ar...@autodesk.com> wrote in message
news:3817303C...@autodesk.com...
> If you're working with AutoCAD2000, then you can calculate the zoom scale
from the viewport's normal data (i.e. you don't need to
> work with XData):
>
> (defun tst (/ ed)
> (setq ed (entget (car (entsel))))
> (/ (cdr (assoc 41 ed)) (cdr (assoc 45 ed)))
> )
>
> This is possible because in AutoCAD2000, the data is no longer stored as
XData. For compatibility with existing LISP programs,
> when you do an entget and ask for the XData, we use the actual data to
make up the appropriate XData values to be returned by
> entget.


>
> Peter Farrell wrote:
>
> > Carefully worded answer, but not the scale of a viewport from paper
space only. This gives the scale of the active model space
> > viewport
> > or recently active viewport.
> >
> > 1. Out of curiosity where is this recently active viewport information
stored.

> > 2. is there an equally elegant means to acquire the scale of
> > any viewport you pick *from paperspace only*. Frank's answer
> > was good, is there a better one?
> >

> > P. Farrell
>

0 new messages