+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2015
    Join Date
    Nov 2017
    Posts
    10

    Default Find a Block and Send it to Another Layer

    Registered forum members do not see this ad.

    I am trying to capture items on layer “0”. I first turn all layers off except “0”, but I don’t know how to code that yet so I did it manually. I am left with one object on that layer and it is a block. My goal is to window in on an area and capture the object and sent it to another layer (in this case, the layer name is “FTG-IsoCont”). I have run the following lisp and it is not able to find the block.

    Can someone suggest a fix?

    Code:
    ; Changes selected objects to Layer from Prompt
      ; Changes selected objects to Layer FTG-IsoCont
      (defun c:SetWinToLayerFTG-IsoCont ()
      (if (setq ss1 (ssget "_C" '(0.625 1.95) '(7.15 10.45) '((0 . "FTG-IsoCont"))))
      (command "change" ss1 "" "p" "la" "FTG-IsoCont" "")
      (alert "No Objects Found")
      );; End of if
      (princ)
        )
    Greg

  2. #2
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    530

    Default

    You need to use group code 8 for the layer name filter:
    Code:
    (setq ss1 (ssget "_C" '(0.625 1.95) '(7.15 10.45) '((0 . "insert") (8 . "FTG-IsoCont"))))

  3. #3
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2015
    Join Date
    Nov 2017
    Posts
    10

    Default

    Quote Originally Posted by ronjonp View Post
    You need to use group code 8 for the layer name filter:
    Code:
    (setq ss1 (ssget "_C" '(0.625 1.95) '(7.15 10.45) '((0 . "insert") (8 . "FTG-IsoCont"))))
    thank you for the code snippet.

    But sadly it didn't work.

    Below is an image and some attribute data of the block.





    Greg
    Attached Images

  4. #4
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2015
    Join Date
    Nov 2017
    Posts
    10

    Default

    Quote Originally Posted by ronjonp View Post
    You need to use group code 8 for the layer name filter:
    Code:
    (setq ss1 (ssget "_C" '(0.625 1.95) '(7.15 10.45) '((0 . "insert") (8 . "FTG-IsoCont"))))
    Thanks, but the code did not work.

    I tried running it more than once and then reloading, but it remained unmoved.

    Greg

  5. #5
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    530

    Default

    A test drawing would help.

  6. #6
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2015
    Join Date
    Nov 2017
    Posts
    10

    Default

    Quote Originally Posted by ronjonp View Post
    A test drawing would help.
    Can you PM me your email? I just joined the group today and I don't think I have the requisite number of posts yet to be somewhat vetted.

    Greg

  7. #7
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    530

    Default

    Read your post a bit closer, if you want to select items on layer 0 using ssget, use this instead.
    Code:
    (setq ss1 (ssget "_C" '(0.625 1.95) '(7.15 10.45) '((8 . "0"))))
    No need to turn off layers .. that's part of the beauty of ssget filters.

  8. #8
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2015
    Join Date
    Nov 2017
    Posts
    10

    Default

    Quote Originally Posted by ronjonp View Post
    Read your post a bit closer, if you want to select items on layer 0 using ssget, use this instead.
    Code:
    (setq ss1 (ssget "_C" '(0.625 1.95) '(7.15 10.45) '((8 . "0"))))
    No need to turn off layers .. that's part of the beauty of ssget filters.
    That one did not work either.

    I'm trying to upload a .dwg.

    Greg
    Attached Files

  9. #9
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,819

    Default

    Why would you not just do find all ? You can add (cons 2 Blkname) also. For me pick a block get all the stuff like name and layer then make the selection set.

    Code:
    ; Changes selected objects to Layer from Prompt
      ; Changes selected objects to Layer FTG-IsoCon
     
    (defun c:chglay-0 ( / obj ss lay blkname)
    (setq obj (vlax-ename->vla-object (car (entsel "\nPick "))))
    (setq lay (vla-get-layer obj))
    (if (= (vla-get-ObjectName obj) "AcDbBlockReference")
    (progn
    (setq blkname (vla-get-name obj))
    (setq ss (ssget "x" (list (cons 0 "insert")(cons 8 lay)(cons 2 blkname))))
    )
    (setq ss (ssget "x" (list (cons 0 "insert")(cons 8 lay))))
    )
    (command "CHprop" ss "" "la" "0" "")
    )
    Last edited by BIGAL; 14th Nov 2017 at 02:54 am.
    A man who never made mistakes never made anything

  10. #10
    Junior Member
    Discipline
    Mechanical
    Using
    AutoCAD 2015
    Join Date
    Nov 2017
    Posts
    10

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by BIGAL View Post
    Why would you not just do find all ? You can add (cons 2 Blkname) also. For me pick a block get all the stuff like name and layer then make the selection set.

    Code:
    ; Changes selected objects to Layer from Prompt
      ; Changes selected objects to Layer FTG-IsoCon
     
    (defun c:chglay-0 ( / obj ss lay blkname)
    (setq obj (vlax-ename->vla-object (car (entsel "\nPick "))))
    (setq lay (vla-get-layer obj))
    (if (= (vla-get-ObjectName obj) "AcDbBlockReference")
    (progn
    (setq blkname (vla-get-name obj))
    (setq ss (ssget "x" (list (cons 0 "insert")(cons 8 lay)(cons 2 blkname))))
    )
    (setq ss (ssget "x" (list (cons 0 "insert")(cons 8 lay))))
    )
    (command "CHprop" ss "" "la" "0" "")
    )
    BIGAL this does not work for me, at least as it is coded in this form. I need it to automatically capture objects in a certain sized window. The master plan is weaving this code into a larger routine, so that when the drawing is opened it is automatically cleaned up so that the user does not have to provide input.

    Maybe just a few lines need to be revised?

    Greg

Similar Threads

  1. How to find objects that are inside blocks on layers other than the block's layer?
    By ColinPearson in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 17th Jan 2016, 05:22 am
  2. send data to attributes inside a block
    By samifox in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 1st Jun 2014, 09:55 pm
  3. Send all objects on certain layer from paper space into model space.
    By gaddyzt in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 10th Apr 2014, 06:51 pm
  4. Find and/or Create a Layer using LISP
    By FindAPath in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 13th Jul 2006, 10:04 pm
  5. Trying to find a layer tool in 2007
    By palace-333 in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 24th May 2006, 02:42 pm

Bookmarks

Posting Permissions

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