GregGleason Posted November 13, 2017 Share Posted November 13, 2017 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? ; 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 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 13, 2017 Share Posted November 13, 2017 You need to use group code 8 for the layer name filter: (setq ss1 (ssget "_C" '(0.625 1.95) '(7.15 10.45) '((0 . "insert") (8 . "FTG-IsoCont")))) Quote Link to comment Share on other sites More sharing options...
GregGleason Posted November 13, 2017 Author Share Posted November 13, 2017 You need to use group code 8 for the layer name filter: (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 Quote Link to comment Share on other sites More sharing options...
GregGleason Posted November 13, 2017 Author Share Posted November 13, 2017 You need to use group code 8 for the layer name filter: (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 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 13, 2017 Share Posted November 13, 2017 A test drawing would help. Quote Link to comment Share on other sites More sharing options...
GregGleason Posted November 13, 2017 Author Share Posted November 13, 2017 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 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 13, 2017 Share Posted November 13, 2017 Read your post a bit closer, if you want to select items on layer 0 using ssget, use this instead. (setq ss1 (ssget "_C" '(0.625 1.95) '(7.15 10.45) '([b](8 . "0")[/b]))) No need to turn off layers .. that's part of the beauty of ssget filters. Quote Link to comment Share on other sites More sharing options...
GregGleason Posted November 13, 2017 Author Share Posted November 13, 2017 Read your post a bit closer, if you want to select items on layer 0 using ssget, use this instead. (setq ss1 (ssget "_C" '(0.625 1.95) '(7.15 10.45) '([b](8 . "0")[/b]))) 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 Test.Object.DWG Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 14, 2017 Share Posted November 14, 2017 (edited) 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. ; 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" "") ) Edited November 14, 2017 by BIGAL Quote Link to comment Share on other sites More sharing options...
GregGleason Posted November 14, 2017 Author Share Posted November 14, 2017 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. ; 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 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 14, 2017 Share Posted November 14, 2017 Here's how I'd approach this with the example provided. (defun c:foo (/ s) (if (setq s (ssget "_x" '((0 . "insert") (2 . "block##") (8 . "0")))) (foreach x (mapcar 'cadr (ssnamex s)) (entmod (append (entget x) '((8 . "FTG-IsoCont"))))) (print "No Objects Found...") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
GregGleason Posted November 14, 2017 Author Share Posted November 14, 2017 Here's how I'd approach this with the example provided. (defun c:foo (/ s) (if (setq s (ssget "_x" '((0 . "insert") (2 . "block##") (8 . "0")))) (foreach x (mapcar 'cadr (ssnamex s)) (entmod (append (entget x) '((8 . "FTG-IsoCont"))))) (print "No Objects Found...") ) (princ) ) Thank you ronjonp! That worked! So I can learn, how is this different from the direction I went? Greg Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 14, 2017 Share Posted November 14, 2017 Greg, The code is not reliant on coordinates to select these objects and no command calls. Be aware that if any other blocks are on layer 0, their layer will be changed as well. How did this issue arise? Your example drawing looks like it was generated by some sort of software package. Quote Link to comment Share on other sites More sharing options...
GregGleason Posted November 15, 2017 Author Share Posted November 15, 2017 Greg, The code is not reliant on coordinates to select these objects and no command calls. Be aware that if any other blocks are on layer 0, their layer will be changed as well. How did this issue arise? Your example drawing looks like it was generated by some sort of software package. Yes, the drawing was generated by another software package. Some of which we can control before creation, but some has to be dealt with after the fact. Greg Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.