Macro Script through a load screen.

Macro Script through a load screen.

evan.8585
Participant Participant
890 Views
7 Replies
Message 1 of 8

Macro Script through a load screen.

evan.8585
Participant
Participant

Hey there!

I wanted to know if there was any way to setup an action script to load a file, and in my case, specifically a new layout from template. I'm trying to setup a recording that loads a new layout from template, chooses a specific template, then continues doing a few more actions afterward. I tried setting up a macro script for this action and autocad ignored the specific file chosen in the load screen and just created a new default layout instead. 

0 Likes
891 Views
7 Replies
Replies (7)
Message 2 of 8

Moshe-A
Mentor
Mentor

@evan.8585 ,

 

here is the command IMLAY to start with. it uses LAYOUT command to import a layout from a dwt/dwg. 

replace <file name.dwt/dwg> with your template name.

replace <layout> with your layout.

 

Note:-

the template should be on the AutoCAD support file search path otherwise you need to specify a full path.

if the layout name is not exist, the command will return an error an probably will break.

 

enjoy

moshe

 

; import layout
(defun c:imlay ()
 (command "._layout" "_template" <file name.dwt/dwg> <layout>)
 ; continues doing a few more actions afterward
 ; ...
 (princ) 
)

 

0 Likes
Message 3 of 8

evan.8585
Participant
Participant
Hey Moshe,

I've been trying to figure out how to use your script for weeks and just
cannot figure it out. Anyway you can give me a step by step of the process?

Thanks
0 Likes
Message 4 of 8

Anonymous
Not applicable

I know Moshe-A will respond we had something similar 20 layout titles all different as these were required for Land plot requirements. So used a menu to pick the correct one and import. I dont have access to the slide images at moment. But should get the idea of choose a layout.

screenshot374.png

 

0 Likes
Message 5 of 8

evan.8585
Participant
Participant

Thanks for the response, but I'm trying to create a macro for the action as opposed to going through mouse clicks. My main goal is to make an alias for the operation in order to greatly speed things up and also to understand a bit more of how AutoCAD handles this sort of thing in order to make more similar tools down the line. 

0 Likes
Message 6 of 8

Anonymous
Not applicable

The idea is you get a visual of the layout you want you can pick the image or the text value then it will load the macro with the correct name of dwg and layout as per moshe-A is 1 menu pick then 1 mouse click to much ? 

 

The menu image has been around since Autocad 1st existed if you can use notepad you can make it work, it is just so easy.

 

screenshot375.png

 

0 Likes
Message 7 of 8

evan.8585
Participant
Participant

I'm sure that'd work just fine for most situations, but I'd like to load a Layout template from a file. It needs to go to the specific file path and I'd love for it to choose the layout state as well (i.e. Landscape or Portrait) to avoid user error. 

0 Likes
Message 8 of 8

Anonymous
Not applicable

I dont think you understand I have been doing this for like 40 years it does what you want, behind the menu is a macro telling Autocad what to do. So for above its sets say the layout name and dwt name then runs a lisp that makes it happen. In this example there was only one dwt and that is hardcoded into newsurvlayout.

 

Look at what Moshe-A posted and look at what I a have shown in the mnu file.

 

(command "._layout" "_template" <file name.dwt/dwg> <layout>)

 

**SURVEY
[SURVEY]
[A0,A0]^C^C^P(SETQ FNAME "A0")(LOAD "NEWSURVLAYOUT")
[A1,A1]^C^C^P(SETQ FNAME "A1")(LOAD "NEWSURVLAYOUT")
[A3 Srv 1,A3 Srv 1]^C^C^P(SETQ FNAME "A3 Survey Sheet 1")(LOAD "NEWSURVLAYOUT")
[A3 Srv 2,A3 Srv 2]^C^C^P(SETQ FNAME "A3 Survey Sheet 2")(LOAD "NEWSURVLAYOUT")
[A3 ex 1,A3 ex 1]^C^C^P(SETQ FNAME "A3 Survey Sheet ex 1)(LOAD "NEWSURVLAYOUT")
[A3 ex 2,A3 ex 2]^C^C^P(SETQ FNAME "A3 Survey Sheet ex 2)(LOAD "NEWSURVLAYOUT")
[A3 New 1-2,A3 Srv Sheet New 1-2]^C^C^P(SETQ FNAME "A3 Survey Sheet New 1-2")(LOAD "NEWSURVLAYOUT")

 

 

  

 

 

; newsurvlayout.lsp

(COMMAND "-LAYOUT" "N" FNAME)
(COMMAND "-LAYOUT" "S" FNAME)
(SETQ SS (SSGET "X" (LIST (CONS 0 "VIEWPORT"))))
(COMMAND "ERASE" SS "")
(SETQ SS NIL)
(COMMAND "INSERT" (STRCAT "p:\\AUTODESK\\C3D TEMPLATES\\SURVEY\\" FNAME) (LIST 0 0) 1 1 0)
(COMMAND "ZOOM" "E")
(SETQ FNAME NIL)

 

 

You can just have a menu if you want just pick from menu, I just used the **image part, or even a toolbar with icons. or go a dcl list and pick from that.

 

screenshot376.png

 

 

 

0 Likes