Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

changing layer color after turning on layerkey override...

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
209 Views, 8 Replies

changing layer color after turning on layerkey override...

Posted this in desktop customization, but it should probably go here...

Here's a special problem. I want to change the color when I turn on a layer
key. For example, I'm drawing walls, I then want to turn on the "exst"
layerkey, but I want to use another color in order to differentiate the
differences between existing and new. The colors would be:
New Exst'g
1 red 15 dark red
2 yellow 55 dark yellow
3 green 95 dark green
4 cyan 135 dark cyan
5 blue 175 dark blue
6 magenta 215 dark magenta

Some how I don't think I can do this in Lisp, it looks like it may have to
be done in VB, but I'm very new to VB... any thoughts or ideas?

Randy Rush
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

Randy,

What's the difference between setting up these layers in your template, and
selecting the desired one, versus selecting a "layerkey" and having a
program set the layer? Am I missing something here?

BTW, it *can* be done in AutoLISP.

--
http://www.acadx.com

"Randy Rush" wrote in message
news:485CC427176B4634E273066E972664BB@in.WebX.maYIadrTaRb...
| Posted this in desktop customization, but it should probably go here...
|
| Here's a special problem. I want to change the color when I turn on a
layer
| key. For example, I'm drawing walls, I then want to turn on the "exst"
| layerkey, but I want to use another color in order to differentiate the
| differences between existing and new. The colors would be:
| New Exst'g
| 1 red 15 dark red
| 2 yellow 55 dark yellow
| 3 green 95 dark green
| 4 cyan 135 dark cyan
| 5 blue 175 dark blue
| 6 magenta 215 dark magenta
|
| Some how I don't think I can do this in Lisp, it looks like it may have to
| be done in VB, but I'm very new to VB... any thoughts or ideas?
|
| Randy Rush
|
Message 3 of 9
Anonymous
in reply to: Anonymous

I may be over thinking this thing but let me try and break it down more and
see if my thinking is clear. I want to create these layers with the color I
want without creating the layers manually or setting them up in a template.
When I use overrides it create a new layer based on the layerkey for the
entity I'm trying to create. So if I'm drawing walls for example, and it's
color is 4, and I turn on the override to create existing walls, my new
layer will be A-Wall-Exst with the same color 4. What I would like to do is
this. use the layerkey override which will create my new layer and have the
color correspond to the list I've created. So when the A-Wall-Exst layer
is created it checks the layerkey color (in this example its 4), then based
on my requirements below changes the color to 135, the corresponding color
for 4. Otherwise I'd have to create duplicate layers of all the entity
types that could possibly be existing, a-wall-exst, a-glz-exst, a-door-exst,
etc. etc. Same things goes for demo. I want all demo'd entities to have
the color of 8 and dashed linetype.

Randy Rush

"R. Robert Bell" wrote in message
news:647B069D33707623661DA787DC8BC2DA@in.WebX.maYIadrTaRb...
> Randy,
>
> What's the difference between setting up these layers in your template,
and
> selecting the desired one, versus selecting a "layerkey" and having a
> program set the layer? Am I missing something here?
>
> BTW, it *can* be done in AutoLISP.
>
> --
> http://www.acadx.com
>
> "Randy Rush" wrote in message
> news:485CC427176B4634E273066E972664BB@in.WebX.maYIadrTaRb...
> | Posted this in desktop customization, but it should probably go here...
> |
> | Here's a special problem. I want to change the color when I turn on a
> layer
> | key. For example, I'm drawing walls, I then want to turn on the "exst"
> | layerkey, but I want to use another color in order to differentiate the
> | differences between existing and new. The colors would be:
> | New Exst'g
> | 1 red 15 dark red
> | 2 yellow 55 dark yellow
> | 3 green 95 dark green
> | 4 cyan 135 dark cyan
> | 5 blue 175 dark blue
> | 6 magenta 215 dark magenta
> |
> | Some how I don't think I can do this in Lisp, it looks like it may have
to
> | be done in VB, but I'm very new to VB... any thoughts or ideas?
> |
> | Randy Rush
> |
>
Message 4 of 9
Anonymous
in reply to: Anonymous

Something like this Randy?

(klayer "A-Wall" 4) ; set base layer, color 4
(klayer "A-Wall" "Xst") ; set layer, color 135
(klayer "A-Wall" "Demo") ; set layer, color 8, dashed

(defun NLayer (LayerName axDoc Color / objLayer)
(setq
objLayer (vla-Add
(vla-Get-Layers axDoc)
LayerName
) ;_ closes vla-Add
) ;_ closes setq
(if Color (vla-Put-Color objLayer Color))
objLayer ; return layer object
) ;_ closes defun

(defun KLayer (Base Key / LayerName axDoc LayerInfo NewLayer)
(setq
LayerName (strcat Base
(if (= (type Key) 'STR)
(strcat "-" Key)
""
) ;_ closes if
) ;_ closes strcat
axDoc (vla-Get-ActiveDocument
(vlax-get-acad-object)
) ;_ closes vla-Get-ActiveDocument
) ;_ closes setq
(cond

((setq NewLayer (tblobjname "LAYER" LayerName)) ; if exists
(setq NewLayer (vlax-ename->vla-object NewLayer)) ; just set layer
)

((= (type Key) 'INT) ; if doing base layer
(setq NewLayer (NLayer LayerName axDoc Key))
)

((= "DEMO" (strcase Key)) ; if demo, do following
(setq NewLayer (NLayer LayerName axDoc 8))
(if (not (tblobjname "LTYPE" "DASHED"))
(vla-Load ; then load it
(vla-Get-Linetypes axDoc)
"DASHED"
"ACAD.lin"
) ;_ closes vla-Load
) ;_ closes if
(vla-Put-Linetype NewLayer "DASHED")
)

((setq LayerInfo (tblobjname "LAYER" Base)) ; if base layer exists
(setq
LayerInfo (vlax-ename->vla-object LayerInfo)
NewLayer (NLayer LayerName
axDoc
(nth (vla-Get-Color LayerInfo) '(nil 15 55 95 135 175 215))
) ;_ closes NLayer
) ;_ closes setq
)

(T (alert "Base layer does not exist."))

) ;_ closes cond
(if NewLayer
(vla-Put-ActiveLayer axDoc NewLayer)
) ;_ closes if
(princ) ; clean exit
) ;_ closes defun

--
http://www.acadx.com

"Randy Rush" wrote in message
news:7AD594DA85D0D70021BEE162098B31B7@in.WebX.maYIadrTaRb...
| I may be over thinking this thing but let me try and break it down more
and
| see if my thinking is clear. I want to create these layers with the color
I
| want without creating the layers manually or setting them up in a
template.
| When I use overrides it create a new layer based on the layerkey for the
| entity I'm trying to create. So if I'm drawing walls for example, and it's
| color is 4, and I turn on the override to create existing walls, my new
| layer will be A-Wall-Exst with the same color 4. What I would like to do
is
| this. use the layerkey override which will create my new layer and have
the
| color correspond to the list I've created. So when the A-Wall-Exst layer
| is created it checks the layerkey color (in this example its 4), then
based
| on my requirements below changes the color to 135, the corresponding color
| for 4. Otherwise I'd have to create duplicate layers of all the entity
| types that could possibly be existing, a-wall-exst, a-glz-exst,
a-door-exst,
| etc. etc. Same things goes for demo. I want all demo'd entities to have
| the color of 8 and dashed linetype.
Message 5 of 9
Anonymous
in reply to: Anonymous

you can have a reactor set to trap AecGenerateLayerKey, when the command
ends you can see what layer it created, and if a layer generated by it,
you parse through and if its override is demo, change the layer table
color to 8 for that layer.

now I am assuming that WALLADD is using AECGENERATELAYER, if they are
using something other than that, or arx, then I am not sure how you
would trap. you can also trap the walladd command rather and after it
finishes you check your layer table, , now this may slow you down.
so you can react to walladd, and check if overrides are on, then parse
the table, if not then just exit.

actually come to think of it, don't react on AECgenerate... as many othe
commands may use it, and you sure
dont want your notes to be color 8 and hidden...

as for reactors, I have the faintest of ideas how to accomplish, but you
may want to look at Eric's AutoLay program and learn from that and other
topics here as well.
It is in lisp and it can be done...what you are looking for, just needs
creative programming...
as for checking overrides, and whether they are on, you got to weed
through the registry, for which I have something, but its buggy and was
modified by me to figure out overrides, and I dont understand dict
operations a whole lot. as for the layer table mod, look up in Cust NG
routines posted by MATT Dillon, and there is a routine in there that
modifies the layer table. or you can simply accomplish it with the layer
command , as I heard there are restrictions to using entmod comannds in
reactors...

just some ideas....

Randy Rush wrote:
>
> I may be over thinking this thing but let me try and break it down more and
> see if my thinking is clear. I want to create these layers with the color I
> want without creating the layers manually or setting them up in a template.
> When I use overrides it create a new layer based on the layerkey for the
> entity I'm trying to create. So if I'm drawing walls for example, and it's
> color is 4, and I turn on the override to create existing walls, my new
> layer will be A-Wall-Exst with the same color 4. What I would like to do is
> this. use the layerkey override which will create my new layer and have the
> color correspond to the list I've created. So when the A-Wall-Exst layer
> is created it checks the layerkey color (in this example its 4), then based
> on my requirements below changes the color to 135, the corresponding color
> for 4. Otherwise I'd have to create duplicate layers of all the entity
> types that could possibly be existing, a-wall-exst, a-glz-exst, a-door-exst,
> etc. etc. Same things goes for demo. I want all demo'd entities to have
> the color of 8 and dashed linetype.
>
> Randy Rush
>
> "R. Robert Bell" wrote in message
> news:647B069D33707623661DA787DC8BC2DA@in.WebX.maYIadrTaRb...
> > Randy,
> >
> > What's the difference between setting up these layers in your template,
> and
> > selecting the desired one, versus selecting a "layerkey" and having a
> > program set the layer? Am I missing something here?
> >
> > BTW, it *can* be done in AutoLISP.
> >
> > --
> > http://www.acadx.com
> >
> > "Randy Rush" wrote in message
> > news:485CC427176B4634E273066E972664BB@in.WebX.maYIadrTaRb...
> > | Posted this in desktop customization, but it should probably go here...
> > |
> > | Here's a special problem. I want to change the color when I turn on a
> > layer
> > | key. For example, I'm drawing walls, I then want to turn on the "exst"
> > | layerkey, but I want to use another color in order to differentiate the
> > | differences between existing and new. The colors would be:
> > | New Exst'g
> > | 1 red 15 dark red
> > | 2 yellow 55 dark yellow
> > | 3 green 95 dark green
> > | 4 cyan 135 dark cyan
> > | 5 blue 175 dark blue
> > | 6 magenta 215 dark magenta
> > |
> > | Some how I don't think I can do this in Lisp, it looks like it may have
> to
> > | be done in VB, but I'm very new to VB... any thoughts or ideas?
> > |
> > | Randy Rush
> > |
> >

--

-------------------
Nauman M
CAD Bazaar
Need to easily Navigate to your Custom Content Folders?
Need Autolayering for Dimensions without going through Design Center?
Download the updated ADT Tools for ADT 2 & 3 at
http://www.cadbazaar.com
Message 6 of 9
Anonymous
in reply to: Anonymous

Now how did I miss that AD reference in the original post? Silly me...
Message 7 of 9
Anonymous
in reply to: Anonymous

I kind of thought it would require a reactor, (something I'm entirely new
too!) I was thinking that this program I was thinking of could react after
the fact, and just change the color based upon it's relation to a similar
layer. sort of run through the layer list find the *xstg layers check em
against the similar layers and then change the color, maybe it can react to
any new layer that's created... I'll also look for Eric's and Matt's
program... Thanks Nauman...

randy

"Nauman M" wrote in message
news:3AF84F48.58C0FF5@email.com...
> you can have a reactor set to trap AecGenerateLayerKey, when the command
> ends you can see what layer it created, and if a layer generated by it,
> you parse through and if its override is demo, change the layer table
> color to 8 for that layer.
>
> now I am assuming that WALLADD is using AECGENERATELAYER, if they are
> using something other than that, or arx, then I am not sure how you
> would trap. you can also trap the walladd command rather and after it
> finishes you check your layer table, , now this may slow you down.
> so you can react to walladd, and check if overrides are on, then parse
> the table, if not then just exit.
>
> actually come to think of it, don't react on AECgenerate... as many othe
> commands may use it, and you sure
> dont want your notes to be color 8 and hidden...
>
> as for reactors, I have the faintest of ideas how to accomplish, but you
> may want to look at Eric's AutoLay program and learn from that and other
> topics here as well.
> It is in lisp and it can be done...what you are looking for, just needs
> creative programming...
> as for checking overrides, and whether they are on, you got to weed
> through the registry, for which I have something, but its buggy and was
> modified by me to figure out overrides, and I dont understand dict
> operations a whole lot. as for the layer table mod, look up in Cust NG
> routines posted by MATT Dillon, and there is a routine in there that
> modifies the layer table. or you can simply accomplish it with the layer
> command , as I heard there are restrictions to using entmod comannds in
> reactors...
>
> just some ideas....
>
> Randy Rush wrote:
> >
> > I may be over thinking this thing but let me try and break it down more
and
> > see if my thinking is clear. I want to create these layers with the
color I
> > want without creating the layers manually or setting them up in a
template.
> > When I use overrides it create a new layer based on the layerkey for the
> > entity I'm trying to create. So if I'm drawing walls for example, and
it's
> > color is 4, and I turn on the override to create existing walls, my new
> > layer will be A-Wall-Exst with the same color 4. What I would like to
do is
> > this. use the layerkey override which will create my new layer and have
the
> > color correspond to the list I've created. So when the A-Wall-Exst
layer
> > is created it checks the layerkey color (in this example its 4), then
based
> > on my requirements below changes the color to 135, the corresponding
color
> > for 4. Otherwise I'd have to create duplicate layers of all the entity
> > types that could possibly be existing, a-wall-exst, a-glz-exst,
a-door-exst,
> > etc. etc. Same things goes for demo. I want all demo'd entities to
have
> > the color of 8 and dashed linetype.
> >
> > Randy Rush
> >
> > "R. Robert Bell" wrote in message
> > news:647B069D33707623661DA787DC8BC2DA@in.WebX.maYIadrTaRb...
> > > Randy,
> > >
> > > What's the difference between setting up these layers in your
template,
> > and
> > > selecting the desired one, versus selecting a "layerkey" and having a
> > > program set the layer? Am I missing something here?
> > >
> > > BTW, it *can* be done in AutoLISP.
> > >
> > > --
> > > http://www.acadx.com
> > >
> > > "Randy Rush" wrote in message
> > > news:485CC427176B4634E273066E972664BB@in.WebX.maYIadrTaRb...
> > > | Posted this in desktop customization, but it should probably go
here...
> > > |
> > > | Here's a special problem. I want to change the color when I turn on
a
> > > layer
> > > | key. For example, I'm drawing walls, I then want to turn on the
"exst"
> > > | layerkey, but I want to use another color in order to differentiate
the
> > > | differences between existing and new. The colors would be:
> > > | New Exst'g
> > > | 1 red 15 dark red
> > > | 2 yellow 55 dark yellow
> > > | 3 green 95 dark green
> > > | 4 cyan 135 dark cyan
> > > | 5 blue 175 dark blue
> > > | 6 magenta 215 dark magenta
> > > |
> > > | Some how I don't think I can do this in Lisp, it looks like it may
have
> > to
> > > | be done in VB, but I'm very new to VB... any thoughts or ideas?
> > > |
> > > | Randy Rush
> > > |
> > >
>
> --
>
> -------------------
> Nauman M
> CAD Bazaar
> Need to easily Navigate to your Custom Content Folders?
> Need Autolayering for Dimensions without going through Design Center?
> Download the updated ADT Tools for ADT 2 & 3 at
> http://www.cadbazaar.com
Message 8 of 9
Anonymous
in reply to: Anonymous

Ok... a question... do I have to define klayer for all the layers that
could be generated from Xstg and demo?
"R. Robert Bell" wrote in message
news:DBE846A5BE0C3BFA67CE7A5A4339023E@in.WebX.maYIadrTaRb...
> Something like this Randy?
>
> (klayer "A-Wall" 4) ; set base layer, color 4
> (klayer "A-Wall" "Xst") ; set layer, color 135
> (klayer "A-Wall" "Demo") ; set layer, color 8, dashed
>
> (defun NLayer (LayerName axDoc Color / objLayer)
> (setq
> objLayer (vla-Add
> (vla-Get-Layers axDoc)
> LayerName
> ) ;_ closes vla-Add
> ) ;_ closes setq
> (if Color (vla-Put-Color objLayer Color))
> objLayer ; return layer object
> ) ;_ closes defun
>
> (defun KLayer (Base Key / LayerName axDoc LayerInfo NewLayer)
> (setq
> LayerName (strcat Base
> (if (= (type Key) 'STR)
> (strcat "-" Key)
> ""
> ) ;_ closes if
> ) ;_ closes strcat
> axDoc (vla-Get-ActiveDocument
> (vlax-get-acad-object)
> ) ;_ closes vla-Get-ActiveDocument
> ) ;_ closes setq
> (cond
>
> ((setq NewLayer (tblobjname "LAYER" LayerName)) ; if exists
> (setq NewLayer (vlax-ename->vla-object NewLayer)) ; just set layer
> )
>
> ((= (type Key) 'INT) ; if doing base layer
> (setq NewLayer (NLayer LayerName axDoc Key))
> )
>
> ((= "DEMO" (strcase Key)) ; if demo, do following
> (setq NewLayer (NLayer LayerName axDoc 8))
> (if (not (tblobjname "LTYPE" "DASHED"))
> (vla-Load ; then load it
> (vla-Get-Linetypes axDoc)
> "DASHED"
> "ACAD.lin"
> ) ;_ closes vla-Load
> ) ;_ closes if
> (vla-Put-Linetype NewLayer "DASHED")
> )
>
> ((setq LayerInfo (tblobjname "LAYER" Base)) ; if base layer exists
> (setq
> LayerInfo (vlax-ename->vla-object LayerInfo)
> NewLayer (NLayer LayerName
> axDoc
> (nth (vla-Get-Color LayerInfo) '(nil 15 55 95 135 175 215))
> ) ;_ closes NLayer
> ) ;_ closes setq
> )
>
> (T (alert "Base layer does not exist."))
>
> ) ;_ closes cond
> (if NewLayer
> (vla-Put-ActiveLayer axDoc NewLayer)
> ) ;_ closes if
> (princ) ; clean exit
> ) ;_ closes defun
>
> --
> http://www.acadx.com
>
> "Randy Rush" wrote in message
> news:7AD594DA85D0D70021BEE162098B31B7@in.WebX.maYIadrTaRb...
> | I may be over thinking this thing but let me try and break it down more
> and
> | see if my thinking is clear. I want to create these layers with the
color
> I
> | want without creating the layers manually or setting them up in a
> template.
> | When I use overrides it create a new layer based on the layerkey for the
> | entity I'm trying to create. So if I'm drawing walls for example, and
it's
> | color is 4, and I turn on the override to create existing walls, my new
> | layer will be A-Wall-Exst with the same color 4. What I would like to
do
> is
> | this. use the layerkey override which will create my new layer and have
> the
> | color correspond to the list I've created. So when the A-Wall-Exst
layer
> | is created it checks the layerkey color (in this example its 4), then
> based
> | on my requirements below changes the color to 135, the corresponding
color
> | for 4. Otherwise I'd have to create duplicate layers of all the entity
> | types that could possibly be existing, a-wall-exst, a-glz-exst,
> a-door-exst,
> | etc. etc. Same things goes for demo. I want all demo'd entities to
have
> | the color of 8 and dashed linetype.
>
Message 9 of 9
Anonymous
in reply to: Anonymous

Nope. (klayer) is a sub-routine that takes a base layer name string and
either color integer or keyname string to create/set layer. Be aware that I
missed your reference to ADT, so I'm not sure how this fits into ADT. The
two (defun)'s would be placed somewhere in your startup lisp files
(AcadDoc.lsp or a customized menu's .mnl).

--
http://www.acadx.com

"Randy Rush" wrote in message
news:89E09C3F92C0CD63E9482A1622817236@in.WebX.maYIadrTaRb...
| Ok... a question... do I have to define klayer for all the layers that
| could be generated from Xstg and demo?
| "R. Robert Bell" wrote in message
| news:DBE846A5BE0C3BFA67CE7A5A4339023E@in.WebX.maYIadrTaRb...
| > Something like this Randy?
| >
| > (klayer "A-Wall" 4) ; set base layer, color 4
| > (klayer "A-Wall" "Xst") ; set layer, color 135
| > (klayer "A-Wall" "Demo") ; set layer, color 8, dashed
| >
| > (defun NLayer (LayerName axDoc Color / objLayer)
| > (setq
| > objLayer (vla-Add
| > (vla-Get-Layers axDoc)
| > LayerName
| > ) ;_ closes vla-Add
| > ) ;_ closes setq
| > (if Color (vla-Put-Color objLayer Color))
| > objLayer ; return layer object
| > ) ;_ closes defun
| >
| > (defun KLayer (Base Key / LayerName axDoc LayerInfo NewLayer)
| > (setq
| > LayerName (strcat Base
| > (if (= (type Key) 'STR)
| > (strcat "-" Key)
| > ""
| > ) ;_ closes if
| > ) ;_ closes strcat
| > axDoc (vla-Get-ActiveDocument
| > (vlax-get-acad-object)
| > ) ;_ closes vla-Get-ActiveDocument
| > ) ;_ closes setq
| > (cond
| >
| > ((setq NewLayer (tblobjname "LAYER" LayerName)) ; if exists
| > (setq NewLayer (vlax-ename->vla-object NewLayer)) ; just set layer
| > )
| >
| > ((= (type Key) 'INT) ; if doing base layer
| > (setq NewLayer (NLayer LayerName axDoc Key))
| > )
| >
| > ((= "DEMO" (strcase Key)) ; if demo, do following
| > (setq NewLayer (NLayer LayerName axDoc 8))
| > (if (not (tblobjname "LTYPE" "DASHED"))
| > (vla-Load ; then load it
| > (vla-Get-Linetypes axDoc)
| > "DASHED"
| > "ACAD.lin"
| > ) ;_ closes vla-Load
| > ) ;_ closes if
| > (vla-Put-Linetype NewLayer "DASHED")
| > )
| >
| > ((setq LayerInfo (tblobjname "LAYER" Base)) ; if base layer exists
| > (setq
| > LayerInfo (vlax-ename->vla-object LayerInfo)
| > NewLayer (NLayer LayerName
| > axDoc
| > (nth (vla-Get-Color LayerInfo) '(nil 15 55 95 135 175 215))
| > ) ;_ closes NLayer
| > ) ;_ closes setq
| > )
| >
| > (T (alert "Base layer does not exist."))
| >
| > ) ;_ closes cond
| > (if NewLayer
| > (vla-Put-ActiveLayer axDoc NewLayer)
| > ) ;_ closes if
| > (princ) ; clean exit
| > ) ;_ closes defun
| >
| > --
| > http://www.acadx.com
| >
| > "Randy Rush" wrote in message
| > news:7AD594DA85D0D70021BEE162098B31B7@in.WebX.maYIadrTaRb...
| > | I may be over thinking this thing but let me try and break it down
more
| > and
| > | see if my thinking is clear. I want to create these layers with the
| color
| > I
| > | want without creating the layers manually or setting them up in a
| > template.
| > | When I use overrides it create a new layer based on the layerkey for
the
| > | entity I'm trying to create. So if I'm drawing walls for example, and
| it's
| > | color is 4, and I turn on the override to create existing walls, my
new
| > | layer will be A-Wall-Exst with the same color 4. What I would like to
| do
| > is
| > | this. use the layerkey override which will create my new layer and
have
| > the
| > | color correspond to the list I've created. So when the A-Wall-Exst
| layer
| > | is created it checks the layerkey color (in this example its 4), then
| > based
| > | on my requirements below changes the color to 135, the corresponding
| color
| > | for 4. Otherwise I'd have to create duplicate layers of all the
entity
| > | types that could possibly be existing, a-wall-exst, a-glz-exst,
| > a-door-exst,
| > | etc. etc. Same things goes for demo. I want all demo'd entities to
| have
| > | the color of 8 and dashed linetype.
| >
|

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

Post to forums  

Autodesk Design & Make Report

”Boost