PDA

View Full Version : Getting viewport scale using a lisp routine.



WBIRT
2004-06-29, 12:05 AM
I have been trying to figure out how to get the viewport scale of a viewport so that I can use the scale in other functions. Just a note usually only have one viewport per tab.

Thanks for any help I can get.
Warren

mjfarrell
2004-06-29, 12:15 AM
Warren here is an example of similar code:

http://usa.autodesk.com/adsk/servlet/ps/item?siteID=123112&id=2882796&linkID=2475323

WBIRT
2004-06-30, 12:27 AM
Thank you very much, have been trying to figure that out for a week.

mjfarrell
2004-06-30, 01:33 AM
just to share how about post your finished code
so that others can see the power of sharing ideas?

Ed Jobe
2004-06-30, 02:09 PM
Here's one I wrote a while back (chg the ext to lsp). It returns a value that can be used transparently in other commands. I also have a vba project on the Exchange for setting the vps by dialog.

kieren
2004-06-30, 02:28 PM
Wrote this some time ago (1996).
Feel free to use/modify/hash-up!!!

Full source in ZIP file - not protected.
I originally posted on www.cadalog.com and it had loads of good feedback and downloads.
Type VPTS at command line.

info:
You will be placed in modelspace. Pick a corner of an imaginary box around your detail. Now pick its opposite diagonal corner. Enter scale of detail as it would appear in paperspace. You are now placed in paperspace. Pick your insertion point for your viewport. You now have a viewport to your chosen scale around your detail. A box is also drawn in modelspace around your detail as a guide only. Modelspace and paperspace viewports are in no way connected or joined.

Enjoy! ;)

Tom Beauford
2004-06-30, 08:23 PM
Here's a menu item I used for years before AutoCAD created a control for it:

ID_VP_Scale [Viewport Scale]^C^C^P(if(= 0 (getvar "tilemode"))(progn(princ "PS:MS == 1:")(princ(/ 1 (car (trans '(1 0 0) 2 3 0))))(princ))(progn(prompt "** Command only allowed in Model Space (Floating) **")(princ)))

The only part you really need if you're in a layout (MS or PS) and want the Viewport Scale of the curent viewport (the one the MS command puts the curser in) is:
(car (trans '(1 0 0) 2 3 0))