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

How to INSERT another drawing's LAYOUT TABs in current drawing

8 REPLIES 8
Reply
Message 1 of 9
aqdam1978
2720 Views, 8 Replies

How to INSERT another drawing's LAYOUT TABs in current drawing

Hi,

 

I want to insert another drawing layout tabs contents in current drawing.

It's easy for MODEL tab, but for LAYOUT tabs, I dont know how!?

 

I prepared a code for INSERTING MODEL tab in current drawing:

 

(defun INS_DWG (TAB path dwg P / blk)
	(setq blk (strcat "\"*" path dwg "\""))
	;(setq N (vla-get-count (vla-get-layouts)));;Number of LAYOUT TABS in dwg
	
	(if (or(= TAB 0) (= TAB nil))(command "INSERT" blk P 1 0)); TAB=0 or omitted ==>Insert MODEL
	;(if (= TAB 1));==>Insert the 1st LAYOUT in dwg file
	;(if (= TAB 2));==>Insert the 2nd LAYOUT in dwg file
	;and so on....
);

;;usage:
;;(INS_DWG 0 "c:\\test\\" "test.dwg" '(0 0))

 

so, can you help me please to complete this code?

 

Thanks

 

8 REPLIES 8
Message 2 of 9
mid-awe
in reply to: aqdam1978

I'm just curious. When you create a new Layout from template and choose the drawing and tab that you want, does it not bring everything from that Layout with it? It works for me. Smiley Indifferent

Message 3 of 9
aqdam1978
in reply to: mid-awe

Hi,

 

if you draw anything in Layout tabs or insert a TitleBlock directly into Layout tabs, you can't see anythings in MODEL space!

 

Thanks for your answer.

 

Abbas

 

Message 4 of 9
mid-awe
in reply to: aqdam1978

What happens to your viewport? You may need to upload a sample dog showing the damaged view.
Message 5 of 9
aqdam1978
in reply to: mid-awe

Hi,

 

please draw some lines in one drawing but in Layout space not in Model space.

then save this file (c:\test\test.dwg) and open another drawing for example:

(command "new" "acadiso.dwt")

 

now, in this drawing load my above code:

appload ==> INS_DWG.lsp

then use my code to inset test.dwg to current drawing:

(INS_DWG 0 "c:\\test\\" "test.dwg" '(0 0))

 

now, test.dwg file inserted in current drawing but you can't see your drwan lines because this code just

insert MODEL space not LAYOUT spaces.

 

Thanks,

 

Abbas

 

Message 6 of 9
mid-awe
in reply to: aqdam1978

I believe that you will have to load the Layout completely to the new drawing.

 

(defun INS_DWG (TAB path dwg P / blk)
	(setq blk (strcat "\"*" path dwg "\""))
	;(setq N (vla-get-count (vla-get-layouts)));;Number of LAYOUT TABS in dwg
	
	(if (or(= TAB 0) (= TAB nil))(command "INSERT" blk P 1 0)); TAB=0 or omitted ==>Insert MODEL
	(if (= TAB 1)(COMMAND "LAYOUT" "T" blk "Layout1"));==>Insert the 1st LAYOUT in dwg file asuming that you follow the exact steps you provided to me
	;(if (= TAB 2)(COMMAND "LAYOUT" "T" blk "Layout2"));==>Insert the 2nd LAYOUT in dwg file ;and so on.... )

Notice a new drawing always includes Layout1 & Layout2 - unless you are utilizing a custom DWT? If you know the name of the Layout it is easy. Depending on your situation, you may want to delete the existing Layouts that already use the names you are loading. Such as:

 

(COMMAND "LAYOUT" "D" "Layout1")
(COMMAND "LAYOUT" "D" "Layout2")

 

I'm almost positive that the new layouts will fail to load if the name already exist, but I may be wrong about that part.

 

OR,

 

You will have to, at the very least:

(setvar "ctab" "DESIRED-TAB")

somewhere in your code.

Message 7 of 9
mid-awe
in reply to: mid-awe

I just thought of one more thing. Since the scale is different btween model space and paper space, after you follow your example, try zoom extents. I may be that your lines did load but they are so large that you cannot see them on the paper and you'll have to scale them to fit. Just a brain fart.

Message 8 of 9
aqdam1978
in reply to: mid-awe

Hi,

 

Thanks for your answers.

 

your suggestion:

 

(command "new" "acadiso.dwt")

(setq path "c:\\test\\" dwg "test.dwg" blk (strcat path dwg))
(COMMAND "LAYOUT" "T" blk "1234")

 

works, but it just added "1234" layout space of test.dwg to current drawing as a layout space!

 

but I'm looking for: inserting contents of another drawing's layout to Model space of current drawing.

 

Thanks again,

 

Abbas

Message 9 of 9
pbejse
in reply to: aqdam1978

To save us the trouble from coding:

 

Steal from Drawing by Lee Mac  <-- linky

 

HTH

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

Post to forums  

Autodesk Design & Make Report

”Boost