CHANGING LAYER PROPERTIES, IGNORING MISSING LAYERS

CHANGING LAYER PROPERTIES, IGNORING MISSING LAYERS

Anonymous
Not applicable
523 Views
5 Replies
Message 1 of 6

CHANGING LAYER PROPERTIES, IGNORING MISSING LAYERS

Anonymous
Not applicable

I am workingona script routine to batch run on a large number of files.  I want it to rename a couple layers, Change layer colours and add a new layer.  I can get it to do all these things, except if a layer is missing.  The files that i am importing may not have layer 'c' but i am changing properties for layers 'a,b,c,d,e' Because the script cannot find layer 'c', it crashes the script. How do i tell the script to ignore a layer if it is missing?  below is a sample of the script. 

 

z

e

(if (tblsearch "LAYER" (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)))

  (command "_rename" "_layer" (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)) "cut"))

-rename

La

Scribe-text

Etch

-rename

La

NO KERF _ CUT _ NO LEAD-IN

Cut2

 

-la

n

bom

 

 

-la

s

bom

 

 

 

-la

lc

rgb

0,0,255

 

 

-la

s

cut

 

 

 

-la

lc

rgb

0,255,255

 

 

-la

s

etch

 

 

-la

lc

rgb

255,0,255

 

 

-la

s

display

 

 

-la

lc

rgb

255,0,0

 

 

-la

s

cut2

 

 

 

-la

lc

rgb

0,200,200

 

0 Likes
524 Views
5 Replies
Replies (5)
Message 2 of 6

cadffm
Consultant
Consultant

Without programming

Create layer first

 

 

-LAYER

THAW

C

MAKE

C

 

RENAME LAYER

C

newname

Sebastian

0 Likes
Message 3 of 6

Kent1Cooper
Consultant
Consultant

What version are you using, and/or overlay program?  I don't have [in 2019, and Help for 2020 doesn't mention, nor do I recall from earlier versions going way back] a LC option in -LAYER, and RGB is not the way to use that kind of color [it's the Color option and then beneath that the Truecolor option].  But in any case:

 

You don't need to make a Layer current in order to assign a color to it.  And if you do it by naming the Layer(s), and there is/are no such Layer(s), a message will go by that it didn't find it/them, but it won't crash -- it will just go back to the main prompt.  Also, you can combine all of this into one  Layer command -- you don't need to complete the command and then start it again, but can just choose further options and carry on.  Using my kinds of command options:

 

-LAYER

make ; this creates it like New option, and makes it current in the process -- no Set option required

bom

color Truecolor

0,0,255

 

color Truecolor

0,255,255

cut

color Truecolor

255,0,255

etch

color Truecolor

255,0,0

display

color Truecolor

0,200,200

cut2

 

Kent Cooper, AIA
0 Likes
Message 4 of 6

cadffm
Consultant
Consultant

@Kent1Cooper  schrieb:

 

-LAYER

make ; this creates it like New option, and makes it current in the process -- no Set option required

 


Only if the Layer is not already there &freezed,

that's why i answered with the bulletproof way, first thaw, then make:

 


@cadffm  schrieb:

Without programming

Create layer first

 

 

-LAYER

THAW

C

MAKE

C

 

RENAME LAYER

C

newname


 

Sebastian

0 Likes
Message 5 of 6

Kent1Cooper
Consultant
Consultant

@cadffm wrote:
.... first thaw, then make:

....


Yes, that's a good idea if it's possible that it might exist but be frozen, since a frozen Layer cannot be made current as the Make option will want to do.

 

[Why you would Make a Layer and then immediately rename it is beyond me -- just Make it under the desired name in the first place.  But if there's some reason to do it that way, there's a Rename option  inside the -Layer command, so you don't need to close Layer and open up a Rename command.]

Kent Cooper, AIA
0 Likes
Message 6 of 6

Anonymous
Not applicable

Thanks for the help guys.  I had to have one of our programmers step in and write it up for me.

0 Likes