Jump to content

Saving Macros To A Disc


gsksun4

Recommended Posts

Is there a way to save macros already in place to a disc, so if you are forced to change PC's you don't have to re-create them?

I realize this may be a stretch, since the toolbar buttons would not be in place when the AutoCad is reloaded.

Also, if you can, where would the existing macros be located?

Glenn

USA

Link to comment
Share on other sites

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • gsksun4

    13

  • Lee Mac

    5

  • rkmcswain

    4

  • lpseifert

    1

Top Posters In This Topic

Posted Images

Yes, I believe it can be done.

 

Macros for toolbar buttons can be retrieved with the following function, I have included a test using the Object Snap Toolbar as an example:

 

[i][color=#990099];; Get Macros by Lee McDonnell[/color][/i]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] GetMac [b][color=RED]([/color][/b]tNme [b][color=BLUE]/[/color][/b] lst[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] Men [b][color=RED]([/color][/b][b][color=BLUE]vla-get-MenuGroups[/color][/b]
                 [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] tObj [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Toolbars[/color][/b] Men[b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] tNme [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Name[/color][/b] tObj[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] bObj tObj
         [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Macro[/color][/b] bObj[b][color=RED])[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-remove[/color][/b] [b][color=#ff00ff]""[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]reverse[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:test [b][color=RED]([/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vl-princ-to-string[/color][/b]
     [b][color=RED]([/color][/b]GetMac [b][color=#ff00ff]"Object Snap"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
                 

Link to comment
Share on other sites

Yes, I believe it can be done.

 

Macros for toolbar buttons can be retrieved with the following function, I have included a test using the Object Snap Toolbar as an example:

 

[i][color=#990099];; Get Macros by Lee McDonnell[/color][/i]

[b][color=red]([/color][/b][b][color=blue]defun[/color][/b] GetMac [b][color=red]([/color][/b]tNme [b][color=blue]/[/color][/b] lst[b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]vl-load-com[/color][/b][b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]vlax-for[/color][/b] Men [b][color=red]([/color][/b][b][color=blue]vla-get-MenuGroups[/color][/b]
                 [b][color=red]([/color][/b][b][color=blue]vlax-get-acad-object[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]
   [b][color=red]([/color][/b][b][color=blue]vlax-for[/color][/b] tObj [b][color=red]([/color][/b][b][color=blue]vla-get-Toolbars[/color][/b] Men[b][color=red])[/color][/b]
     [b][color=red]([/color][/b][b][color=blue]if[/color][/b] [b][color=red]([/color][/b][b][color=blue]eq[/color][/b] tNme [b][color=red]([/color][/b][b][color=blue]vla-get-Name[/color][/b] tObj[b][color=red])[/color][/b][b][color=red])[/color][/b]
       [b][color=red]([/color][/b][b][color=blue]vlax-for[/color][/b] bObj tObj
         [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] lst [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-get-Macro[/color][/b] bObj[b][color=red])[/color][/b] lst[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]vl-remove[/color][/b] [b][color=#ff00ff]""[/color][/b] [b][color=red]([/color][/b][b][color=blue]reverse[/color][/b] lst[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]

[b][color=red]([/color][/b][b][color=blue]defun[/color][/b] c:test [b][color=red]([/color][/b][b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]princ[/color][/b]
   [b][color=red]([/color][/b][b][color=blue]vl-princ-to-string[/color][/b]
     [b][color=red]([/color][/b]GetMac [b][color=#ff00ff]"Object Snap"[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]princ[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]

 

You have me totally lost here. I'm not as well versed with this stuff. I imagine I would have to copy them to a CD from where they exist currently. I have no idea where that may be. I'm guessing the above function would be used on the new PC.

Also, I'm lost as to what the toolbar I created is named. I just took something existing and deleted the buttons and added my new commands.

I appreciate your help, but I lack a few skills with things like the above.

Link to comment
Share on other sites

Not a problem, I could step you through it if you like :)

 

If you just load and run the function I posted above, you will see that it will retrieve every macro associated with the Object Snap toolbar.

 

This information could be saved, (and the function could be extended to associate the toolbar name with the macro data), so that on a new computer you could use the saved data in a different LISP function to assign the macros to the toolbar buttons - assuming the toolbars exist.

 

The toolbar name is just what you see when you right click on a button and see a list of toolbar names :)

 

I am not sure if this can already be done with importing and exporting a profile though. :unsure:

Link to comment
Share on other sites

Not a problem, I could step you through it if you like :)

 

If you just load and run the function I posted above, you will see that it will retrieve every macro associated with the Object Snap toolbar.

 

This information could be saved, (and the function could be extended to associate the toolbar name with the macro data), so that on a new computer you could use the saved data in a different LISP function to assign the macros to the toolbar buttons - assuming the toolbars exist.

 

The toolbar name is just what you see when you right click on a button and see a list of toolbar names :)

 

I am not sure if this can already be done with importing and exporting a profile though. :unsure:

 

OK, the macros are the ones you helped me set up and the toolbar I set in place is "Draw Order". I used it because I have no need for that actual toolbar. I put the new buttons on that one.

Just an FYI, I don't have the new PC yet, so this is preliminary. The IT folks want me to upgrade, but I'm not ready yet.

I though I could put the macros on a CD for when the time comes instead of redoing 12 macros.

Baby steps for load and run?

This won't disturb the existing toolbar will it? I still need to use it now.

Link to comment
Share on other sites

Is there a way to save macros already in place to a disc, so if you are forced to change PC's you don't have to re-create them?
Menu macros are stored in the CUI file, but they can be in any one of several of them. If you created macros in the stock OOTB menu (like ACAD.CUI for vanilla AutoCAD), then you just need to copy this file. However, consider the results if your macros are in here and you upgrade to the next version. As an example, if you copy your 2009 CUI file for use in 2010, you will be missing all the new items that Autodesk put into the 2010 menu.

 

A better idea is to create your own custom CUI file to keep all *your* stuff in. Then you can copy this to any machine that has (almost) any version of AutoCAD on it, and load it as a partial menu.

Link to comment
Share on other sites

Menu macros are stored in the CUI file, but they can be in any one of several of them. If you created macros in the stock OOTB menu (like ACAD.CUI for vanilla AutoCAD), then you just need to copy this file. However, consider the results if your macros are in here and you upgrade to the next version. As an example, if you copy your 2009 CUI file for use in 2010, you will be missing all the new items that Autodesk put into the 2010 menu.

 

A better idea is to create your own custom CUI file to keep all *your* stuff in. Then you can copy this to any machine that has (almost) any version of AutoCAD on it, and load it as a partial menu.

 

I would only need to copy to a CD so I can use them in the same 2009LT I'm using now, only reloaded.

Not sure where this .CUI file is though. I also don't want to get ahead of Lee, he's been very helpfull to me.

Link to comment
Share on other sites

Ok, baby steps :)

 

First, let me just say, I haven't actually done this myself, and so I don't know if it will work or not - but we have nothing to lose.

 

The code I am providing will not affect your toolbar in the slightest - at the moment we are merely retrieveing information about your setup. :)

 

OK, so I have modified the code to use the toolbar name: "Draw Order".

 

What the code will do is find the necessary toolbar and extract all the macros associated with that toolbar.

 

[i][color=#990099];; Get Macros by Lee McDonnell[/color][/i]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] GetMac [b][color=RED]([/color][/b]tNme [b][color=BLUE]/[/color][/b] lst[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] Men [b][color=RED]([/color][/b][b][color=BLUE]vla-get-MenuGroups[/color][/b]
                 [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] tObj [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Toolbars[/color][/b] Men[b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] tNme [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Name[/color][/b] tObj[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] bObj tObj
         [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Macro[/color][/b] bObj[b][color=RED])[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-remove[/color][/b] [b][color=#ff00ff]""[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]reverse[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:test [b][color=RED]([/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]vl-princ-to-string[/color][/b]
     [b][color=RED]([/color][/b]GetMac [b][color=#ff00ff]"Draw Order"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 

Right, so how to use this code:

 

Copy it into Notepad and save it as a .lsp (any filename will do). I'm sure you have done this before.

 

Load the code into any drawing (using "_appload") and type "test" at the command line.

 

You should see a list of all the macros associated with the toolbar.

 

We can take it from here.

 

Lee

Link to comment
Share on other sites

Tbh, RKMcSwain is much more advanced at migrating settings than I am.

 

I will do what I can, but, as I say, I am stabbing in the dark here. - He can probably offer more practicle advice. :thumbsup:

 

Lee

Link to comment
Share on other sites

I would only need to copy to a CD so I can use them in the same 2009LT I'm using now, only reloaded.

Not sure where this .CUI file is though. I also don't want to get ahead of Lee, he's been very helpfull to me.

 

The first thing you have to figure out is what menu file are these macros in?

Run the CUI command, find your command in the command list (lower left pane), then look at the "source" column. This is the menugroup in which your "command" resides. Then look in the upper left pane. Make sure the drop-down list at the top is set to "All Customization Files". Your top level menu (the one listed at the top of the tree) is your MAIN MENU. Click on it and the menugroup name and the location of the menu will be shown in the upper right pane of the CUI. At the bottom of the tree is an entry called "Partial Menus", expand this to show all the partial menus loaded. Click on each one of those to see the menugroup name and menu location in the upper right pane also.

Link to comment
Share on other sites

Ok, baby steps :)

 

First, let me just say, I haven't actually done this myself, and so I don't know if it will work or not - but we have nothing to lose.

 

The code I am providing will not affect your toolbar in the slightest - at the moment we are merely retrieveing information about your setup. :)

 

OK, so I have modified the code to use the toolbar name: "Draw Order".

 

What the code will do is find the necessary toolbar and extract all the macros associated with that toolbar.

 

[i][color=#990099];; Get Macros by Lee McDonnell[/color][/i]

[b][color=red]([/color][/b][b][color=blue]defun[/color][/b] GetMac [b][color=red]([/color][/b]tNme [b][color=blue]/[/color][/b] lst[b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]vl-load-com[/color][/b][b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]vlax-for[/color][/b] Men [b][color=red]([/color][/b][b][color=blue]vla-get-MenuGroups[/color][/b]
                 [b][color=red]([/color][/b][b][color=blue]vlax-get-acad-object[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]
   [b][color=red]([/color][/b][b][color=blue]vlax-for[/color][/b] tObj [b][color=red]([/color][/b][b][color=blue]vla-get-Toolbars[/color][/b] Men[b][color=red])[/color][/b]
     [b][color=red]([/color][/b][b][color=blue]if[/color][/b] [b][color=red]([/color][/b][b][color=blue]eq[/color][/b] tNme [b][color=red]([/color][/b][b][color=blue]vla-get-Name[/color][/b] tObj[b][color=red])[/color][/b][b][color=red])[/color][/b]
       [b][color=red]([/color][/b][b][color=blue]vlax-for[/color][/b] bObj tObj
         [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] lst [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-get-Macro[/color][/b] bObj[b][color=red])[/color][/b] lst[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]vl-remove[/color][/b] [b][color=#ff00ff]""[/color][/b] [b][color=red]([/color][/b][b][color=blue]reverse[/color][/b] lst[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]

[b][color=red]([/color][/b][b][color=blue]defun[/color][/b] c:test [b][color=red]([/color][/b][b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]princ[/color][/b]
   [b][color=red]([/color][/b][b][color=blue]vl-princ-to-string[/color][/b]
     [b][color=red]([/color][/b]GetMac [b][color=#ff00ff]"Draw Order"[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]
 [b][color=red]([/color][/b][b][color=blue]princ[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b]

 

Right, so how to use this code:

 

Copy it into Notepad and save it as a .lsp (any filename will do). I'm sure you have done this before.

 

Load the code into any drawing (using "_appload") and type "test" at the command line.

 

You should see a list of all the macros associated with the toolbar.

 

We can take it from here.

 

Lee

How will we know if it works? That existing toolbar is still in my setup. Should I turn it off?

Also, you lost me on the _appload. Where do I do this?

And, if you're in London, it must be getting late. I don't want to inconvenience you. I'm in Florida and leave here in two hours. We can always continue tomorrow or whenever convenient for you Lee.

Don't want to be a burden.

Link to comment
Share on other sites

If you are using LT as it says in your profile, you won't have the command Appload, nor will you be able to run Lee Mac's lisp code. You'd probably be best off using RK McSwain's advise about the CUIs.

Link to comment
Share on other sites

The first thing you have to figure out is what menu file are these macros in?

Run the CUI command, find your command in the command list (lower left pane), then look at the "source" column. This is the menugroup in which your "command" resides. Then look in the upper left pane. Make sure the drop-down list at the top is set to "All Customization Files". Your top level menu (the one listed at the top of the tree) is your MAIN MENU. Click on it and the menugroup name and the location of the menu will be shown in the upper right pane of the CUI. At the bottom of the tree is an entry called "Partial Menus", expand this to show all the partial menus loaded. Click on each one of those to see the menugroup name and menu location in the upper right pane also.

This is where I got to in the CUI.

See attached:

 

OK, I'm sorry. I can't sem to attach the "Print Screen" I mad to show you where I am at this point. By the way, I'm running 2009LT.

Link to comment
Share on other sites

If you are using LT as it says in your profile, you won't have the command Appload, nor will you be able to run Lee Mac's lisp code. You'd probably be best off using RK McSwain's advise about the CUIs.

Thank you. I'm trying, but I got to the CUI and found the files, but am having trouble attaching the shot of the screen I made to show him where I am.

I leave in 45 minutes, and will have to pick this up tomorrow. I'm sorry for having to inconvenience anyone here, you've all been very helpful, but I'm doing this at work, so it's a little uneasy with, well, work.

Glenn

USA

Link to comment
Share on other sites

The first thing you have to figure out is what menu file are these macros in?

Run the CUI command, find your command in the command list (lower left pane), then look at the "source" column. This is the menugroup in which your "command" resides. Then look in the upper left pane. Make sure the drop-down list at the top is set to "All Customization Files". Your top level menu (the one listed at the top of the tree) is your MAIN MENU. Click on it and the menugroup name and the location of the menu will be shown in the upper right pane of the CUI. At the bottom of the tree is an entry called "Partial Menus", expand this to show all the partial menus loaded. Click on each one of those to see the menugroup name and menu location in the upper right pane also.

 

OK, I found the acadlt.cui file and copied it to my desk top. Can you help me attach the file to this forum tomorrow and then we can continue? At this point my head is spinning. This is all new to me.

Thank you for helping.

Glenn

USA

Link to comment
Share on other sites

Can you help me attach the file to this forum tomorrow and then we can continue?

 

ALT+Print Screen will copy the current window to the clipboard.

Open Paintbrush (or your fav editor) and paste this in.

Crop as needed.

Save it as a JPG or PNG file.

 

When you are in CADTutor, writing your post, scroll down to "Manage Attachments" and click the button. A new window will open. Click the Browse button, then find the saved image on your computer. After you do that, press the Upload button. Now close this windows and go back to your message that you are creating. Put the cursor where you want the image to show up and click the tiny arrow to the right of the paper clip icon at the top of the editor. Find your attachment and click it.

 

example5.png

 

It will insert some text into your message, but when you preview or submit the image will show up.

Link to comment
Share on other sites

My apologies Glenn, I completely overlooked the fact you were using LT. Hope you get this sorted. :oops:

 

Lee

No need to apologize Lee, you've been a tremendous help to me.

I just got a rush job dropped on me and will have to continue this at a later date. Sorry for the inconvenience, but I am doing all this at work.

Glenn

USA

Link to comment
Share on other sites

ALT+Print Screen will copy the current window to the clipboard.

Open Paintbrush (or your fav editor) and paste this in.

Crop as needed.

Save it as a JPG or PNG file.

 

When you are in CADTutor, writing your post, scroll down to "Manage Attachments" and click the button. A new window will open. Click the Browse button, then find the saved image on your computer. After you do that, press the Upload button. Now close this windows and go back to your message that you are creating. Put the cursor where you want the image to show up and click the tiny arrow to the right of the paper clip icon at the top of the editor. Find your attachment and click it.

 

[ATTACH]13266[/ATTACH]

 

It will insert some text into your message, but when you preview or submit the image will show up.

 

 

I don't know if this will help, but I found the files and will try to attach them here.

Unfortunately, as I told Lee, I just got a rush job dumped on me and have to attend to it. I will pick this back up as soon as I'm able. So sorry for this delay, you've been very helpful, and I hope we can finish this thread on a positive note.

Glenn

USA

 

OK, they don't show up in the Manage Attachments window. Maybe because they are .CUI files?

Again, I have to delay this for a short period of time. Please forgive.

Link to comment
Share on other sites

OK, they don't show up in the Manage Attachments window. Maybe because they are .CUI files?

 

If you want to attach a CUI file, you will have to ZIP it first (or at least change the extension to a valid one for attaching)

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...