Results 1 to 8 of 8

Thread: Change the Layer of Blocks to the Layer of the individual Block Entities

  1. #1
    Member
    Join Date
    2006-07
    Posts
    15
    Login to Give a bone
    0

    Question Change the Layer of Blocks to the Layer of the individual Block Entities

    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

  2. #2
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Change the Layer of Blocks to the Layer of the individual Block Entities

    if you use tool palettes, you can specify in the tool palette what layer to insert the block on when you first insert it

  3. #3
    I could stop if I wanted to kpblc2000's Avatar
    Join Date
    2006-09
    Posts
    212
    Login to Give a bone
    0

    Default Re: Change the Layer of Blocks to the Layer of the individual Block Entities

    For example try to start this code:
    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
    And answer the quesition: what the layer of block should be setted?

  4. #4
    Member
    Join Date
    2006-07
    Posts
    15
    Login to Give a bone
    0

    Default Re: Change the Layer of Blocks to the Layer of the individual Block Entities

    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.

  5. #5
    I could stop if I wanted to kpblc2000's Avatar
    Join Date
    2006-09
    Posts
    212
    Login to Give a bone
    0

    Default Re: Change the Layer of Blocks to the Layer of the individual Block Entities

    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.

  6. #6
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Change the Layer of Blocks to the Layer of the individual Block Entities

    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.

  7. #7
    I could stop if I wanted to kpblc2000's Avatar
    Join Date
    2006-09
    Posts
    212
    Login to Give a bone
    0

    Default Re: Change the Layer of Blocks to the Layer of the individual Block Entities

    What for so long way?
    Code:
    (entmod (subst (cons 8 (cdr (assoc 2 (entget (entlast))))) (assoc 8 (entget (entlast))) (entget (entlast))))

  8. #8
    Member
    Join Date
    2006-07
    Posts
    15
    Login to Give a bone
    0

    Default Re: Change the Layer of Blocks to the Layer of the individual Block Entities

    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

Similar Threads

  1. Replies: 3
    Last Post: 2013-07-25, 02:50 PM
  2. Change One Or Two Block Layer(s)
    By omorah in forum AutoCAD Customization
    Replies: 4
    Last Post: 2010-08-30, 12:09 PM
  3. Change Block Layer
    By Mac Demer in forum AutoCAD General
    Replies: 6
    Last Post: 2009-04-06, 06:13 PM
  4. Replies: 5
    Last Post: 2008-11-27, 06:38 AM
  5. Replies: 6
    Last Post: 2007-05-30, 05:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •