Jump to content

Quicker way to combine a few macro script commands buttons into a adhoc routine


vernonlee

Recommended Posts

A macro can call multiple scripts, so if you have a library of small scripts stored in a file on the filepath, you can just call up the scripts in the order you need (the blank script is empty and therefore ignored), the only reason to string all those together in the macro is just to save a few seconds by not having to type the word script each time you adjust the macro (OCD).

I was copying all my macros out into a master txt file yesterday to convert them to scripts and had my CUI and a text document each set to half screen width, it was really quick just going between the two and using Ctrl+c and Ctrl+v.

 

Got a couple of query:-

1. How do you convert them to scripts?

2. How do I "call up the scripts in the order I need"?

3) WHat is the purpose of the blank script file?

 

Thanks

Link to comment
Share on other sites

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • vernonlee

    14

  • steven-g

    7

  • YZ

    4

  • tombu

    3

Top Posters In This Topic

Late, but for any macro used to modify selected objects I prefer (right-click) Shortcut Menus. They take no screen space, you never have to look for them, and when you select an object or a group of like objects only macros for that object type are shown. Contextual Tabs are designed for this purpose as well. I keep most everything else on the Ribbon and Quick Access Toolbars controlled by Workspaces. I quit using the old drop-down Menus and Toolbars 3 years ago in favor of the Ribbon.

Thanks for the reminder. I did previously explore using (right-click) Shortcut Menus & had only 2 LISP using this method. I may explore further to arrange more shortcut to be in this manner. I cannot get use to Ribbons though.

Link to comment
Share on other sites

Got a couple of query:-

1. How do you convert them to scripts?

2. How do I "call up the scripts in the order I need"?

3) WHat is the purpose of the blank script file?

 

 

1. Just copy them into a normal text file but use the extension .scr (store these in the Autocad file search path, or add a folder to the search path). Be aware that scripts and macro's are slightly different, a script won't recognise alias's so you need to type the full command, and in a macro you use the ";" symbol to show pressing the enter key in a script you need to use a space or preferably use a new line.

2. Use a master macro (see post #17). A macro can call up multiple scripts which are run in the order they are listed.

3. Again see post #17 the blank file serves no real purpose, it's just to give the basis for a macro that can be altered as needed.

Link to comment
Share on other sites

1. Just copy them into a normal text file but use the extension .scr (store these in the Autocad file search path, or add a folder to the search path). Be aware that scripts and macro's are slightly different, a script won't recognise alias's so you need to type the full command, and in a macro you use the ";" symbol to show pressing the enter key in a script you need to use a space or preferably use a new line.

2. Use a master macro (see post #17). A macro can call up multiple scripts which are run in the order they are listed.

3. Again see post #17 the blank file serves no real purpose, it's just to give the basis for a macro that can be altered as needed.

 

Thanks bro. Also looking at post #16, I now understand your method. I do agree that this will be faster then my present method. The issue now is converting those macro to scr. It's time consuming especially change the ";" to a next line & initials to full command spelling.

 

But I still do not get the purpose for creating a blank script, will not having a blank.scr affect anything?

 

Thanks

Link to comment
Share on other sites

You can leave the blank script out.

 

As I understand it steven-g wrote that in there so it was easier to replicate. Sometimes you might have 4 routines, sometimes 5, but if the template always has 5 then you won't need to create the syntax again and risk an error, simply change "blank" to "script name". If you'd prefer to leave out the "blank" and just create new script commands in the ad hoc macro that will also work.

Link to comment
Share on other sites

Yeah like wot YZ said, I probably should not have worded it so in the first place, reading back over the post's I can see why it might be confusing (made perfect sense to me at the time - but this is probably why I have 2 ex's icon9.gif). The idea is just to have a standard 'master' macro somewhere in your system that can be easily called from a toolbar, toolpalette, ribbon, or menu and that the macro can be easily edited, without having to go through creating a new one each time.

Converting to script isn't so bad, in notepad, just highlight the ";" and press enter. It's a good idea anyway to use the full words in macro's it makes deciphering them a year later much easier (was that "l" meant to be line or was it last or maybe the number 1).

And for clarity (or not) the blank.scr is just ignored because it is empty.

Edited by steven-g
Link to comment
Share on other sites

You can leave the blank script out.

 

As I understand it steven-g wrote that in there so it was easier to replicate. Sometimes you might have 4 routines, sometimes 5, but if the template always has 5 then you won't need to create the syntax again and risk an error, simply change "blank" to "script name". If you'd prefer to leave out the "blank" and just create new script commands in the ad hoc macro that will also work.

 

Yeah like wot YZ said, I probably should not have worded it so in the first place, reading back over the post's I can see why it might be confusing (made perfect sense to me at the time - but this is probably why I have 2 ex's icon9.gif). The idea is just to have a standard 'master' macro somewhere in your system that can be easily called from a toolbar, toolpalette, ribbon, or menu and that the macro can be easily edited, without having to go through creating a new one each time.

Converting to script isn't so bad, in notepad, just highlight the ";" and press enter. It's a good idea anyway to use the full words in macro's it makes deciphering them a year later much easier (was that "l" meant to be line or was it last or maybe the number 1).

And for clarity (or not) the blank.scr is just ignored because it is empty.

 

Thanks guys for the clarifications.

 

:thumbsup:

Link to comment
Share on other sites

HI guys. I hit a wall for one of the macro scripts to be converted to scripts:

 

INSERT A BLOCK called "REV CLOUD" FROM template.dwg

^C^C_insert;"template";^C-insert;"*REV CLOUD";  

I changed to this but it insert the whole template.dwg instead of just "REV CLOUD" block:-

_insert
"template"
^C-insert
"*REV CLOUD"

Any advise on drafting the script?

 

Thanks

Link to comment
Share on other sites

A script is simply a list of commands to be sent to the command line. After successfully completing a group of commands and getting the result you want go to the text screen and copy that group of commands into a script. If it doesn't work on the command line it will not work in the script.

Link to comment
Share on other sites

_insert
"template"
^C-insert
"*REV CLOUD"

The insert command doesn't give you the option to get at a block from inside another drawing, so the way you are doing this is the only way. But there is a way to make it more workable, if you first insert the template drawing, and then imediately erase the last item, and then insert the block that you actually want, because now the block definition is included in your drawing, you can always use the purge command later to get rid of all those other unwanted and unused block definitions. I think that your problems is that your script starts the insert command as you expect, but the "^C" is actually not recognised because it is used in macros, so the rest of the script fails, but still prompts you to insert the template drawing (If scripts fail they don't give any warnings). Try this script.

-insert
template
0,0
1
1
0
erase
last

-insert
"*REV CLOUD"

Link to comment
Share on other sites

_insert
"template"
^C-insert
"*REV CLOUD"

The insert command doesn't give you the option to get at a block from inside another drawing, so the way you are doing this is the only way. But there is a way to make it more workable, if you first insert the template drawing, and then imediately erase the last item, and then insert the block that you actually want, because now the block definition is included in your drawing, you can always use the purge command later to get rid of all those other unwanted and unused block definitions. I think that your problems is that your script starts the insert command as you expect, but the "^C" is actually not recognised because it is used in macros, so the rest of the script fails, but still prompts you to insert the template drawing (If scripts fail they don't give any warnings). Try this script.

-insert
template
0,0
1
1
0
erase
last

-insert
"*REV CLOUD"

 

Ahhhh...I understand.

 

Also thanks for the workaround. Appreciate it

 

:beer:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...