TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: vicoco on May 04, 2021, 09:37:37 AM
-
Hello everybody,
I'm using a LeeMac AutoLisp, "Copy2Drawing", to copy some objects into a list of drawings in a directory.
I want to extend the code by adding some more functions. But these new functions only work on the current document, and not on the entire collection of drawings .
The new functions would be:
- set layer "0" as the current layer,
- freeze two layers (if they exist) according to some indicated names.
The code I used as follow (unsuccessfully), between highlighted lines (included in an extract from the original AutoLisp file):
)
)
)
)
)
;; New code start
layer2
(vla-item LayerTable
"LayerName2") )
;; New code finish
)
)
)
Note: "layer1" and "layer2" will not always exist. It may be that both exist, only one of them, or that neither exist.
Could you help me about this?
-
Welcome to TheSwamp :) Try something like this for your layers:
(foreach lyr '
("LayerName1" "LayerName2") )
)
I don't think you can set a current layer via odbx, but could be wrong.
-
I don't think you can set a current layer via odbx, but could be wrong.
Correct - the activelayer property is not available for an ObjectDBX document, and neither is the setvariable method unfortunately.
@vicoco, this:
Should be:
So as to obtain the Layers Collection for the ObjectDBX document as opposed to the Active Document.
-
Welcome to TheSwamp :) Try something like this for your layers:
(foreach lyr '
("LayerName1" "LayerName2") )
)
I don't think you can set a current layer via odbx, but could be wrong.
I don't think you can set a current layer via odbx, but could be wrong.
Correct - the activelayer property is not available for an ObjectDBX document, and neither is the setvariable method unfortunately.
@vicoco, this:
Should be:
So as to obtain the Layers Collection for the ObjectDBX document as opposed to the Active Document.
Thank you very much to both!!
Because AutoCAD does not allow freezing the current layer, and it's possible that some dwg has one of the layers to freeze as current, I have decided to modify the code, turning the layers off instead of freezing:
(foreach lyr '
("LayerName1" "LayerName2") )
)
I am a very beginner in LISP and VL, and I am still learning and understanding many new things every day.
-
You can freeze the current layer via DBX :-)
-
You can freeze the current layer via DBX :-)
Good point!!
This remark is "freezing" my brain! :wink:
Thanks again.
-
You can freeze the current layer via DBX :-)
Yikes! That sounds like a recipe for disaster, do you have a way using DBX to check the current layer?
-
You can freeze the current layer via DBX :-)
Yikes! That sounds like a recipe for disaster, do you have a way using DBX to check the current layer?
I do not.