Create new layout tabs and assign mspace coords

Create new layout tabs and assign mspace coords

neaton
Advisor Advisor
1,433 Views
8 Replies
Message 1 of 9

Create new layout tabs and assign mspace coords

neaton
Advisor
Advisor

I am trying to copy an existing layout tab multiple times, name them in a consecutive order and set the mview to specific coordinates in model space. Everything is working well, except that it is creating increasingly multiple viewports for each new layout. Layout 2 has 1 viewport, Layout 3 has 2 viewports, Layout 4 has 3 viewports...

I don't do much LISP programming and my routines are usually one-liners so I am sure there is a much easier way to do this. Attached is the dwg after I run the attached .lsp file. Thanks for any help!

Nancy

 

 

0 Likes
Accepted solutions (1)
1,434 Views
8 Replies
Replies (8)
Message 2 of 9

dbhunia
Advisor
Advisor

Try This.....

 

Do not forget that you are copying each Layout and creating viewport in new created Layout.......That's the reason for getting multiple viewport....


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 3 of 9

maratovich
Advisor
Advisor

See this solution on the forum:

https://forums.autodesk.com/t5/autocad-forum/create-multi-layouts-in-paper-space/m-p/8453051#M960067

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 4 of 9

dbhunia
Advisor
Advisor
Accepted solution

Sorry I forget to attach the file.......

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 5 of 9

neaton
Advisor
Advisor

Thanks, @maratovich. That is the post that started me thinking that the solution shouldn't be that hard. Since I am teaching myself LISP I thought it would be a good problem to tackle. Obviously, I still have a lot to learn since I couldn't get it to work.

Nancy


@maratovich wrote:

See this solution on the forum:

https://forums.autodesk.com/t5/autocad-forum/create-multi-layouts-in-paper-space/m-p/8453051#M960067


 

0 Likes
Message 6 of 9

neaton
Advisor
Advisor

Thanks, @dbhunia. That works perfectly. Now I just have to figure out why the additional if statement is required. I guess my understanding of how the while and if statements work is incorrect. Thanks for the help!

Nancy


@dbhunia wrote:

Try This.....

 

Do not forget that you are copying each Layout and creating viewport in new created Layout.......That's the reason for getting multiple viewport....


 

0 Likes
Message 7 of 9

maratovich
Advisor
Advisor

Good thing you have found a temporary solution.
Do not forget this forum.
When your lisp stops working, you will return here.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 8 of 9

ВeekeeCZ
Consultant
Consultant

@neaton wrote:

... Now I just have to figure out why the additional if statement is required. I guess my understanding of how the while and if statements work is incorrect. ....


 

Hi @neaton, I wouldn't think that layouts are the typical thing to start learning with..., but you did it pretty well!

 

I would say that it's not really incorrect while that caused all the trouble.... but, there are some things that you should consider to make your code better readable.

 

- do you really need 2 counters? 

- do you need so many variables?

- are the variable names clear enough that still need to be explained in commentaries...

- isn't there a better type of loop for this purpose? The while is good if you prior don't know how many iterates you will need. 

  

Spoiler.

(defun c:NVXXI ( / mll mur dst ang pfr pll pur idx)

  (command )

  (setq mll '(0 0)
	mur '(86 66)
	dst  130
	ang  0.
	prf "F"
	pll '(0.95 0.7)
	pur '(9.5633 7.3)
	idx 1
	)

  (repeat 4
    
    (if (= idx 1)
      (command "tilemode" 0
	       "pspace"
	       "mview" pll pur)
      (command "layout" "Copy"
	       (strcat prf (itoa (1- idx)))
	       (strcat prf (itoa idx))
	       "layout"
	       "Set" (strcat prf (itoa idx))))
    (command "mspace"
	     "zoom"
	     (polar mll ang (* (1- idx) dst))
	     (polar mur ang (* (1- idx) dst))
	     "tilemode" 0
	     "pspace")
    
    (setq idx (1+ idx)))  
  (princ)
)

 

0 Likes
Message 9 of 9

neaton
Advisor
Advisor

@ВeekeeCZ thanks for the logic lesson; I knew there was a cleaner way to do this.

Nancy


@ВeekeeCZ wrote: 

Hi @neaton, I wouldn't think that layouts are the typical thing to start learning with..., but you did it pretty well!

 

I would say that it's not really incorrect while that caused all the trouble.... but, there are some things that you should consider to make your code better readable.

 

- do you really need 2 counters? 

- do you need so many variables?

- are the variable names clear enough that still need to be explained in commentaries...

- isn't there a better type of loop for this purpose? The while is good if you prior don't know how many iterates you will need.  


 

0 Likes