PDA

View Full Version : Creating a new command for AutoCAD 2009



swells132024
2009-03-04, 11:11 PM
I'm new to this level of customizing AutoCAD (we're using 2009). I'm trying to create some new buttons that will insert various blocks that we have standardized in my office. As I understand I need to either have a script or LISP routine that will insert a specific block. Then I need to create a command that runs that script or LISP. (Stop me if I'm wrong). I'm having trouble getting the LISP and/or script written. Here's what I want to have done as an example:

Click on a button for inserting a section bug symbol. It should go to my blocks folder on the network and pull the "section_bug.dwg" file and then insert into the drawing at the scale the drawing is set to (the blocks are drawn at full scale).

I can't seem to get it to work. Again, I'm new to this type of customizing. We looked at just putting all the blocks into the tool palettes, but decided to have buttons in a customized panel and tab.

Any help would be greatly appreciated.

Thanks.

RobertB
2009-03-05, 11:10 PM
You don't need either a script or a LISP routine. The macro alone is sufficent.


^C^C^P._-Insert;Section_Bug;_s;(/ 1.0 (getvar "CAnnoScaleValue"))

Note the block's location is assumed to be on the Acad search path. If not, you can hardcode the path in the macro because once the block is defined in the current drawing the path is ignored.

swells132024
2009-03-06, 06:01 PM
You don't need either a script or a LISP routine. The macro alone is sufficent.


^C^C^P._-Insert;Section_Bug;_s;(/ 1.0 (getvar "CAnnoScaleValue"))

Note the block's location is assumed to be on the Acad search path. If not, you can hardcode the path in the macro because once the block is defined in the current drawing the path is ignored.

Thanks. That worked perfectly. The only issue I'm still having is getting it to insert at the correct scale. We set our dimscale to the appropriate scale (ex: DIM-96 for 1/8" = 1'-0" plans). This would only apply to annotation bugs like section, door #, wall type. We also have appliance and furniture blocks that would be inserted at fullscale.

Right now, when I click the new button, it inserts at full scale, which ends up being very small on an 1/8" drawing. Is there a way for it to see what dimscale is currently set and then match that size?

RobertB
2009-03-10, 01:21 AM
Thanks. That worked perfectly. The only issue I'm still having is getting it to insert at the correct scale. We set our dimscale to the appropriate scale (ex: DIM-96 for 1/8" = 1'-0" plans). This would only apply to annotation bugs like section, door #, wall type. We also have appliance and furniture blocks that would be inserted at fullscale.

Right now, when I click the new button, it inserts at full scale, which ends up being very small on an 1/8" drawing. Is there a way for it to see what dimscale is currently set and then match that size?The macro I posted does scale the object being inserted. However, you need to have the annotation scale set correctly. Dimension styles do not necessarily reflect the current scale of the drawing as well as annotation scale.

IMHO, dimension styles in AutoCAD 2008 and above should be annotative, which means you cannot use the DimStyle name.

Also, I find it odd that you have a different dimension style for each scale. That is unnecessary. One DimStyle can cover all scales as long as you override the DimScale system variable.

swells132024
2009-03-10, 01:34 AM
The macro I posted does scale the object being inserted. However, you need to have the annotation scale set correctly. Dimension styles do not necessarily reflect the current scale of the drawing as well as annotation scale.

IMHO, dimension styles in AutoCAD 2008 and above should be annotative, which means you cannot use the DimStyle name.

Also, I find it odd that you have a different dimension style for each scale. That is unnecessary. One DimStyle can cover all scales as long as you override the DimScale system variable.

Thanks for the clarification. Yes, I know it seems counter-intuitive to use this type of system for dimensioning. I'm working on changing that but for the moment it's what we have to work with. It looks like if we make that change, the info you gave me earlier will work great. Thanks again!