Dear All,
Please find the attached. I have too many blocks with specific layers inside.
Could you help me to develope lisp can change all to layer 0 but keep color and linetype as it is.
I will use this as a part of script to change multiple block.
Thanks
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
See my generalised 'Apply to Block Objects' function - that page also contains an example program demonstrating how to utilise the function to move all objects in a block to layer "0", as you require.
Thanks Lee,
I dont need only change all block elements to 0. I also need change continuos line to bylayer, keep other linetype as it is or change them all to hidden line.
Does this help?
Until now the attached lisp can help me but still need customize a little bit to change all linetype (except continuos line) to hidden line, lts = 1
Thanks again.
First ensure that my Apply to Block Objects function is loaded, then the following program will move all objects within the definition of a selected block to Layer "0", will set objects with Continuous linetype to ByLayer linetype, and will set objects with any linetype except Continuous to use the Hidden linetype:
(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 )
(vla-put-layer obj "0")
(if (= "CONTINUOUS" (strcase (vla-get-linetype obj)))
(vla-put-linetype obj "BYLAYER")
(vla-put-linetype obj "HIDDEN")
)
)
)
)
(princ)
)
(vl-load-com) (princ)
Please note: the linetype "HIDDEN" must be loaded in the drawing.
Thanks a milliion.
It works well but change all linetype BYLAYER to HIDDEN. If linetype bylayer i want to keep as it is.
Is it posible if i want linetype scale of HIIDDEN is 1?
Thanks.
No problem
Please try the following code:
(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)
Dear Lee,
Could you revise a little bit to ingnore defpoints layer? It means keep all in defpoints as it is.
Thanks.
@pixelarch wrote:Dear Lee,
Could you revise a little bit to ingnore defpoints layer? It means keep all in defpoints as it is.
Thanks.
The following code will not modify objects residing on the defpoints layer:
(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 ) (if (/= "DEFPOINTS" (strcase (vla-get-layer obj))) (progn (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:
....
Could you revise a little bit to ingnore defpoints layer? It means keep all in defpoints as it is.
....
For one that allows selection of more than one Block, and processing of all Block definitions among the selection, don't miss my reply on the other thread about this, here [one of the drawbacks of having more than one thread on the same topic...].
There's more than one way to skin a cat Kent
Hi all,
Lee, I have another request and hope you will not find it tedious as enough time passed since you modified your script 🙂
I have been, unsuccessfully, trying to make an option where instead applying lintype you leave linetypes but change line colour to ie. 251 (we print that super thin). So any object that was not by layer to become gray.
Also, is it possible to apply it to nested blocks?
Thanks!
Janko
Great routine - now if we could modify to build a list of multiple blocks and step through them - I have a drawing with literally hundreds of blocks that were incorrectly formed (exported from Vectorworks). Vectorworks also assigns all entities a specific color, so we need to change all colors to bylayer, too. I would like to use the filter command to select all blocks, then apply your routine to the "previous" selection set - modifying them all in place in one fell swoop.
BTW, your website is very helpful - I will return and donate!
Any help greatly appreciated!
Hi Lee Mac !
Your program is just great but it only works one by one block. Is there a way to do a multiple selection and run the program to all ?
It would be perfect!
Thank you very much for your help !
@Anonymous wrote:
....
Your program is just great but it only works one by one block. Is there a way to do a multiple selection and run the program to all ?
...
@Anonymous wrote:
Great routine - now if we could modify to build a list of multiple blocks and step through them....
Welcome to the Forums, snaboxx! Try out the link in my earlier Reply on this thread.
This script is to make all objects within a block to be on layer "0" ... correct?
I keep attempting to run this (this is my first script show) and nothing happens to any of the blocks?
Ideas?
This is very important to my firm!
@Anonymous wrote:
This script is to make all objects within a block to be on layer "0" ... correct?
I keep attempting to run this (this is my first script show) and nothing happens to any of the blocks?
....
When you say "nothing happens," do you mean nothing is visibly any different? If so, that's exactly what the routines on this thread are meant to do -- see the end of the Subject line. They change everything to be on Layer 0, but they assign override color(s) and linetype(s) from the original Layer(s) of the Block's components, so the result shouldn't be apparent visibly.
To test whether the routine, whichever one you're talking about [and it's not a "Script," by the way -- that has a specific meaning in AutoCAD, different from what these AutoLisp routines are] did what it's supposed to do, run it on some Block(s), then Explode one. The objects resulting should all be on Layer 0, but with various different color and linetype overrides if they were originally on different Layers when the Block was defined. If they're not all on Layer 0, it would help if you can post a drawing file with some before-and-after conditions.
If you want everything forced to Layer 0 and ByLayer in color and linetype [and presumably with default values in other properties], there are certainly routines available to do that [and the routines on this thread could easily be adjusted to work that way], but this thread was for a different purpose.
Can't find what you're looking for? Ask the community or share your knowledge.