Generation from Block reference

Generation from Block reference

manyamjyotsna
Participant Participant
1,050 Views
5 Replies
Message 1 of 6

Generation from Block reference

manyamjyotsna
Participant
Participant

Dear All,


I am new to this platform and am currently facing a challenge involving the automated generation of layouts from model space GRID blocks.

 

Specifically, I need to create over 100 layouts, each corresponding to a unique GRID block. Manually generating these layouts is proving to be quite time-consuming, and I am exploring automation solutions.

 

I have attached a sample DWG file containing five GRID blocks with GeoIMAGE, along with a sample layout for reference.

 

My goal is to automate the generation of layouts for all GRID blocks. Each layout should be named according to the SHTNUM attribute value associated with its respective GRID block, and the viewport properties (scale, etc.) should match those of the provided sample layout.

 

I would be immensely grateful for any guidance or assistance you could provide in achieving this automation.

 

Thank you very much for your time and consideration.

0 Likes
Accepted solutions (1)
1,051 Views
5 Replies
Replies (5)
Message 2 of 6

O_Eckmann
Mentor
Mentor

Hi @manyamjyotsna ,

 

You could try something like that 

(defun C:AutoLayout ( / ssBlk oBlk sShtNum I PT)
  (if (setq ssBlk (ssget "x" (list (cons 0 "INSERT") (cons 2 "GRID") (cons 66 1))))
    (progn
      (setq I 0)
      (repeat (sslength ssBlk)
	(setq oBlk (ssname ssBlk I))
	(setq I (1+ I))
	(setq sShtNum (cdr (assoc 1 (entget (entnext oBlk)))))
	; Delta X = 177.0000,  Delta Y = 124.8318
	(setq PT (cdr (assoc 10 (entget oBlk))))
	(setq PT (polar PT    0.0     (* 0.5 177.0000)))
	(setq PT (polar PT (* 0.5 PI) (* 0.5 124.8318)))
	(command "_-layout" "_c" "Sample" sShtNum)
	(setvar "CTAB" sShtNum)
	(command "_-VPORTS" "_l" "_off" "_all" "")
	(command "_MSPACE")
	(command "_zoom" "_c" PT "")
	(command "_PSPACE")
	(command "_-VPORTS" "_l" "_on" "_all" "")
	(setvar "CTAB" "Sample")
      )
    )
  )
)

 

 

Olivier Eckmann

EESignature

0 Likes
Message 3 of 6

baksconstructor
Advocate
Advocate

No problem.
If you can't create your own Lisp, then you'd better use a ready-made solution.
For example - "AutoViewport"
I recommend using the Internet search, there's a lot of information there.

 

1.PNG2.PNG

Message 4 of 6

manyamjyotsna
Participant
Participant

Thanks for your time and effort, Olivier.

This is working perfectly; however, the only adjustment needed is that the generated layouts are not being added in sequential order and are following a random pattern.

I would like the layouts to be arranged in ascending order (1, 2, 3, 4, ...).

0 Likes
Message 5 of 6

O_Eckmann
Mentor
Mentor
Accepted solution

Hi,

 

You could use TabSort from LeeMac to reorder your layouts : https://www.lee-mac.com/tabsort.html 

 

Olivier Eckmann

EESignature

Message 6 of 6

manyamjyotsna
Participant
Participant

This works, Many thanks 😊

0 Likes