need help to create special lisp routine to label lines with more than one label

need help to create special lisp routine to label lines with more than one label

Anonymous
Not applicable
2,030 Views
17 Replies
Message 1 of 18

need help to create special lisp routine to label lines with more than one label

Anonymous
Not applicable

hi every one ,  iam a fresh graduate and iam working on some project and really need your help to create a special lisp routine that can label different lines with fixed labels although one of these labels to be dynamic not fixed 

 

 

ddd.PNG

0 Likes
Accepted solutions (1)
2,031 Views
17 Replies
Replies (17)
Message 2 of 18

CodeDing
Advisor
Advisor

@Anonymous,

 

There are a few unknowns that need to be identified before anyone can help you with this.

Can you post an example dwg similar to the image you posted?

 

Unknowns I can think of:

- will text size ever change?

- will text layer ever change?

- will text direction ever change?

- is spacing between octagon shapes always the same?

- are octagon shapes blocks? If not, would it be beneficial to make them blocks?

- will the user input in middle text always be number? integer or real?

- what is maximum length of "fixed letter or phrase"?

- How many fixed letters or phrases are there? should user enter item or can it be simplified and limited to a list of items?

 

Best,

~DD

0 Likes
Message 3 of 18

Moshe-A
Mentor
Mentor

@Anonymous hi,

 

hope this is still relevent?!

 

Attached attribute block LineTAG.dwg plus LineTAG.VLX command to do what you want. place the files on AutoCAD support files search path and add the lisp to appload (do you know how?)

 

the block geometric looks exactly as in your pictue all lays on layer "0"  and contain 3 attributes:


AUTO

VARY

FIXED

 

after the lisp is loaded start the command as:

 

Command: LINETAG

Starting# or Rescan <001>:


First prompt ask you for starting number (Starting#) . by default (on dwg never used) it's 001 but if there are already some (the second time and up) LineTAG blocks, the default will be the last AUTO number incremented by one (e.g if the last number was 034, the default will be 035). the max value allowed is 3 digits due to the block attribute space.


press enter to accept the default or enter a new starting number (about Rescan see bellow).


Specify first LineTAG position <305>:


Next prompt ask you the LineTAG insertion point. at default is the varing value you wanted. this is the value for the VARY attribute.  pick your first insertion point or enter a new value for VARY attribute. again the max value allowed  is also 3 characters for the same reason. it could be a number or any 3 characters. if you want to exit here, just press enter (ofcours you can also ESC here). the block is insert now and you will be given the option to rotate it.


 than continue inserting more blocks...


Specify next LineTAG position <305>:

to exit just press enter (or ESC)

 

as you request the third attribute is fixed and it's default value is 'C' in the attribute (you can change it if you like).

the block scale is multipled by DIMSCALE so it would be fit to any drawing scale.

 

about Rescan:

the last values of AUTO and VARY attributes is saved only during drawing session (forget at closeing the file)

say you have some blocks inserted, the first time you run LineTAG the command scans the drawing to find the last AUTO and VARY values and save them in local variables. during session if you manually modifies AUTO number attribute and Starting# or Rescan <001>:  offers wrong default value, use the Rescan option to let it rescan the drawing to find the last values. this way it saved time and not scan the drawing on each LineTAG command.


enjoy

moshe

 

 

 

0 Likes
Message 4 of 18

Anonymous
Not applicable

FIRST OF ALL I WANT TO THANK BOTH OF you ,Moshe-A & CodeDing for your fast replies thank u very much .

Moshe-A  got exactly what i need , very simple very clever , but there is the thing that i cant manage to make the auto numbering it always shows 001 unless if i change it every time, then i have to control the  orientation of the block so if it is possible if the default orientation lets say horizontal  and there is an option to choose it to be vertical and when i choose either horizontal or vertical it saves my selection for the next clicks until i give it another order to change it to either directions again , last thing if it creates fixed layer for the block shape different from that of the texts so i can control the colors of  them by simply change the colors of their layers so i need it not to work with the current layer selection instead i want it to create two layers one for the block and the other for the texts and for every new click if it founds those layers already there it doesnot create new layers for every block i create but it uses the one that is already created . I know  i asked to much but if it needs alot of work then dont bother i can work with what i have right now ,and again thank u so much for helping me

0 Likes
Message 5 of 18

Moshe-A
Mentor
Mentor

@Anonymous,

 

Attched an update, made some changes the next prompt is 'history'

Specify first LineTAG position <305>:

instead the next prompt is constant

Specify LineTAG position/Rotate <305>:

note the default value here is the VARY attribute (not the auto number) you control the auto number in:

Command: LINETAG

Starting# or Rescan <001>:

check the auto number again, it works fine for me

 

As for the layers and colors you can control them by your own e.g open the block with BEDIT and create a layer for the block and a layer for the attributes and move them accordinly but i do not advise you to do that. currenly the block and attributes are on layer 0 and keeping them so will allow you to put it on any layer (you know in time we change our minds and want to move objects to other layers) however i made a minor change and set the attributes color to BYBLOCK. this gives you the following:

 

1. you can lay the block in any layer you want.

2. if you set the block an object color? the attributes will get that color.

3. you can control all that in future (if you change your mind)

 

for example:

create a layer by the name TAG and set it's color green. set layer TAG current and insert block. now select it and go to properties and in the color field set it to red. your block is green and attributes is red - cool no?!

 

moshe

 

 

 

 

 

 

any how i

 

 

0 Likes
Message 6 of 18

Anonymous
Not applicable

thanks Moshe-A for replying , everything is great and the rotation thing working just fine , but the auto numbering it asks me (#starting or rescan) then what ever number i write will appear but just for this one when i choose another point it starts from 001 again and i have to manually write another number in the window that appear ? so it seems that there is something iam missing here ? 

0 Likes
Message 7 of 18

Moshe-A
Mentor
Mentor

What AutoCAD version do you have?

can you post your dwg as a sample or atleast the part that in question?!

 

0 Likes
Message 8 of 18

Moshe-A
Mentor
Mentor

@Anonymous

 

ho Smiley LOL, my bell is ringing,  i think i know what is the problem so attached an update.

tell me what have you done with layers/colors?

 

 

0 Likes
Message 9 of 18

Anonymous
Not applicable

Moshe-A  , i've tried it actualy this time i got  an error , iam currently  using cad  17Capture.PNG

0 Likes
Message 10 of 18

Anonymous
Not applicable

 Moshe-A , this is the step that i have a problem with in the old version that u did change the orientation order for it  , as the photo in this command it says <005> but when i accept and press enter it give me again 001 unless i manually write 005 or any number , so it will just show 001 or any number i manually write despite the value that it has show automatically in this example it should've show 005 automatically yet it gives the same number which is 001 Capture.PNG

 

Capture.PNG

0 Likes
Message 11 of 18

Moshe-A
Mentor
Mentor

do not use the old version please.

 

with the new version, if this is the respond you are getting and this is a full AutoCAD 2017 version (not 2017 LT) then there may be something wrong with your installation?

 

 

 

 

0 Likes
Message 12 of 18

Anonymous
Not applicable

i'll try to re install it and try again coz it's the full version , whatever the result is, i have to really thank u for your patience and thank u for responding to me more than once , u really helped me alot 

0 Likes
Message 13 of 18

Moshe-A
Mentor
Mentor
Accepted solution

@Anonymous,

 

Made more fine tunings (see attached) and this is my final version for now.

have you solved the installation problem?

 

are we agrees about the layer\color matter?

please mark this as your solution

 

moshe

 

0 Likes
Message 14 of 18

Anonymous
Not applicable

every thing is fine except that a re installed the cad and used more than 1 pc still getting the same error , but iam currently using your first modification before the one that is giving me an error , i will mark this as the solution , as a thank u for your trouble , and if u find the cause of the error email me with it or something ,and if u didnt that is fine after all thank u again very very much

0 Likes
Message 15 of 18

Moshe-A
Mentor
Mentor

in that case, attached an 'update' version which a little step back from the last one

this i hope will work for you but try to exit from command by pressing enter and not esc.

 

anyhow the problem is sysvar ATTDIA which at default is 1 and it should be 0 in order LineTAG work well.

what it does is open attribute dialog box on insert of attributes block (LineTAG doesn't need it)

 

what about layers?

 

 

 

0 Likes
Message 16 of 18

Anonymous
Not applicable

that is all i wanted , u have solved it all , thank u so much , it is perfect for exactly what i need , all is good

0 Likes
Message 17 of 18

Moshe-A
Mentor
Mentor

Good Morning,

 

wonderful, happy to 'see' it's working for you. i'm sure you saw the constant prompt which keep you update with auto number and rotation angle.

 

 

 

 

 

 

0 Likes
Message 18 of 18

Anonymous
Not applicable
yes , it's perfect got every thing i need thanks again for your trouble
0 Likes