Jump to content

VBA titleblock.


mintyfresh

Recommended Posts

Hi,

 

My predecessor had created a macro that allowed him to cick a button in the toolbar and choose what size titleblock to insert from A4 - A0.

 

Unfortunaltey the pc was wiped and had everything re-installed so this clever feature has also dissapeared. I have the title block with loaded attributes available and can change the base size of this as needed.

 

Any help on how to go about creating such a macro would be appreciated. Something to do with VBA's? As you can tell my knowledge on this aspect of CAD is limited.

 

:(

Link to comment
Share on other sites

Hi Mintyresh,

 

Let me have the honour to welcome.gif you to the forum!

Hope you enjoy your stay. Where are you from if I may be so free to ask?

 

Since you are not familiar with VBA (and I suppose "lisp" is not common to you) I'd suggest another fairly easy approach. I use this in our office also. Let me explain what I have and see for yourself if the solution suits you.

 

The Source

First you need to have a drawing in wich the layouts (the paperspace layouts) are present as you want them to be. Let's act as if you do not have this kind of file and want to start from scratch, so here we go, starting to create one:

 

  • Open a new drawing, start from a clean template, as you do usually
  • Once the drawing is open, add a layout as you wish and call it anything you want but try to be "general" like ISOA4 if you use A4. Lets say we've added 3 layouts, ISOA4, ISOA3 and ISOA2.
  • Be shure each layout is as you want them to be; have the page setup as it should be, including the right plotter, plot styles, landscape/portrait, scale etc. etc.
  • Also include your stamps, titleblock, frames, etc.
  • Now save it to a "dedicated" folder like c:\Program Files\My Cad Files (it can be any folder, just remember where you place it and call the file "MyStandards.dwg" (I tend not to use any spaces in the name). If you have anything better in mind; suit yourself but stay of the spaces, this may be a bug in my mind but I don't want the spaces to appear in my macro's.
  • Enter "options" and add your dedicated folder to the "support file search paths". Be shure you add the correct folder.
  • Close the drawing.

Once this is done, you can say "the source" is ready. Now we need to tel AutoCAD how to do what you want it to do. Thats where the macro comes in.

 

The Macro

I will use a toolpalette for this, for it is easy to learn.

 

  • Open any (or a new) drawing in AutoCAD, not "My Standards.dwg", and then press the crtl+3 keys together. The toolpalettes show up.
  • Rightclick on the bar of the toolpalette and select "New palette".
  • Name it anything you want and here is the clean palette, awaiting your commands.
  • Select another palette where AutoCAD has some commands on it, and right click on any command and copy it.
  • Go back to your newly created palette and paste the copied command.
  • With a "rightclick -> properties" you can set various things, like the image.

Tool properties

Name: ISOA4

Description: This will inert a layout ISOA4

 

Use flyout: no

Flyout options:

Command string: HERE COMES THE MACRO

 

General: all --use current.

 

Where I say "here comes the macro" means that per command you can add 1 macro. So if you want to be able to insert 10 different layouts, then you will have to have a source file that has 10 layouts in it, one toolpalette with 10 commands on it. Each command has its own image and macro.

 

How should a macro look like?

^C^C-layout;t;MyStandards.dwg;ISOA4;

 

If you google around you will find how to make more out of your macro's and what some symbols do, like "^C^C" is 2 * escape, making shure the macro starts clean and not in the middle of another command.

 

Also, AutoCAD can find the drawing because you have added the dedicated folder to the Support File Search Paths and you have not mistyped anything. Remember: 1 space too much and nothing goes!

 

I have not tested all that I have stated above but I am pretty shure this will work.

 

Please let me know if there is a problem or if you want any further help.

 

Good luck, kind regards,

MarcoW.

 

ps.: I wonder if, once I Submit my Reply, I will still be the first...

Link to comment
Share on other sites

Hey MarcoW,

 

Thankyou for the welcome and advice. I'm from the UK.

 

This all worked out great until I reached the point where instructed to edit the Tool properties. I have tried to copy various tools from other pallets into the one I have created but none of them present me with the options, when I go into properties, to edit the following,

 

Use flyout:

Flyout options:

Command string:

 

I have tried with walls doors beams etc but they all seem to have there own specific properties.

 

Kind regards

MintyFRESH.

Link to comment
Share on other sites

Works perfectly. Tested this using just A4, A3 & A2. Now to set it up for A4 through to A0, landscape and portrait.

 

I found the folder where the guy before me had saved all his lisp and macro work. Trying to get my head round it a its quite interesting and would like to be able to set this up on older versions of AutoCAD. There is a lot to take in :unsure:

 

Thank you :D

Link to comment
Share on other sites

@ Mintyfresh: nice to hear that this is working fine.

Try to make it the best you can and you will have a time-saver for a long time.

 

@ Designerstuart: Thanks for the comment!

A post of the year will most likely not be given to me but that's okay.

I just wanted to give something back for all the help I got mostly in the VBA/Lisp section.

Funny thing: reveiving help in one part of a forum and payback to another.

Link to comment
Share on other sites

Yes, there are sveral options.

 

Try googling for "exporting toolpalettes". Also investigate "*_toolpalettepath". This will defenitely help you out.

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