Jump to content

Prevent exiting the hatch command until something is picked or esc pressed


3dwannab

Recommended Posts

I have this to hatch and it works as I would like as it adds the hatches to the ssHatches selection set.

 

But I would like for the user to at least pick once or twice and for the return key not to exit this block of code.

 

I would like the escape key to only do that. 

 

(princ "Hatch area") 
(command "._bhatch")

;; Loop the hatch command until the user exits or returns out it
;; But I would like the escape key to only exit this and not the return key.

(setq ssHatches (ssadd)) ; creates a blank selection set
(while (> (getvar 'cmdactive) 0)
 (progn
   (command pause)
   (setq ssHatches (ssadd (entlast) ssHatches))
   )
 ) ; while end

;; Here it checks the lastprompt variable and if it finds:
;; Valid hatch boundary not found.
;; Then the program will exit.

(if (wcmatch (strcase (getvar 'lastprompt)) "*HATCH BOUNDARY NOT*")
  (progn
    (ACET-UI-MESSAGE "Valid hatch boundary not found. "
     "Exiting Program"
     (+ Acet:OK Acet:ICONWARNING)
     )
    (exit)
    )
  )

 

Edited by 3dwannab
Link to comment
Share on other sites

So is there more to this code?

Looking at it to see what it is doing, you create a blank selection set, then the 'while' since there is no command active, 'cmdactive = 0, is skipped, then you have your checking... so as it is as far as I can tell this snippet isn't doing an awful lot... so can you share a bit more?

  • Agree 1
Link to comment
Share on other sites

Basically if you run the code you get a picker for the hatch which if you pick its okay. I was looking for a way to prevent it exiting the command with a right click or return until the user clicks at least once or twice. 

Link to comment
Share on other sites

Anyway... is this what you were looking to do with the first part?

 

  (setq ssHatches (ssadd)) ; creates a blank selection set
  (While (setq MyHatch (entsel))
    (setq ssHatches (ssadd (car MyHatch) ssHatches))
  )

 

Link to comment
Share on other sites

No, not quite. I don't want to entsel any hatch. The code I have is what I wanted to do. 

 

Basically I want to enter the hatch command with continuous picking of an area but I want to at least ask for one pick at least and for that command not to exit after one right click.

 

Opps! I missed a line of code. I'll edit the original post. 

Edited by 3dwannab
Link to comment
Share on other sites

That part works. Its getting it to not exit the picking of the area if the user presses enter I want to get added to it.

 

This will prevent the user from accidently skipping this step.

Edited by 3dwannab
Link to comment
Share on other sites

Got it working how I want it with this. A slight modification of your code here.

 

It doesn't skip the hatching process until at least one pick has been made. 🙃

 

;; Click the internal area for the hatching
;; (command "_.bhatch") ; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/hatching-by-lisp/m-p/5923832/highlight/true#M336978
;; Loop the hatch command until the user exits or returns out it

(setq ssHatches (ssadd)) ; Create empty selection set

(setq loopForPickHatch "loop") ; Marker to whether to loop again or end the loop
(while (= "loop" loopForPickHatch ) ; Loop if loop marker says 'loop'
 (progn
  (setq ptHatch (getpoint "\nPick an area to hatch (Press ESC cancel) : "))
  )
 (if (/= ptHatch nil)
   (progn ; Do this loop
    (command "._bhatch" ptHatch)

    (while (> (getvar 'cmdactive) 0)
     (progn
       (command pause)
       (setq ssHatches (ssadd (entlast) ssHatches))
       )
     )

    (setq loopForPickHatch "StopLoop") ; If no point is selected (enter or space pressed)
    (setq ptHatch nil) ; Might not be needed, but why not have this
    (setq ssHatches (ssadd (entlast) ssHatches)) ; Add hatch to selection
    )
   )
 ) ; End while loopForPickHatch

 

 

 

Edited by 3dwannab
Link to comment
Share on other sites

Finally finished the routine.

 

I've posted the full thing here for getting the areas with various options here.

 

Thanks for your help Steven earlier in helping me get this to work.

 

 

Edited by 3dwannab
Link to comment
Share on other sites

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