Hello
I have a problem. After inserting blocks I want to change the layer of blocks to the layer in which the individual Block Entities are created.
Pl help.
Tahnks in advance.
snviswanadha
|
Hello
I have a problem. After inserting blocks I want to change the layer of blocks to the layer in which the individual Block Entities are created.
Pl help.
Tahnks in advance.
snviswanadha
if you use tool palettes, you can specify in the tool palette what layer to insert the block on when you first insert it
For example try to start this code:
And answer the quesition: what the layer of block should be setted?Code:(defun c:makeblock (/ adoc blk ent layer) (defun loc:addlayer (name color / res) (setq res (vla-add (vla-get-layers adoc) name)) (vla-put-color res color) res ) ;_ end of defun (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark adoc) (setq blk (vla-add (vla-get-blocks adoc) (vlax-3d-point '(0. 0. 0.)) "TestBlockForSettingLayer" ) ;_ end of vla-add layer (loc:addlayer "TestLayer_Color1" 1) ent (vla-addcircle blk (vlax-3d-point '(10. 0. 0.)) 5.0) ) ;_ end of setq (vla-put-layer ent (vla-get-name layer)) (setq layer (loc:addlayer "TestLayer_Color5" 5) ent (vla-addlightweightpolyline blk (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble '(0 . 5) ) ;_ end of vlax-make-safearray (apply 'append '((0. 0.) (5. 0.) (2.5 5.))) ) ;_ end of vlax-safearray-fill ) ;_ end of vlax-make-variant ) ;_ end of vla-AddLightWeightPolyline ) ;_ end of setq (vla-put-closed ent :vlax-true) (vla-put-layer ent (vla-get-name layer)) (setq blk (vla-insertblock (vla-get-modelspace adoc) (vlax-3d-point '(0. 0. 0.)) (vla-get-name blk) 10. 10. 10. 0. ) ;_ end of vla-InsertBlock ) ;_ end of setq (vla-put-layer blk "0") (vla-endundomark adoc) (princ) ) ;_ end of defun
Tahnks you,
Actually I want to insert a TOWER named WBLOCK drawn in layer TOWER and when i insert the new drawing,when i insert it it naturally comes in to current layer but i required it in the layer named TOWER same as in WBLOCK.
Wow-wow-wow. Slowly, please. Do you want to insert block to layer "<block-name>"? When you're creating block by _wblock command i think the datas of this record (i mean layer) are saving in "new block.dwg". I can't get the name of this layer after inserting block in new drawing. And i don't think so someone could get them.
For example i created Layer1 and Layer2, placed 1 lwpolyline and 1 circle to Layer1, and execute _wblock command (active layer is Layer2; this layer contains no entities). New drawing, _insert, select "wblocked" file. _purge -> I can purge Layer2!!! The data of it not saved in block definition
I tested it on ACAD 2005.
would entlast do what you need? it might select the previous item which would have been the block itself, you could get the name from the block, create a layer if it isn't already there, and move the block to that layer.
What for so long way?
Code:(entmod (subst (cons 8 (cdr (assoc 2 (entget (entlast))))) (assoc 8 (entget (entlast))) (entget (entlast))))
Thank for reply.
I hope above code might solve my problem,
I will see that in 2 days *** I am on leave i could not load it.
Any way the WBLOCK is created in a single layer1 it contains no other layer.
Thanks again