Renaming Layer lisp , just like the original in autocad but with modification

Renaming Layer lisp , just like the original in autocad but with modification

razkaman
Enthusiast Enthusiast
1,372 Views
5 Replies
Message 1 of 6

Renaming Layer lisp , just like the original in autocad but with modification

razkaman
Enthusiast
Enthusiast

Hi

 

i prepared a script for change layer in multiple drawing, but the problem is , if the layer is been rename, and there is no layer name , they will continue to ask the old layer , and since in script we can't make esc /cancel command, can you tell me how to modified layername change or maybe a lisp for renlayer? 

 

so when the old layer isnt there they will cancel and turn back to "command" or turn to "enter an option(...."

 

example:

-LAYER

Current layer:  "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: r

Enter old layer name: bearing

Enter new layer name: bearing01
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: r

Enter old layer name: dim

Cannot find layer "dim".

Enter old layer name: dim

Cannot find layer "dim". (they always repeating, what i want is they just cancel and back to "command" or to "enter an option (..." again)

 

0 Likes
1,373 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant
0 Likes
Message 3 of 6

Kent1Cooper
Consultant
Consultant

Here's a question:  Do you want to have all the Layers with the new names in all the drawings, whether or not all the Layers with the old names are there already?  That is [using your first example], if a drawing does not already contain a Layer "bearing," do you still want it to have a Layer "bearing01" in it after you run the routine?

 

If so, you could just force all the old Layer names to exist before renaming things, with a New option in the Layer command and a comma-delimited string of Layer names.  Add something like this before it gets into the Rename options:

 

-LAYER

N

bearing,dim,this,that,other,whatever,Bob,Carol,Ted,Alice

r

bearing

bearing01

r

dim

.... etc ....

 

Any of those Layer names that already exist in the drawing will be unaffected by the above [a message will go by that they already exist, but it will continue without error].

Kent Cooper, AIA
0 Likes
Message 4 of 6

razkaman
Enthusiast
Enthusiast

thank you for the link, it really helpful. so maybe better i insert the lisp first and change layer first with script , and then change the other like color,linetype,lw etc...

0 Likes
Message 5 of 6

razkaman
Enthusiast
Enthusiast

thank you for your reply.

 

but it still if i need  rename the layer with script, if the old layer if not exist, the script will be stop

i attached txt and also scr that i made. first i made the txt and then run it in perl and make scr from it.

 

i using perl because i'm just learn VBA. also don't know how to make lsp, i only make lsp to make command alias, which i don't use it anymore cause we can make command alias since autocad 2010

 

change layer in scr file.( can't upload the scr file so i write in here)

ltscale 1
-layer R "tse attrib" "D_EX_TSE_ATT" C 7 "D_EX_TSE_ATT" L "Continuous" "D_EX_TSE_ATT" LW 0.25 "D_EX_TSE_ATT" D "EXISTING TSE ATTRIBUTES (ID, DIAMETER, LENGTH, MATERIAL ETC)"
"D_EX_TSE_ATT"  -layer R "air valve" "D_EX_TSE_AVCH" C 240 "D_EX_TSE_AVCH" L "Continuous" "D_EX_TSE_AVCH" LW 0.25 "D_EX_TSE_AVCH" D "EXISTING TSE AIR VALVE CHAMBER"
"D_EX_TSE_AVCH"  -layer R "chamber 59+000" "D_EX_TSE_DCH" C 240 "D_EX_TSE_DCH" L "Continuous" "D_EX_TSE_DCH" LW 0.25 "D_EX_TSE_DCH" D "EXISTING TSE DISCHARGE CHAMBER"
"D_EX_TSE_DCH"  -layer R "C_50OUT" "D_EX_TSE_DICH" C 240 "D_EX_TSE_DICH" L "Continuous" "D_EX_TSE_DICH" LW 0.25 "D_EX_TSE_DICH" D "EXISTING TSE DISTRIBUTION CHAMBER"
"D_EX_TSE_DICH"  -layer R "cancelled_Waterline" "D_EX_TSE_DUCT" C 30 "D_EX_TSE_DUCT" L "Continuous" "D_EX_TSE_DUCT" LW 0.25 "D_EX_TSE_DUCT" D "EXISTING TSE DUCT"
"D_EX_TSE_DUCT"  -layer R "concrete encasement" "D_EX_TSE_FCH" C 240 "D_EX_TSE_FCH" L "Continuous" "D_EX_TSE_FCH" LW 0.25 "D_EX_TSE_FCH" D "EXISTING TSE FLUSHING CHAMBER"
"D_EX_TSE_FCH" 

0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@razkaman wrote:

.... 

but it still if i need  rename the layer with script, if the old layer if not exist, the script will be stop

....

 

If that's happening even if you make all the old Layer names exist in the drawing, maybe [I'm guessing] those names don't "register" until the Layer command ends, so they're not really there yet for the renaming, as I laid it out before.

 

If that's the issue, I expect it would work to have a separate Layer command to make the old Layer names exist, complete that, and then start a new one to rename them:

 

-LAYER

N

bearing,dim,this,that,other,whatever,Bob,Carol,Ted​,Alice

 

-LAYER

r

bearing

bearing01

r

dim

.... etc ....

Kent Cooper, AIA
0 Likes