Community
AutoCAD LT Forum
Welcome to Autodesk’s AutoCAD LT Forums. Share your knowledge, ask questions, and explore popular AutoCAD LT topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Macro for creating duplicates without repeating macro

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
782 Views, 4 Replies

Macro for creating duplicates without repeating macro

I'm using Autocad LT 2017 and I want a macro that will create a string of rectangles of a user-defined length, for a terminal block (Autocad Electrical is not an option here). Currently I have the following Macro: "*^C^C_rectang;\D;20;6;", which creates a rectangle of my desired dimensions, and allows me to keep adding more until i exit the macro, however this isn't much of an advantage over my existing method. Ideally, I want to be able to specify the base point of the first rectangle, then have a user prompt for the number of terminals (rectangles) they would like, and each successive rectangle would be pasted directly below the last. I've attached an image of what this would look like for six terminals. Is this possible with Autocad LT macro functionality or would this require more involved scripting?

 

terminals.PNG

 

Labels (1)
4 REPLIES 4
Message 2 of 5
steven-g
in reply to: Anonymous

In theory it sounds possible, a macro can be repeatable using the "*" at the start but macros can only repeat continuously  using the exact same content of the macro, there is no way to 'program' in the number of times it will repeat and no way to create a 'programming loop' using the available variables.

It might be possible using a long list of 'if' branches to input a number and then have each 'if' make the choice of plot a rectangle or do nothing but that would require you to write the macro including each 'if' up to how ever many rectangles you might ever need, which would probably make your macro longer than the allowed number of characters in a macro.

I would suggest creating blocks, one for each of your variations of the number of terminals (you can make self exploding blocks so you just end up with rectangles), or even different macro's one for each variation. And then choose the correct one from a toolpalette.

Message 3 of 5
Paul_Gander
in reply to: Anonymous

I think you just need to use the ARRAY command, either manually or in a macro like this:

^C^C_rectangle;\_none;@20,-6;_-array;_last;;_rectangular;\1;-6

 You will be prompted for the top left corner of the rectangle and then for the number of rows in the array.

Message 4 of 5
janu319
in reply to: Anonymous

You can try both suggestions from Steven and Paul by creating a block with one rectangle and add the "Linear" Parameter plus "Array" Action. Then you can adjust the number of rectangles as you need, later explode the block.

Message 5 of 5
Anonymous
in reply to: Paul_Gander

This worked perfectly, thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report