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?
Solved! Go to Solution.
Solved by Paul_Gander. Go to Solution.
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.
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.
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.
Can't find what you're looking for? Ask the community or share your knowledge.