Layer Modify reactor
Hi,
Bricscad has no "_LayerP"- command and i like this command.
I wrote a lisp-script to save layerstates. 2 Reactors start the layerstate-save command, a command- reactor for "layer" and a sysvar-reactor for "clayer".
But it´s possible to modify layers (on/of, thaw/freeze/lock with the controlelement "Layers" or with another lisp-programm.
Has bricscad a reactor for all possibility to modify layers?
Thanks
Christian
Bricscad has no "_LayerP"- command and i like this command.
I wrote a lisp-script to save layerstates. 2 Reactors start the layerstate-save command, a command- reactor for "layer" and a sysvar-reactor for "clayer".
But it´s possible to modify layers (on/of, thaw/freeze/lock with the controlelement "Layers" or with another lisp-programm.
Has bricscad a reactor for all possibility to modify layers?
Thanks
Christian
0
Comments
-
So I will add _LayerP and _LayerPMode to BcadTools :-)
Besides, there are at least 2 ways to get notifications about layer changes :
- database reactor : this notifies about any change to database resident objects, like layers;
but even for all, so it is necessary to filter ...
- the likely better way is to attach an "ObjectReactor" to LayerTable ... this way, your
"ObjectReactor" will get a notification on any change to the layer table.
I hope this gives an idea ?0 -
Thank you, Torsten
my test - layer-ObjectReactor works now fine.
The _LayerP- Command in Bcad-Tools is a good idea, but the better solution is a _LayerP- Command in Bricscad.
Your Bricscad-Tool works only with windows. I had the Linux-Version and changed the version to Windows V12, because Linux- Version (V11) is very buggy (menu, toolboxes. graphic, pixel-pictures). But in the future i want go back to the Linux-version. I wrote own Layer-Lisp-routines for Linux and Windows, light-Versions from your LaymanPro and Layertools. The Layerstates-Command in the Linuxversion V11 is very slow. Without layergroups i can´t work with more then 500 layers. _layerP is a fast way to change the layerstatus.
Thank you very much for your help.
Christian0 -
My version "layerP-Command" with object-reactors for Bricscad Windows (and Linux also, but not tested).
Thanks for your help.
Christian0 -
Hello Christian,
It is always nice to see some Lisp action on this forum. Your code looks very nice, but while testing I have found a problem. Also some things could perhaps be improved.
1.
On line 38 of your code you have:
[code](setq i (length (car (nth ckPosLayerstand cklayerstliste))) ...)[/code]
The (car) statement should be removed. You want to use the length of the list and not the length of its first item.
2.
While your code loads it attaches an object reactor to each individual layer. I think what Torsten is suggesting is to use the LayerTable instead. This is better because it will also work for layers that are created after loading your lisp.
To get the LayerTable object without using (vla-get-activedocument):
[code](vlax-ename->vla-object (cdr (assoc 330 (entget (tblobjname "layer" "0")))))[/code]
3.
When your code loads it makes sense to add a first item to cklayerstliste.
4.
If you use the LAYER command and switch the current layer and also change the visibility of one or more layers, two new items are added to cklayerstliste. You would expect/want only a single new item. I think using a :vlr-commandwillstart reactor that sets ckLaybearb to T can solve this. Of course you then have to remove (not ckLaybearb) from (ckLayerEndCommand).
Hope that helps.
Regards, Roy.0 -
Hello Roy,
thank you for your tipps. The Points 1, 3 and 4 myself detecteted and it was already done your answer before.
I think, your Point 2 (vlax-ename->vla-object (cdr (assoc 330 (entget (tblobjname "layer" "0"))))) is better and shorter then my code. For newlayers i read the layerlist after the -layer-command, but this is not a good solution
Thank you and best Regards
Christian0 -
Dear Christian, Dear Roy,
regaring point 3 : yes, what I suggest is to use a *SINGLE* reactor, attached
to the Layer Table :-)
That will monitor *any* change to the Layer Table, and does not depend on
commands etc. - even changes to Layer Table made by Lisp/VB/VBA/C++/COM
will all be monitored then, by a single reactor :-)
Greetings to all !0 -
ooops - point #2, of course :-)0
-
@ Christian:
Some other stuff that you may have already considered:
5.
(cklayerwiederherstellen) will crash if a layer has been deleted.
6.
Commands that (ckLayerEndCommand) should perhaps also monitor:
-LAYER
EXPLORER
SETTINGS
UNDO
REDO
The last two are of course very interesting... Change cklayerstliste or ckPosLayerstand...?
7.
If the color or linetype of a layer is changed a new item is added to cklayerstliste when in fact you are only interested in layer visibility.
Question:
Why do you use the LAYER command inside (cklayerwiederherstellen)? To force a regen?
Regards, Roy.0 -
@ Roy
Hallo, thank you for your interesting tips
[code](vlax-ename->vla-object (cdr (assoc 330 (entget (tblobjname "layer" "0"))))) works fine.[/code]
[code]5. (cklayerwiederherstellen) will crash if a layer has been deleted. [/code]
This was a bug, is ok
[code]-LAYER :[/code] I changed the code
[code]EXPLORER :[/code]no problem for me
[code]SETTINGS :[/code]no problem for me
[code]UNDO:[/code]I changed the code
[code]REDO:[/code]I changed the code
[code] The last two are of course very interesting... Change cklayerstliste or ckPosLayerstand...? [/code]
This is only a little problem for me. The program now save the new layerstate after U, UNDO and REDO, is ok.
7.
[code] If the color or linetype of a layer is changed a new item is added to cklayerstliste when in fact you are only interested in layer visibility. [/code]
I know this and it´s a todo for the future. The code works.
[code]Question:
Why do you use the LAYER command inside (cklayerwiederherstellen)? To force a regen? :[/code]
Yes, but this was from a old version. The code works also without this command.
Best regards, Christian0
This discussion has been closed.