Ament Posted June 11, 2018 Share Posted June 11, 2018 Hi everyone. I hope this time I hava an easy one: I want to ask the user to put in the name of a selection set during my lisp and call it later to highlight the elements inside. Unfortunately I'm not that sure how to get the user input into work. See code below: (setq ct -1) (setq ans (getstring "Please enter name of selection set. ")) (setq ans (read ans)) (repeat (sslength ans) (setq obX (ssname ans (setq ct (1+ ct)))) (redraw obX 3) ) The issue is that I can't transfer the string from user to a (not sure, but I guess I need) symbol. can someone give me a hint how to convert it. Best regards, Ament Quote Link to comment Share on other sites More sharing options...
rlx Posted June 11, 2018 Share Posted June 11, 2018 (set (read "A") 5) note difference between set and setq (princ a) -> 5 other symbol functions are vl-symbol-name & vl-symbol-value gr.Rlx Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted June 11, 2018 Share Posted June 11, 2018 (setq ans (getstring "\nSpecify name of sel. set : ")) ;;; you type selsetxxx (set (read ans) (ssget)) ;;; to select entities and store them in selsetxxx ;;; to highlight it (sssetfirst nil selsetxxx) ;;; or eventually if ans is not localized (sssetfirst nil (vl-symbol-value (read ans))) HTH., M.R. Quote Link to comment Share on other sites More sharing options...
Ament Posted June 11, 2018 Author Share Posted June 11, 2018 I checked it but if I'm not wrong it allows me to evaluate first argument too. But that won't work for me (I think). (I updated the code to be able to clarify it easier as I used the same variable several times) (defun c:MHI ( / ) (setq ct -1) (setq ans (getstring "Please enter name of selection set. ")) (setq hl (read ans)) (repeat (sslength hl) (setq obX (ssname hl (setq ct (1+ ct)))) (redraw obX 3) ) (princ) ) I have a selection set named tbe in my memory, so the user enters the name and I get the string "tbe" set as value for the variable ans Now I want to have the same entry's of the selection set tbe in a new set hl. (Edit) Or just use the answer ("tbe") in my colde instead of hl. But it went wrong because it is not expecting a string there. (Edit end) Maybe I just don't see the forrest for the trees.. Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted June 11, 2018 Share Posted June 11, 2018 Maybe : (setq hl (vl-symbol-value (read ans))) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 11, 2018 Share Posted June 11, 2018 (setq hl (eval (read ans))) Quote Link to comment Share on other sites More sharing options...
Ament Posted June 11, 2018 Author Share Posted June 11, 2018 Maybe : (setq hl (vl-symbol-value (read ans))) That's it.. Wasn't thinking far enough.. Thank you!! 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.