lamensterms Posted February 11, 2015 Share Posted February 11, 2015 Hi guys, I'm not even sure I am going about this the right way, but let me try to explain what I'm trying to achieve, and the method I am trying to achieve it. I have a ProSteel command (PS_CREATE_SPEZPART) that I would like to pass each element of a selection set to - one by one. From what I understand, this ProSteel command will accept selections in the form of ENTSEL, but not single item selection sets. So I had a thought to create a selection set, and cycle through it using the REPEAT & SSNAME functions. (defun c:tmi () (prompt "\nSelect item:") (setq ss (ssget)) (setq num (sslength ss)) (setq con 0) (repeat num (setq ent3A (ssname ss con)) (command "PS_CREATE_SPEZPART" ent3A nil) (setq con (1+ con)) ) ) ... which does not work. I think what I am struggling with is... SSNAME returns the name of an entity - rather than selects that entity. Is this correct or am I missing something? So my question is, is it possible to pass each element to this ProSteel command, in the same manner as ENTSEL would? Thanks a lot for any help. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 11, 2015 Share Posted February 11, 2015 Since entsel returns a list of two items (the selected entity and the center of the cursor pickbox), try something like the following: (defun c:tmi ( / num sel ) (prompt "\nSelect item: ") (if (setq sel (ssget)) (repeat (setq num (sslength sel)) (command "_.PS_CREATE_SPEZPART" (list (ssname sel (setq num (1- num))) '(0 0 0)) ) ) ) (princ) ) Depending on how the command operates, the point supplied with the entity may need to be located on or near to the object. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 11, 2015 Share Posted February 11, 2015 Check what you get with (Car (entsel)) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 11, 2015 Share Posted February 11, 2015 Lee snuck in while I fed the dog Quote Link to comment Share on other sites More sharing options...
lamensterms Posted February 11, 2015 Author Share Posted February 11, 2015 Hi Lee and BigAl, Thanks a lot for your help. You have, once again, nailed it. Lee - your routine works great, I have tested it on a few types and combinations of elements, and it has worked every time. To further my education though, could you please explain the logic/philosophy behind the "(1- num)". I understand it is being used to work through the selection set (being the index for SSNAME). I just can't get my head around "1-"... is it the same as "num - 1" (but in the correct syntax)? Haha, BigAl - Lee sure is quick, thanks for your suggestion. Quote Link to comment Share on other sites More sharing options...
Commandobill Posted February 11, 2015 Share Posted February 11, 2015 It's not actually Lee, he set up a lisp routine to answer questions for him. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 11, 2015 Share Posted February 11, 2015 Thanks a lot for your help. You have, once again, nailed it. Lee - your routine works great, I have tested it on a few types and combinations of elements, and it has worked every time. Excellent to hear! Thank you lamensterms To further my education though, could you please explain the logic/philosophy behind the "(1- num)". I understand it is being used to work through the selection set (being the index for SSNAME). I just can't get my head around "1-"... is it the same as "num - 1" (but in the correct syntax)? Exactly - The 1- & 1+ functions are just convenient & quick functions which simply increment or decrement a given numerical value by one: (1+ x) is the same as (+ x 1) (1- x) is the same as (- x 1) Therefore, my code is iterating over the selection set starting with the entity at the (sslength-1)th position and decrementing the index to zero (since selection set indexes are zero-based). For more information on this topic, you might find my tutorial on Selection Set Processing of interest. It's not actually Lee, he set up a lisp routine to answer questions for him. :lol: What can I say, LISP was originally intended for developing A.I. Quote Link to comment Share on other sites More sharing options...
lamensterms Posted February 17, 2015 Author Share Posted February 17, 2015 Awesome, thanks a lot for taking the time to explain, Lee. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 18, 2015 Share Posted February 18, 2015 Awesome, thanks a lot for taking the time to explain, Lee. You're welcome lamensterms! - Feel free to ask if you have any further questions. Lee 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.