Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
69 Posts
1 Kudo
Registered: ‎07-25-2012
Post 1 of 2

LISP Code to Arrange Model Space In Viewports

318 Views, 1 Replies
09-05-2012 01:09 PM

Over the last few months I've been developing LISP code to automate some assembly drawings. The process is carried out completely without user intervention. And that is the key as we now want to roll it out to some sales people who have little if any training in the use of AutoCAD.

 

Once the drawing is completed in model space we have four different layout tabs, each with a different paper size (A-D) and a different viewport scale. It works really great except that most of the time the users are requesting 11 x 17 size drawings and when the assembly get large, the way it fits in the paper space has to be adjusted.

 

My goal is to find some method of using the center of the three orthograohic views of the assembly (front, top and side views). I pretty sure I can calculate the point of the center of a rectangle that just enclose these three views and then zoom from there, but the trick would be to get the viewport scale set to something that wouldn't be whacko like 1-7/64" = 1'-0". The goal is to stay with 1:8, 1:12, 1:16, 1:20, etc...

 

Any pointers or suggestions would be appreciated.

Mentor
Mentor
184 Posts
31 Kudos
Registered: ‎11-19-2012
Post 2 of 2

Re: LISP Code to Arrange Model Space In Viewports

09-19-2014 05:08 PM in reply to: btillman

Well, you can go inside the mspace vport and do a zoom extent.

Then grab the viewsize:

(setq vwz (getvar"viewsize"))

Goto Pspace and grab the pspace vport object and save it to variable " en " and then grab the following info:

(setq ed(entget en))

(setq vwh(cdr(assoc 40 ed))) ; vw height
(setq vww(cdr(assoc 41 ed))); vw width
Next, calculate the current value of the vport scale:

(setq vps(/ (/ vwh vwz) (/ vwh vww)))

Finally find the closes zoom scale factor that's greater than the current vps and use that.

 

Area Object Link | Dwg Setup | Feet-Inch Calculator | List on Steroids
Exchange App Store

Paul Li
Senior Associate
ALTOON PARTNERS LLP
Los Angeles • Amsterdam • Shanghai
617 West 7th Street • Suite 400 • Los Angeles • California • 90017-3889
D +1 213 225 1944 • T +1 213 225 1900 • www.altoonpartners.com
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!