lamensterms Posted October 11, 2013 Posted October 11, 2013 Hi guys, I've got a routine which allows the user to select and object and perform a ProSteel command on every item on the layer of the object selected. For example, in a structural steel model, we have all our column members on a layer titled "COLUMN". The user will initiate the command, select 1 object (on the COLUMN layer) and the routine will hide everything except items on the COLUMN layer as well as any items grouped to any items on the column layer (ie. a column baseplate would be on a layer called "BASEPLATE" but so long as the baseplate is grouped to the column - it will not be hidden). The code is: (defun c:isl (/ x p CODE SS) (setq x (nentsel "\nSelect object whos layer is to be isolated: ")) (if (/= x nil) (progn (setq p (cdr (assoc 8(entget (car x))))) (setq CODE (setq ss (ssget "x" (list (cons CODE p)))) (command "PS_HIDE_EXCLUDE_GROUP" ss "") ) (prompt "\nNo object selected !!") ) (princ) ) At the moment the routine runs fine, but I would like to be able to select multiple items on multiple layers and have the list of layer from the selection set be passed to the "PS_HIDE_EXCLUDE" function. The part I am struggling with would be extracting a list of layers from a selection set "X", then passing that list to the "SS" SSGET. Just wondering if anyone could please help me achieve this. Thanks a lot for any help. Quote
BIGAL Posted October 11, 2013 Posted October 11, 2013 (edited) 1st question does Layiso not work ? Its in built. Pretty easy change your x line to a ssget with no filters this will allow multiple picking of objects=multi layers You need a Repeat or Foreach loop to go through the selection set X, using your current P code you need to add the layers together using Strcat to a new variable you also need them seperated by a comma eg (setq lay "layer1,layer2,alyer3) then (cons code lay ) all done Not tested (defun c:isl (/ x p CODE SS) (princ "\nSelect objects whos layer is to be isolated: ") (setq ss (ssget)) (if (/= ss nil) (progn (setq len (sslength x)) (setq num 0) (repeat len (setq p (cdr (assoc 8(entget (ssname ss num))))) (setq lay (strcat lay p )) (setq num (+ 1 num)) (if (/= num len) (setq lay (strcat lay ",")) ); end if ); end repeat (setq CODE (setq ss2 (ssget "x" (list (cons CODE lay)))) (command "PS_HIDE_EXCLUDE_GROUP" ss2 "") ); end progn (prompt "\nNo object selected !!") ) ; end if (setq ss nil ss2 nil) (princ) ) Edited October 14, 2013 by BIGAL Code updated Quote
lamensterms Posted October 11, 2013 Author Posted October 11, 2013 Gday BIGAL, Thanks a lot for the reply. The reason I would like to create a routine rather than use LAYISO is because the groups we use often contain elements of various layers. So when I am trying to isolate groups with element belonging to the COLUMN layer, I also want all other elements (which are grouped to the elements on the COLUMN layer) visible. I hope that makes sense. Thanks for the routine too.. I do get an error when trying to run it though " ; error: bad argument type: listp ". I had another error originally but I think that was due to trying to use a prompt with the SSGET function, so I have taken the prompt out, and now I get the message above. I did play around with trying to resolve this error, but I really am quite unfamiliar with LISTS and CDR, ASSOC, etc. So any further help is greatly appreciated. Thanks again. Quote
Lee Mac Posted October 11, 2013 Posted October 11, 2013 Here's another option: (defun c:isl ( / idx lay lst sel ) (if (setq sel (ssget)) (progn (repeat (setq idx (sslength sel)) (if (not (member (setq lay (cdr (assoc 8 (entget (ssname sel (setq idx (1- idx))))))) lst)) (setq lst (vl-list* "," lay lst)) ) ) (command "_.PS_HIDE_EXCLUDE_GROUP" (ssget "_X" (list (cons 8 (apply 'strcat (cdr lst))))) "") ) ) (princ) ) Quote
lamensterms Posted October 12, 2013 Author Posted October 12, 2013 Hi again BigAl and Lee, Thanks so much for the code help. I won't be able to test them out till I'm back at work, and I will certainly let you know how I go. Thanks again. Quote
lamensterms Posted October 13, 2013 Author Posted October 13, 2013 Hi BigAl and Lee, Just got into work a few minutes ago, and have now tested out both routines. BigAl - I was still getting a few errors while trying to run your revised code. I began trying to troubleshoot/debug the errors but had to stop because I was really only guessing about how to affectively modify it. Does anything stick out as to why the routine might return errors? First I got "malformed list" error, so I was able to add in a close bracket, but due to my inexperience with the REPEAT function... I couldn't be sure if I had put it in the correct location. Lee - Your code worked great, thanks a lot for taking the time to help. Thanks a again for the help guys, I really appreciate it. Quote
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.