Dear All,
I create this topic http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Change-all-block-element-to-Layer-0-w...
I got solution for that topic but now i need a liitle bit change as my latest comments in that topic. I dont want to change defpoint layer to layer 0.
Thanks.
This ?
(defun c:Test nil ;; Tharwat 24.Sep.2013 ;; (or acdoc (setq acdoc (vla-get-activedocument (vlax-get-acad-object))) ) (vlax-for x (vla-get-blocks acdoc) (if (and (eq :vlax-false (vla-get-Islayout x)) (eq :vlax-false (vla-get-IsXref x)) ) (vlax-for b x (if (/= (vla-get-layer b) "Defpoints") (vla-put-layer b "0") ) ) ) ) (vla-regen acdoc AcAllViewports) (princ) ) (vl-load-com)
I would suggest give user an option to remain objects on both Layer defpoint and any other non-plot layers as they are.
This one works well, it is what i needed but i dont want defpoint or another non plot layer will be changed to 0.
Could you adjust base on this code? Thanks.
(defun c:test ( / s ) (princ "\nSelect Block: ") (if (setq s (ssget "_+.:E:S" '((0 . "INSERT")))) (LM:ApplytoBlockObjects (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename (vlax-ename->vla-object (ssname s 0))) '(lambda ( obj / lin ) (vla-put-layer obj "0") (setq lin (strcase (vla-get-linetype obj))) (cond ( (= "BYLAYER" lin)) ( (= "CONTINUOUS" lin) (vla-put-linetype obj "BYLAYER") ) ( t (vla-put-linetype obj "HIDDEN") (vla-put-linetypescale obj 1.0) ) ) ) ) ) (princ) ) (vl-load-com) (princ)
Perhaps?
(defun c:test ( / lockedLayerPlot s ) (setq lockedLayerPlot '("Defpoints")) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (= (vla-get-Plottable l) :vlax-false) (setq lockedLayersPlot (cons (vla-get-Name l) lockedlayersPlot)) ) ) (princ "\nSelect Block: ") (if (setq s (ssget "_+.:E:S" '((0 . "INSERT")))) (LM:ApplytoBlockObjects (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename (vlax-ename->vla-object (ssname s 0))) '(lambda ( obj / lin ) (if (not (member (vla-get-layer obj) lockedLayersPlot)) (vla-put-layer obj "0")) (setq lin (strcase (vla-get-linetype obj))) (cond ( (= "BYLAYER" lin)) ( (= "CONTINUOUS" lin) (vla-put-linetype obj "BYLAYER") ) ( t (vla-put-linetype obj "HIDDEN") (vla-put-linetypescale obj 1.0) ) ) ) ) ) (princ) ) (vl-load-com) (princ)
Please see the error
; error: no function definition: LM:APPLYTOBLOCKOBJECTS
I tried with script beforeto lock defpoints layer. But when we lock layer we can not use APPLYTOBLOCKOBJECTS
I thinks this lisp have the same problem.
???
In your link thread:
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Change-all-block-element-to-Layer-0-w...
Is a function of Lee Mac
Yes. From Lee. But that thread got solution so no support anymore. That's reason i create new thread.
If your code uses the function of Lee Mac (LM:ApplytoBlockObjects ...), you must have loaded it beforehand...
You can simply the integrer in your code in the single file, example of final file:
(defun c:test ( / lockedLayerPlot s ) ;; Apply to Block Objects - Lee Mac ;; Evaluates a supplied function on all objects in a block definition. ;; Arguments: ;; blks - VLA Block Collection in which block resides ;; name - Block name ;; func - function to apply to all objects in block ;; Returns a list of results of evaluating the function, else nil. (defun LM:ApplytoBlockObjects ( blks name func / def result ) (setq func (eval func)) (if (not (vl-catch-all-error-p (setq def (vl-catch-all-apply 'vla-item (list blks name))))) (vlax-for obj def (setq result (cons (func obj) result))) ) (reverse result) ) (setq lockedLayerPlot '("Defpoints")) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (= (vla-get-Plottable l) :vlax-false) (setq lockedLayersPlot (cons (vla-get-Name l) lockedlayersPlot)) ) ) (princ "\nSelect Block: ") (if (setq s (ssget "_+.:E:S" '((0 . "INSERT")))) (LM:ApplytoBlockObjects (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename (vlax-ename->vla-object (ssname s 0))) '(lambda ( obj / lin ) (if (not (member (vla-get-layer obj) lockedLayersPlot)) (vla-put-layer obj "0")) (setq lin (strcase (vla-get-linetype obj))) (cond ( (= "BYLAYER" lin)) ( (= "CONTINUOUS" lin) (vla-put-linetype obj "BYLAYER") ) ( t (vla-put-linetype obj "HIDDEN") (vla-put-linetypescale obj 1.0) ) ) ) ) ) (princ) ) (vl-load-com) (princ)
@pixelarch wrote:
....
I got solution for that topic but now i need a liitle bit change as my latest comments in that topic. I dont want to change defpoint layer to layer 0.
....
Here's my take on it -- BEL0CL.lsp [= Block Entities to Layer 0 with Color & Linetype from entity's original layer]. Other suggestions here all seem to either require selection of one Block, or do it to all Block definitions in the drawing. This lets you select as many Blocks as you want, and does it to all [and only] Block definitions among the selection. No external routine is used. It could use some of the usual bells and whistles that I haven't added in yet....
Kent,
would it be possible to extend this function to include nested blocks also?
thanks
Janko
@jahbgd wrote:
....
would it be possible to extend this function to include nested blocks also?
....
Never got around to this back then [I hope you're still watching...], but another recent thread got me going. Here's BENL0CL.lsp [the N is for its including everything in Nested Blocks' definitions, too] with its eponymous command. It has a few additional improvements over the earlier BEL0CL.lsp, mainly Undo begin/end wrapping.
Kent,
Thanks, I will try it, although I have been using Edit_bloc by Gilles Chanteau. Is very helpful and has many options. Highly recommendable!
Anyway thanks for the effort!
Cheers
With updated CHZ20.vlx, now you can set up rules to change all subentities to Layer 0 except for those on Layer Defpoints.
Rules as below, save it as a txt file and use "By file" option from "Put subentities to layer" to select the txt file as the matching rule file.
((8 . "defpoints")) *Defpoints ;Remain objects on layer defpoints ("True") *0 ;Change all other objects except above to Layer 0
Settings as below:
@Kent1Cooper wrote:
@jahbgd wrote:....
would it be possible to extend this function to include nested blocks also?
....
Never got around to this back then [I hope you're still watching...], but another recent thread got me going. Here's BENL0CL.lsp [the N is for its including everything in Nested Blocks' definitions, too] with its eponymous command. It has a few additional improvements over the earlier BEL0CL.lsp, mainly Undo begin/end wrapping.
Ressurecting older thread... now:
What would one have to change in order to NOT retain the layers color? Have everything be on layer 0 w/o inheriting the original layers color?
Thanks!
@dsparkes wrote:
....What would one have to change in order to NOT retain the layers color? Have everything be on layer 0 w/o inheriting the original layers color?
....
Remove or comment out this part:
(if
(or ; [no Color override]
(not (assoc 62 edata)); Bylayer
(member '(62 . 0) edata); Byblock
); or
(setq edata (append edata (list (assoc 62 ldata)))); then -- assign Layer's color
); if
If you also want things to not be given their original Layer's linetypes, similarly remove or comment out the entire (if) function that immediately follow the one above.