Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Change all objects to new layer and keep properties

  1. #11
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Change all objects to new layer and keep properties

    Quote Originally Posted by irneb View Post
    Which AC version ... the drawing gives me an error opening in 2008.
    Version 2010. i attached another drawing.
    I understand your point of view. This is a better way of working. But I'm talking about work that is done in "Network" by several colleagues who usually draw each of its specialty. We work with xrefer (more correctly, of course) but this xrefer is always "worked" (company policy) so that the result is as simple as possible. He serves as the basis for all specialties. The design is not "exploded" because the routine that I put here even change the color blocks. The problem is avoid the kinds of lines that are defined in the layer do not change to "continuous" like my lisp code.
    Thanks
    Attached Files Attached Files

  2. #12
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Change all objects to new layer and keep properties

    As was explained in another thread, it's always a good idea to write your code so that it is case insensitive . Apparently 2008 has alinetype value of "ByLayer" while 2009 has one of "BYLAYER"
    Code:
    (vl-load-com)
    (defun c:combinelayers (/ doc blocks blk eo layers lay)
      ;; Get the ActiveX object of the current dwg
      (setq doc    (vla-get-ActiveDocument (vlax-get-acad-object))
            blocks (vla-get-Blocks doc) ;Get the blocks collection
            layers (vla-get-Layers doc) ;Get the layers collection
      ) ;_ end of setq
    
      ;; Step through all blocks (including Model Space & Layouts)
      (vlax-for blk blocks
        ;; Step through all contained entities in block
        (vlax-for eo blk
          ;; Get the layer the entity is placed on
          (setq lay (vla-Item layers (vla-get-Layer eo)))
          (vla-put-Layer eo (getvar "CLAYER")) ;Change the entity to the current layer
          (if (= (vla-get-Color eo) 256)
            ;;If its colour bylayer, change it to overridden color to match
            (vla-put-Color eo (vla-get-color lay))
          ) ;_ end of if
          (if (= (strcase (vla-get-Linetype eo)) "BYLAYER")
            ;;If its linetype bylayer, change it to overridden linetype to match
            (vla-put-Linetype eo (vla-get-Linetype lay))
          ) ;_ end of if
          (if (= (vla-get-Lineweight eo) -1)
            ;;If its lineweight bylayer, change it to overridden lineweigth to match
            (vla-put-Lineweight eo (vla-get-Lineweight lay))
          ) ;_ end of if
        ) ;_ end of vlax-for
      ) ;_ end of vlax-for
      (princ)
    ) ;_ end of defun
    Seems to now work
    Attached Files Attached Files

  3. #13
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Change all objects to new layer and keep properties

    It is a privilege being a member of Augi. Thank you. It was a great help. If you have time available and willing to put up with me, I have one or another situation to resolve in terms of code.
    Last edited by pt_zooropa; 2009-06-18 at 04:18 PM. Reason: Bad text

  4. #14
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Change all objects to new layer and keep properties

    Quote Originally Posted by irneb View Post
    As was explained in another thread, it's always a good idea to write your code so that it is case insensitive . Apparently 2008 has alinetype value of "ByLayer" while 2009 has one of "BYLAYER"
    Code:
          (if (= (strcase (vla-get-Linetype eo)) "BYLAYER")
    BwaHaHa!!!! <snort>

    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  5. #15
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Change all objects to new layer and keep properties

    Now it works fine...thank you.
    If i may dare to, i wanted it to be possible to create the layer E-ENG color 40 and change all objects to that layer. The code that i already placed before do that, it but the language is different. Furthermore, also change all the fonts that are in drawing for Standard size .10
    This could do it i think but and when we have Mtext...it works like simple text?:

    Code:
    (vl-load-com)
    (vlax-for x (vla-get-textstyles
    	      (vla-get-activedocument (vlax-get-acad-object))
    	    )
      (vla-put-fontfile x "Simplex.shx")
    )
    (vl-load-com)
    (setq TxtHgt 0.1)
    (setq CurSet (ssget '((0 . "TEXT")(-4 . "<=")(40 . 4.7))))
    (if CurSet
    (while (setq CurEnt (ssname CurSet 0))
    (setq CurObj (vlax-ename->vla-object CurEnt))
    (ssdel CurEnt CurSet)
    (vla-put-alignment CurObj acAlignmentLeft)
    (vla-put-StyleName CurObj "STANDARD")
    (vla-put-height CurObj TxtHgt)
    (vla-Update CurObj)
    )
    )
    (princ)
    )
    Thanks for your help, it has been very useful.
    Sorry my english...i am portuguese...lol

  6. #16
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Change all objects to new layer and keep properties

    MText can have overrides on the size, so it won't be as easy as that. However, I wonder if CAD Standards would help for the text size issue?
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  7. #17
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Change all objects to new layer and keep properties

    Quote Originally Posted by RobertB View Post
    MText can have overrides on the size, so it won't be as easy as that. However, I wonder if CAD Standards would help for the text size issue?
    that will be a solution...i think...any ideas?

  8. #18
    Woo! Hoo! my 1st post
    Join Date
    2013-12
    Posts
    1
    Login to Give a bone
    0

    Default Re: Change all objects to new layer and keep properties

    hi irneb. this lisp is great. I need this kind of lisp but with different criteria. Transfer all old layers to one new layer, the color and lineweight to change BYLAYER and keep the linetype as is. I think you called it overide. example. if the current line is dashed and bylayer setting when it transfer to new layer it will remain dashed.

    And it will also apply to multiple blocks.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Layer filter for currently selected objects in layer properties palette
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2010-06-09, 01:16 PM
  2. How do I change Layer properties in a script
    By Gary.182361 in forum AutoCAD General
    Replies: 7
    Last Post: 2010-01-26, 06:00 PM
  3. View/Change Properties in Layer Properties Window
    By mlongfellow in forum AutoCAD General
    Replies: 2
    Last Post: 2007-12-28, 03:37 PM
  4. Change display of layer without changing layer properties
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2006-09-11, 02:33 PM
  5. Replies: 2
    Last Post: 2006-03-29, 03:42 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
  •