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: 

AutoCAD LT - Macro to number piles sequentially

25 REPLIES 25
SOLVED
Reply
Message 1 of 26
caeda102
12216 Views, 25 Replies

AutoCAD LT - Macro to number piles sequentially

Hello,

I've read a few posts which I thought would cover this but haven't been able to make anything work. Basically I have a piling layout with 350 piles on it which have to be numbered. I have done this by block and attribute and can edit the number to each one individually. However, If one pile gets added I have to renumber the subsequent ones to have a logical sequence for the builder. Not too much of a problem if is near the end of the numbers, but a real pain if it is near the top. The piles are not on  a regular grid either so I can't just select and move the numbers en bloc. Is there any way to speed this up in Acad LT 2013? It would save me hours of editing time.

Thanks.

 

25 REPLIES 25
Message 2 of 26
Charles_Shade
in reply to: caeda102

That level of automation is not available in LT however you can Autonumber manually with these Macro's if you are so inclined. Though you may need to make adjustments to the first Macro if you have no need for a Text in the piles nomenclature.

 

-To provide a numbering scheme as in Rooms.  Text height must be zero:
-Put this on one button:
^C^C_setenv;StartWithNumber;\_setenv;TextInFront;\
-Put this on a second button: (I added the Textstyle set portion  S;Standard;)
*^C^C_text;S;Standard;\;;$M=$(getenv,textinfront)" "$(getenv,startwithnumber);setenv;startwithnumber;$(+,1,$(getenv,startwithnumber));^M;

 

(The smiley wink should be a semi-colon and a parenthesis.)

 

Please mark any response as "Accept as Solution" if it answers your question.
_____________________________________________________________

 

Message 3 of 26
caeda102
in reply to: Charles_Shade

Hello Charles,

Thanks very much for this. I have done the two button arrangement using cut and paste but I must be quite thick as I can't get it to work. What I would like to do is select the blocks and have numbers put in each one preferably without having to edit each one. If this is what the macro does how do I make it work? I'm not used to working with macros so need basic instructions.

Thanks anyway.

 

Message 4 of 26
Charles_Shade
in reply to: caeda102

Pick the first Macro and type the number to start with (Value) hit enter and type some Text (Value) hit enter to close the first Macro.

Pick the scond Macro and just start clicking. This should give you the Text followed by the Number.

Like I said you may not need the text but we need to get you to understand how the Macros work.

 

Please mark any response as "Accept as Solution" if it answers your question.
_____________________________________________________________

Message 5 of 26
pendean
in reply to: caeda102

You will need to select each and every one to renumber: as noted above, your wish for automation at that level is not available in LT.
Consider the much more pricey full AutoCAD for that advanced programming wish.
Message 6 of 26
steven-g
in reply to: caeda102

Do you also use excel in your work. If so you can better spend that couple of hours going out for lunch (3 course), come back to work and still have time for an afternoon nap.

To show how it could be done create a block called "TEST" with one attribute with the tag AUTONUM. Insert the block 4 times and give them the values 1,2,3 & 4 now insert a 5th block and give it a value of 2.1

Copy the following text into notepad and save it as "Update.scr" (just copy the text between the dotted lines)

-----------

-attedit
n
n
TEST
AUTONUM
4
4
5
-attedit
n
n
TEST
AUTONUM
3
3
4
-attedit
n
n
TEST
AUTONUM
2.1
2.1
3

 

--------------

Now just drag and drop the Update.scr file onto your autocad drawing, and the blocks will be renumbered from 1 thru 5.

PS the sequence has to run high to low or you will end up with 1,2,5,5,5

Anyway back to how it should work Isert any new piles that you need and number them so that the new piles fall in where you want them using decimals. Extract the number values from your drawing and reverse sort them. Use the format above and make a scr file, even doing it by hand in notepad copy and pasting shouldn't take more than 10 min for 350 piles (with excel and a bit of programming less than a minute). And if you need to remove piles then same thing but numbers run low to high. You will no doubt need to do a bit of work to get it to work with your attributes, but it is doable. If you want then post a sample of your blocks and I can probably give you a better idea.

Message 7 of 26
pendean
in reply to: steven-g

Nice tip.

Message 8 of 26
caeda102
in reply to: steven-g

Thanks for this. I will have to work it through when I have some time as it sounds as if it could be useful to me. As usual a deadline looms so I have managed to get the macro to work. Many thanks.

Message 9 of 26
caeda102
in reply to: Charles_Shade

Many thanks Charles. I have managed to get the Macro to do what I want and learned quite a bit about Macros too! It will save me lots of time.

Much appreciated.

Message 10 of 26

Hi @Charles_Shade,

I bumped into your solution while looking for the similar problem and this looks promising. But I can't make two buttons as the 2nd one just replaces 1st one. This might be the easiest part but I am having trouble doing it. I am using AutoCAD LT.

Message 11 of 26

Its been a while but likely the best thing to do is post your Macros as you currently have them so we can have a look.

Message 12 of 26

The problem is I can't find any macros option so I typed in macros which takes me in the "modemacro". Then I entered your code for the first button but nothing happens when I click on it. I have also tried to make new command from CUI which does not either. Probably missing some really simple thing here. I am using AutoCAD LT 2017.

Message 13 of 26
steven-g
in reply to: tamanna.moon

Unfortunately that's not where macro's go, it's a bit of a learning curve, take a look at this site how-to-automate-autocad-with-command-macros/ he covers the basics of macro's and gives a nice example of how and where to place them, there is also a link to the more traditional method. You might need to read through a couple of times but once understand it, macro's can be really useful, I'd be lost without them.

Message 14 of 26
tamanna.moon
in reply to: steven-g

Thanks for your help @steven-g. I will definitely look through it. For now I have made @Charles_Shade's solution work but for some reason the tag rotates to 214 degrees and text height is .2. Also I set the starting number as 001 but the next numbers are coming up as 2,3... instead of 002,003 which is not the biggest problem though. If I could fix these like have the rotation to 0 degrees and play with text height that would be life saving. Thanks 🙂

Message 15 of 26
jhagie
in reply to: Charles_Shade

Is it also possible to use an -insert block command that always adds up?


I have an old Autocad 2002 command that does this.

 

Macro 1. - Start from number

^C^Cdist;\

 

 

Macro 2. - From number +1

*^C^C-insert;groupnumber;\;;;$m=$(+, $(getvar, distance), 1);dist;$m=$(+, $(getvar, distance), 1) 

 

The groupnumber block is only a text block that is added by the macro 2 each time.

 

In Autocad 2018 it does not work and I would like to use it because I export the group numbers to a labeling program.

Message 16 of 26
steven-g
in reply to: jhagie

Take out one of the semicolons after the backslash (so there are 2 not 3)

*^C^C-insert;groupnumber;\;;$m=$(+, $(getvar, distance), 1);dist;$m=$(+, $(getvar, distance), 1) 

 that should fix it, if not post a copy of the command line history, starting from macro 1 and up to it failing in macro 2 

Message 17 of 26
jhagie
in reply to: steven-g

@steven-g

 

This is not what I meant, the macro works perfectly in Autocad 2002 LT.
Only in Autocad 2018 LT it no longer works with -insert block command.
The counting command (at the beginning of this post) works well in text but I want to do this in a block insert.
Because I export the block to another program with a different macro.

 

So what I would like to do.
The macros used above but with *^C^C-insert;groupnumber;\;;.....macro that adds up..... in the second macro

 

The first macro with setenv is good

And then the insert block command in the second macro

 


First post (10-03-2012 02:33 AM) with the solved anwser quote.
-To provide a numbering scheme as in Rooms.  Text height must be zero:
-Put this on one button:
^C^C_setenv;StartWithNumber;\_setenv;TextInFront;\
-Put this on a second button: (I added the Textstyle set portion  S;Standard;)
*^C^C_text;S;Standard;\;;$M=$(getenv,textinfront)" "$(getenv,startwithnumber);setenv;startwithnumber;$(+,1,$(getenv,startwithnumber));^M;

 

Message 18 of 26
steven-g
in reply to: jhagie

@jhagie the code I posted above in answer to your question, is changed and works perfectly in Autocad 2018LT or at least it does on my machine, if it fails for you then the only way we can help is by seeing what the results are in your command history, which would possibly give a clue as to what is going on, or maybe show up something that would show a need for a further more directed question.

Message 19 of 26
jhagie
in reply to: steven-g

@steven-g 

 

 

At Macro 1 I give the number 0, because I want to start adding from there

When I have done that, I will continue with Macro 2

After every mouse click the number should add up.

But I only get to see "dist" instead of a number after using the macros.

 

This is in my command history.

 

( Start Macro 1 ) - ^C^Cdist;\


Command:
Command:
Command: dist

Specify first point: 0

Specify second point or [Multiple points]:

Distance = 0.0, Angle in XY Plane = 0, Angle from XY Plane = 0
Delta X = 0.0, Delta Y = 0.0, Delta Z = 0.0

 


( Start Macro 2 ) - *^C^C-insert;groupnumber;\;;$m=$(+, $(getvar, distance), 1);dist;$m=$(+, $(getvar, distance), 1)


Command:
Command:
Command: -insert
Enter block name or [?] <groupnumber>: groupnumber

Units: Unitless Conversion: 1.0
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>:
Enter Y scale factor <use X scale factor>:

Specify rotation angle <0>: 1

Enter attribute values
GROUPNUMBER?: dist

Command: 1 Unknown command "1". Press F1 for help.

Command:
Command:
Command: -insert
Enter block name or [?] <groupnumber>: groupnumber

Units: Unitless Conversion: 1.00000000
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]: *Cancel*


***** End Macro 2 *****

 

Message 20 of 26
steven-g
in reply to: jhagie

Try this one as the second macro

*^C^C-insert;groupnumber;\;;;$m=$(+, $(getvar, distance), 1);dist;0,0;$m=$(+, $(getvar, distance), 1)

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

Post to forums  

Autodesk Design & Make Report

”Boost