Jump to content

Recommended Posts

Posted
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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.

Posted

I'm not quite sure what your asking to optimize. 

Posted (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 by maahee
Posted

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. 

Posted (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 by Steven P
  • Agree 1
Posted

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. 

Posted (edited)
1 hour ago, Steven P said:

Case 2:

However the help suggests doing this in other ways.

 

Have a progress output to the bottom left for long process is always a good idea because people will cancel commands that they thing are hung.

https://www.cadtutor.net/forum/topic/75702-all-objects-inside-this-selection-want-to-send-layer-0/#findComment-598604

 

in the update loop if user hits esc exit lisp

Edited by mhupp

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...