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

Thread: changing multiple blocks to "0" layer

  1. #11
    Member
    Join Date
    2017-10
    Posts
    3
    Login to Give a bone
    0

    Default Re: changing multiple blocks to "0" layer

    Thank you.
    I have a sprinkler block. There's about a hundred of them.
    I have selected them and turned them into a single block.
    If I use the lisp you provided on this single large block, it will turn each of the sprinkler blocks into layer 0 WITHIN the sprinkler block, but the block itself won't be changed to layer 0.
    Is there a way to change the layer the block is in to layer 0 too?
    I have to open block editor to move the sprinklers over to layer 0 manually.
    Thank you.

  2. #12
    Mod / Salary / SM Wanderer's Avatar
    Join Date
    2001-12
    Location
    St. Louis
    Posts
    5,407
    Login to Give a bone
    0

    Default Re: changing multiple blocks to "0" layer

    Quote Originally Posted by pkim1230758226 View Post
    Basically I have 2 documents. One is XREF, and one is the main document.
    I want to transfer all blocks in XREF to layer "X", so that I can control the color of the layer X from the main document.
    Are you on 2016 or later? Could you not get the desired effect by setting VISRETAIN and XREFOVERRIDE from 0 to 1?
    Melanie Stone
    @MistresDorkness

    Archibus, FMS/FMInteract and AutoCAD Expert (I use BricsCAD, Revit, Tandem, and Planon, too)
    Technical Editor
    not all those who wander are lost

  3. #13
    Member
    Join Date
    2019-03
    Posts
    3
    Login to Give a bone
    0

    Default Re: changing multiple blocks to "0" layer

    Hello Tom,

    Please help me with your code. I am getting this error in my command line when i attempt to use the command:

    Command: FIXBLKS
    Select objects: 1 found
    Select objects: undo Current settings: Auto = On, Control = All, Combine = Yes, Layer = Yes
    Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: BEgin
    Command: ; error: no function definition: VLAX-ENAME->VLA-OBJECT

    - - - Updated - - -

    Quote Originally Posted by Tom Beauford View Post
    Here's one that will work on multiple blocks and sets to byblock. Which like Opie said gives you the same control of the inserted block as a regular object.
    Code:
    ; Written By: Tom Beauford
    ; Changes all block entities to layer "0" with color, linetype & lineweight ByBlock
    (defun C:FIXBLKS (/ SSET intCount ENAM ELST BNAM FLST FIX1)
      (defun FIX1 (BNAM / BENAM BONAM)
        (if (not (member BNAM FLST))
       (progn
         (setq FLST  (cons BNAM FLST)
         BENAM (tblobjname "block" BNAM)
         )
       (while (setq BENAM (entnext BENAM))
          (if (= (cdr (assoc 0 (entget BENAM))) "INSERT")
           (fix1 (cdr (assoc 2 (entget BENAM))))
           (progn
             (setq BONAM(vlax-ename->vla-object BENAM))
                    (vl-catch-all-apply 'vla-put-layer (list BONAM "0"))
                    (vl-catch-all-apply 'vla-put-color (list BONAM 0))
                    (vl-catch-all-apply 'vla-put-linetype (list BONAM "Byblock"))
                    (vl-catch-all-apply 'vla-put-Lineweight (list BONAM -2))
    ;                (vl-catch-all-apply 'vla-put-PlotStyleName (list BONAM "Byblock"))
           )
         )
       )
            )
        )
      )
      (setq SSET (ssget (list (cons 0 "INSERT"))))
      (vl-cmdf "undo" "BEgin")
      (repeat (setq intCount (sslength SSET))
        (setq intCount     (1- intCount)
              ENAM (ssname SSET intCOunt)
        ELST (entget ENAM)
        BNAM (cdr (assoc 2 ELST))
        FLST nil
        )
        (fix1 BNAM)
      )
      (vl-cmdf "undo" "End")
      (vl-cmdf "regen")
      (princ)
    )
    Hello Tom,

    Please help me with your code. I am getting this error in my command line when i attempt to use the command:

    Command: FIXBLKS
    Select objects: 1 found
    Select objects: undo Current settings: Auto = On, Control = All, Combine = Yes, Layer = Yes
    Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: BEgin
    Command: ; error: no function definition: VLAX-ENAME->VLA-OBJECT

    I have attached the .lsp i have created as well if you want to review it.
    Attached Files Attached Files

  4. #14
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: changing multiple blocks to "0" layer

    Quote Originally Posted by SHAREEF779910 View Post
    Hello Tom,

    Please help me with your code. I am getting this error in my command line when i attempt to use the command:

    Command: FIXBLKS
    Select objects: 1 found
    Select objects: undo Current settings: Auto = On, Control = All, Combine = Yes, Layer = Yes
    Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: BEgin
    Command: ; error: no function definition: VLAX-ENAME->VLA-OBJECT

    I have attached the .lsp i have created as well if you want to review it. [/COLOR]
    Add
    Code:
    (vl-load-com)
    as the first line of the code or add it as the first line in your acaddoc.lsp file. It loads the visual lisp interpreter, but only needs to be run once each time you open a drawing and since it's already in my acaddoc.lsp I don't need to add it to all my other lisp files. I've updated the lisp in my original post and recommend recopying it as your copy lost all the indentation and is hard to read. I keep the author, description, and a copy of the link where I found the code at the top of all the lisp I download for reference so if I ever have an issue in the future I know where to go for help.

  5. #15
    Member
    Join Date
    2019-03
    Posts
    3
    Login to Give a bone
    0

    Default Re: changing multiple blocks to "0" layer

    Greetings Tom,
    Thanks for the reply. Isn't the internet fascinating, We are reusing a post from 2011-02-21, 07:43 PM.

    I updated the routine to your new one and upon use got this message:
    <COPIED FROM MY COMMAND LINE>


    Command: APPLOAD
    FIXBLKS.lsp successfully loaded.
    Command: ; error: vl-load-com not supported on "Mac OS X Version 10.14 (x86_64)"

    As is noted i am working on a Mac OS. Clue to a solution ?
    This code is perfect so i want to be able to use it. It will accompany me throughout my life likely and i will certainly share it a several others. You will be doing a lot help

  6. #16
    Member
    Join Date
    2019-03
    Posts
    3
    Login to Give a bone
    0

    Default Re: changing multiple blocks to "0" layer

    Here is the case for you to be able to determine with accuracy if we can find a solutions with the LISP Routine Code:

    I work with several others on projects. Our office's layering structure gets messed up on account of all the manufacturers block we have to import that come in with their layers + layers and blocks others use when they edits the model. I want to solve this problem once and for all for myself and everyone else here so i appreciate your help.

    I tried LAYMERG and it does work to an extent but creates other problems. Scenario:

    I have a block, dubbed [dubbed B1] that in its definition is on layer "X" and may also have a nested block [Dubbed B2] that is on another layer, lets say "Z". I want to merge layer "X" to layer "0".

    LAYMERGE does successfully merge layer "X" to layer "0" and deletes therein layer "X" from my drawing.

    The issue is LAYMERGE leaves B1 that was defined to layer "X" now undefined + the nested B2 that was defined to layer "Z" unchanged and still define to layer "Z".

    I end up with no layer "X", which is a win. But then have to go into B1 to change its undefined layer to layer "0" and then while in B1 go into B2 that is nested in B1 to changes its layer to "0" as well. Which required time and defeats the purpose of what i want to do. [Note not all block i deal with have nested blocks, this is is the full scenario]

    I am trying to find a LISP routine or a way to quickly change the layers defined in a block's definition, including nested blocks if found, to layer "0".

  7. #17
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: changing multiple blocks to "0" layer

    Quote Originally Posted by SHAREEF779910 View Post
    Greetings Tom,
    Thanks for the reply. Isn't the internet fascinating, We are reusing a post from 2011-02-21, 07:43 PM.

    I updated the routine to your new one and upon use got this message:
    <COPIED FROM MY COMMAND LINE>


    Command: APPLOAD
    FIXBLKS.lsp successfully loaded.
    Command: ; error: vl-load-com not supported on "Mac OS X Version 10.14 (x86_64)"

    As is noted i am working on a Mac OS. Clue to a solution ?
    This code is perfect so i want to be able to use it. It will accompany me throughout my life likely and i will certainly share it a several others. You will be doing a lot help
    vl-load-com (AutoLISP/ActiveX)
    Loads the extended AutoLISP functions related to ActiveX support

    Supported Platforms: Windows only

    I've no knowledge of using a MAC myself, but it doesn't seem to support ActiveX functions. Try removing the line
    Code:
    (vl-load-com)
    , reload the lisp and see if it works. If not have you tried the SetBylayer command? There are other lisp routines out there for doing this without ActiveX commands like http://www.cadtutor.net/forum/showth...l=1#post284839

  8. #18
    Member
    Join Date
    2018-04
    Posts
    3
    Login to Give a bone
    0

    Default Re: changing multiple blocks to "0" layer

    This routine is already fantastic and I would add additional functions if I could.
    1. Also set the transparency to ByBlock
    2. Turn ON the linetype generation for all possible elements inside the block
    3. Set the linetype scale of all the elements inside the block to a fixed amount (for example to 3)
    4. Set Scale Uniformly to NO
    5. Set Allow Exploding to Yes
    Are any of those option possible?
    Anyway, I am glad that I found this thread. This code is already very helpful for me. Thank you.

  9. #19
    Member
    Join Date
    2018-04
    Posts
    3
    Login to Give a bone
    0

    Default Re: changing multiple blocks to "0" layer

    Quote Originally Posted by jooogyerek766507 View Post
    This routine is already fantastic and I would add additional functions if I could.
    1. Also set the transparency to ByBlock
    2. Turn ON the linetype generation for all possible elements inside the block
    3. Set the linetype scale of all the elements inside the block to a fixed amount (for example to 3)
    4. Set Scale Uniformly to NO
    5. Set Allow Exploding to Yes
    Are any of those option possible?
    Anyway, I am glad that I found this thread. This code is already very helpful for me. Thank you.
    Quote Originally Posted by Tom Beauford View Post
    Here's one that will work on multiple blocks and sets to byblock. Which like Opie said gives you the same control of the inserted block as a regular object.
    Code:
    ; Written By: Tom Beauford
    ; Changes all block entities to layer "0" with color, linetype & lineweight ByBlock
    (vl-load-com)
    (defun C:FIXBLKS (/ SSET intCount ENAM ELST BNAM FLST FIX1)
      (defun FIX1 (BNAM / BENAM BONAM)
        (if (not (member BNAM FLST))
       (progn
         (setq FLST  (cons BNAM FLST)
         BENAM (tblobjname "block" BNAM)
         )
       (while (setq BENAM (entnext BENAM))
          (if (= (cdr (assoc 0 (entget BENAM))) "INSERT")
           (fix1 (cdr (assoc 2 (entget BENAM))))
           (progn
             (setq BONAM(vlax-ename->vla-object BENAM))
                    (vl-catch-all-apply 'vla-put-layer (list BONAM "0"))
                    (vl-catch-all-apply 'vla-put-color (list BONAM 0))
                    (vl-catch-all-apply 'vla-put-linetype (list BONAM "Byblock"))
                    (vl-catch-all-apply 'vla-put-Lineweight (list BONAM -2))
    ;                (vl-catch-all-apply 'vla-put-PlotStyleName (list BONAM "Byblock"))
           )
         )
       )
            )
        )
      )
      (setq SSET (ssget (list (cons 0 "INSERT"))))
      (vl-cmdf "undo" "BEgin")
      (repeat (setq intCount (sslength SSET))
        (setq intCount     (1- intCount)
              ENAM (ssname SSET intCOunt)
        ELST (entget ENAM)
        BNAM (cdr (assoc 2 ELST))
        FLST nil
        )
        (fix1 BNAM)
      )
      (vl-cmdf "undo" "End")
      (vl-cmdf "regen")
      (princ)
    )
    Sorry, I left out the quote.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Changing the "Line1", "Line2", etc headers in the Project description dialog box?
    By brynjolfur853743 in forum AutoCAD Electrical - General
    Replies: 1
    Last Post: 2013-04-15, 08:25 PM
  2. Replies: 0
    Last Post: 2012-06-06, 11:54 AM
  3. Replies: 0
    Last Post: 2011-03-15, 05:44 PM
  4. 2011: Selecting multiple objects defaulting to "by layer"
    By andrew.dickinson in forum AutoCAD General
    Replies: 2
    Last Post: 2010-10-05, 05:19 PM
  5. Replies: 10
    Last Post: 2010-03-11, 12:49 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
  •