Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create closed polylines based on layout windows

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
barry2104
626 Views, 9 Replies

Create closed polylines based on layout windows

On a project I'm running we have 1x .dwg for each infrastructure utility type (sewer, stormwater, electro, etc). In each of these .dwgs there are anywhere between 5 and 19 layouts (plus modelspace of course), which each represent one submission drawing - each layout is at 1:100 scale and covers the entire project area (detailed design stage at the moment).

 

We currently don't have a drawing showing exactly where each layout box is. Is it possible to create a lisp which effectively does the following:
1) creates a closed polyline around each layout's viewport using the current layer properties

2) switches all of these polylines from Layout Paperspace into Modelspace

 

I also need to insert MTEXT into each of these polylines in modelspace which represent the respective drawing number (layout tab name) but this is likely too tricky to implement, but I'd be really happy if someone has (or can create) a lisp which does the 1) and 2) tasks above!

Doing this by hand will take at least a day as we have over a hundred drawings/layouts in total (spread over 8 different .dwgs/utility types)

 

cheers!

Running AutoCAD Architecture 2020, in German
Tags (2)
9 REPLIES 9
Message 2 of 10
Lee_Mac
in reply to: barry2104

Try the attached Viewport Outline program (VPOutlineV1-0.zip).

 

Lee

 

Message 3 of 10
barry2104
in reply to: Lee_Mac

Thanks LM.

This lisp works nicely, but is there any way to enhance it so that you don't have to pick EACH layout to get each of them copied into model space?

I often have .dwgs with up to 25 layouts and they're typically very slow in switching from one layout to the other, so I'm looking for something which will search for all layout windows and copy a polyline into the model space for ALL of them in one hit.

 

appreciate any response!

Running AutoCAD Architecture 2020, in German
Message 4 of 10
hmsilva
in reply to: barry2104

One doubt,
How many viewports per layout, one or more than one?

Henrique

EESignature

Message 5 of 10
barry2104
in reply to: hmsilva

If it could work for just one viewport per layout then I'd be happy.

 

If it worked for any number of viewports per layout then it'd be perfect

Running AutoCAD Architecture 2020, in German
Message 6 of 10
hmsilva
in reply to: barry2104

Unfortunately the code I made does not work with multiple viewports per layout, it will skip all layouts with multiple viewports...

Henrique

EESignature

Message 7 of 10
barry2104
in reply to: hmsilva

any chance you can post/upload your code so I can test it out?

Running AutoCAD Architecture 2020, in German
Message 8 of 10
hmsilva
in reply to: barry2104


@barry2104 wrote:

any chance you can post/upload your code so I can test it out?


A quick one, minimally tested:

 

(vl-load-com)
(defun c:demo (/ ENT LL LLPT LST MT PL SSN UR URPT VLAOBJ VP) (setvar 'CTAB "model") (setq lst (layoutlist)) (foreach x lst (setvar 'CTAB x) (command "_.zoom" "_E") (if (and (setq vp (ssget "x" (list '(0 . "viewport") (cons 410 x) '(-4 . "/=") '(69 . 1)) ) ) (= (sslength vp) 1) ) (progn (setq ssn (ssname vp 0) ent (entget ssn) VlaObj (vlax-ename->vla-object ssn) ) (vlax-invoke-method VlaObj 'GetBoundingBox 'll 'ur) (setq llpt (vlax-safearray->list ll) urpt (vlax-safearray->list ur) ) (command "_.rectang" "_NONE" llpt "_NONE" urpt) (setq pl (entlast)) (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 10 llpt) (cons 1 x) ) ) (setq mt (entlast)) (command "_.chspace" pl mt "") (command "_.pspace") ) ) ) (setvar 'CTAB "model") (princ) )

 

HTH

Henrique

EESignature

Message 9 of 10
barry2104
in reply to: hmsilva

worked a treat, thanks!

just noticed though, that of the 9x Layout rectangles now visible/created in modelspace, seven of them share the same layer name, and the other two are on another layer.

 

any chance to tweak the code so that all layout rectangles get assigned the CURRENT/ACTIVE LAYER?

 

Running AutoCAD Architecture 2020, in German
Message 10 of 10
hmsilva
in reply to: barry2104

You're welcome, barry2104.

 

The code creates the rectangle and the text in the current layer...

 

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost