maahee Posted 5 hours ago Posted 5 hours ago ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CASE 1 (setq ss (ssadd)) (if (not (ssmemb n ss)) (ssadd n ss) ;code );if ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CASE 2 (setq flag T) (while flag (setq obj (ssget "_:S")) (cond (obj ;CODE ) ;ar (t (princ "\nNo selection made.") (initget "X") (setq bm (strcase (getstring "\nEnter 'X' to exit or press Enter to continue [X]: " ) ) ) (if (= bm "X" ) (setq flag nil) ; Exit the loop if user types 'x' (princ "\nInvalid input. Please try again.") ) ;if ) ) );WHILE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CASE 1: If the dataset is large, it will slow down the process. alternatives or tricks. CASE 2: Press the Enter key once to continue the loop, and press it twice to exit. or Only the letter "x" and empty inputs are acceptable. Quote
maahee Posted 4 hours ago Author Posted 4 hours ago (edited) @mhupp Case 1: I want to reduce the time. I use the "not (ssmemb n ss)" function, but it takes a long time when the selection set is large. case 2: Press the Enter key once to continue the loop, and press it twice to exit. ( empty selection set handle) The above two cases do not relate to each other. Please Edited 4 hours ago by maahee Quote
mhupp Posted 3 hours ago Posted 3 hours ago I understand what your asking for in case1 case2. I am asking is why your using them. might be a better optimization in how your selecting things. just asking for a higher level of what your trying to do. Quote
Steven P Posted 1 hour ago Posted 1 hour ago (edited) Case 1: ssadd does a check if the entity exists in the set, you can change CASE 1 (setq ss (ssadd)) (if (not (ssmemb n ss)) (ssadd n ss) ;code );if to CASE 1 (ssadd n ss) ;code Often in code optimisation is rarely a single line that makes a difference... unless you are doing thousands of calculations, so here taking out an if statement won't do a lot. Most likely you have a loop within a loop that slows things - might be more efficient to look back at how you are selecting the entities and processing them before adding to the selection set. However don't just accept that, if you code will work without the line take out your if statement, and ssadd and you shouldn't really notice a big difference in speed Edited 1 hour ago by Steven P 1 Quote
Steven P Posted 1 hour ago Posted 1 hour ago Case 2: This nicest user friendly way I found.. is not the nicest user friendly way in programming - involves grread which the help suggests is rarely needed and for advanced users.... grread if the input is keyboard or mouse input. If keyboard check if it is enter, X, space or escape (enter, space, escape got to use character codes) else ignore text inputs. If mouse input check if they have selected an object or just clicking empty space However the help suggests doing this in other ways. For both cases, and MHUPPs question what is the goal you are wanting to achieve. 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.