Author Topic: Determine if Enter has been Pressed  (Read 2184 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1443
Determine if Enter has been Pressed
« on: August 28, 2015, 02:19:50 PM »
I am working on one of my LISP routines and I have a point where I let the user use a particular command. What I need to know is how do I determine if the user picked a point or not during the command.

Here is an examaple of what I am trying to do:
Code: [Select]
(if initcommandversion (initcommandversion 2))
(command "._revcloud" "_S" "_N" "_M" Pt1)
(while (= 1 (logand (getvar 'CMDACTIVE)))
(princ (strcat "\nSpecify next point [Undo] <Enter " ExTxt ">: "))
(command pause)
(setq ExTxt "or C to Finish")
);End While
;Below is what I do not know how to do:
;If enter was pressed, do this....
;If point was picked, do this.....
Please note the following restriction:
Cannot use an Visual Lisp (so, nothing that starts with VLA or VLAX) because it needs to be compatible with Windows and Mac.

ChrisCarlson

  • Guest
Re: Determine if Enter has been Pressed
« Reply #1 on: August 28, 2015, 02:45:39 PM »
Could do

Code - Auto/Visual Lisp: [Select]
  1. (if (not (getpoint (strcat "\nSpecify next point [Undo] <Enter " ExTxt ">: "))) (alert "User Hit Enter") (alert "User Clicked"))

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Determine if Enter has been Pressed
« Reply #2 on: August 28, 2015, 05:28:02 PM »
Could do

Code - Auto/Visual Lisp: [Select]
  1. (if (not (getpoint (strcat "\nSpecify next point [Undo] <Enter " ExTxt ">: "))) (alert "User Hit Enter") (alert "User Clicked"))
Unfortunately that doesn't work properly with the Revcloud; however, I have figured out how to get around it by creatively setting and using the LastPoint variable.

Code: [Select]
(defun c:rcloud (/ *ACAD_DOC* *ACAD_LAYERS* Pt1 Pt2 Pt3 Pt4 Pt444 ptTst pt2Tst ExTxt dLayer cLayer DScale StopLoop Obj Obj1 Obj2 Obj3 Obj4 LayTemp Ct tPt TptTst)
;*********************************************************************************************************
;** RCLOUD **
;** Written By: Chris Wade **
;** **
;** Version 4.0 **
;**   08-28-2015 **
;** **
;** - Completely rewritten **
;** - Made to be Mac compatible. **
;** - Code Simplified to be more reliable. **
;** **
;** Version 3.0 **
;** Alpha **
;**   06-12-2013 **
;** **
;** - Completely rewritten **
;** - Fixes bug when OSNAP was turned on that prevented delta insertion. **
;** - Layer change made more reliable, as changes are made as each item is created. **
;** - PLINE Width change moved to be just after cloud creation to be more reliable. **
;** **
;** **
;*********************************************************************************************************
(if (< (getvar "acadver") "20.1")
(alert "This version of RCLOUD only works in AutoCAD 2016 and newer.")
(progn
(setq tPt (list 0 0 0)
  tPtTst (osnap tPt "_NEA")
  Ct 0
)
(while tPtTst
(setq ct (- ct 1)
  tPt (list ct ct ct)
  tPtTst (osnap tPt "_NEA")
)
)
(setvar "lastpoint" tPt)
(defun set_Layers (/)
(setq dLayer (strcat "$DELTA-" BEI_RC_DELTA) ;Sets the delta layer
      cLayer (strcat "$CLOUD-" BEI_RC_DELTA) ;Sets the cloud layer
)
(if (not (tblsearch "LAYER" dLayer))
(progn
(if (= getvar "PSTYLEMODE" 0)
(command "._-layer" "_N" dlayer "_c" "7" dlayer "_pstyle" "BLACK" dlayer "")
(command "._-layer" "_N" dlayer "_c" "7" dlayer "" )
)
)
  )
  (if (not (tblsearch "LAYER" cLayer))
  (progn
(if (= getvar "PSTYLEMODE" 0)
(command "._-layer" "_N" clayer "_c" "8" clayer "_pstyle" "CLOUD" clayer "")
(command "._-layer" "_N" clayer "_c" "8" clayer "")
)
  )
)
)
(defun set_Delta ()
(while (not BEI_RC_DELTA)
(setq BEI_RC_DELTA (getstring "\rEnter Revision Number or Delta: "))
)
(set_Layers)
)
(defun change_Layer (Obj Lyr / Obj2)
(command "._chprop" Obj "" "_LA" Lyr "")
)
(defun insert_Delta (/ OS)
(setq OS (getvar "OSMODE"))
(setvar "OSMODE" 0)
(cond
((= Pt3 nil)
(cond
((and (= pt2 nil) (/= ptTst nil))
(setq Pt3 Pt1)
)
(T
(setq Pt3 (getpoint "\rSelect point to insert Delta symbol: "))
)
)
)
)
(setvar "attreq" 1)
(setvar "attdia" 0)
(command "._-insert" "BEIDelta-Rev5" Pt3 DScale DScale "0" BEI_RC_DELTA)
(change_Layer (entlast) dLayer)
(setvar "OSMODE" OS)
)
(defun draw_Cloud (/ Pt4 ArcSize Obj3)
(while (= StopLoop nil)

(cond
(Pt2

(setq ArcSize (* DScale 0.35))
(if initcommandversion (initcommandversion 2))
(command "._revcloud" "_S" "_N" "_A" ArcSize ArcSize "_R" Pt1 Pt2)
(setq Obj3 (entlast))
(setq Pt4 (getpoint Pt2 "\rSelect next point <Enter to finish>: "))
(cond
(Pt4
(if Obj3
(command "._erase" Obj3 "")
)
(if initcommandversion (initcommandversion 2))
(command "._revcloud" "_S" "_N" "_A" ArcSize ArcSize "_P" Pt1 Pt2 Pt4)
(while (= 1 (logand (getvar 'CMDACTIVE)))
(princ "\rSpecify next point [Undo] <Enter or C to Finish>: ")
(command pause)
)
)
)
(setq Obj3 (entlast))
(command "._pedit" Obj3 "C" "")
(command "._pedit" Obj3 "_width" (/ Dscale 48) "")
(change_Layer Obj3 cLayer)
(setq StopLoop T)
)
(T
(while (= Pt2 nil)
(setq Pt2 "Select next point: ")
)
)
)
)
)
(if (And (= (Getvar "Tilemode") 0) (= (Getvar "Cvport") 1))
  (Setq DScale 1.1)
  (Setq DScale (Getvar "Dimscale" ))
)
(set_delta)
(while (not Pt1)
(initget "Changedelta _Changedelta")
(setq Pt1 (getpoint (strcat "\rSelect first point (or point on object to insert Delta on) [Change Delta <" BEI_RC_DELTA ">]: ")))
(cond
((= Pt1 "Changedelta")
(setq Pt1 nil
      BEI_RC_DELTA nil)
(set_Delta)
)
)
)
(setq PtTst (nentselp "" pt1)
  ExTxt ""
)
(cond
(PtTst
(if (not (wcmatch (cdr (assoc 8 (entget (car PtTst)))) "$CLOUD-*"))
(setq PtTst nil
      Obj3 nil      
)
(progn
(setq ExTxt "to insert delta")
;Insert Delta or add to cloud
)
)
)
)
(while (not Pt2)
(if ptTst
(progn
(command "._pedit" PtTst "_width" "0" "")
(if initcommandversion (initcommandversion 2))
(command "._revcloud" "_S" "_N" "_M" Pt1)
(while (= 1 (logand (getvar 'CMDACTIVE)))
(princ (strcat "\nSpecify next point [Undo] <Enter " ExTxt ">: "))
(command pause)
(setq ExTxt "or C to Finish")
(setq Pt2 (getvar 'LastPoint))
(setq Pt2Tst (nentselp "" pt2))
(if Pt2Tst
(progn
(defun mid-pt (p1 p2);;Code by CAB
  (polar p1 (angle p1 p2) (/ (distance p1 p2) 2.) )
)
(setq Pt444 (mid-pt Pt1 Pt2))
(setq Pt4Tst (nentselp "" Pt444))
(while (not Pt4Tst)
(setq Pt4Tst (entsel "\nSelect side to trim: "))
(setq Pt444 (car Pt4Tst))
)
(if Pt444
(progn
(command Pt444 "_No")
(command "._pedit" Pt2Tst "_width" (/ Dscale 48) "")
(command "._draworder" pt2Tst "" "_Back")
)
)
)
(progn
(setq Pt3 Pt1)
(setq Pt2Tst (nentselp "" pt3))
(if Pt2Tst
(progn
(insert_delta)
(command "._pedit" Pt2Tst "_width" (/ Dscale 48) "")
(command "._draworder" pt2Tst "" "_Back")
)
)
)
)
)

)
(progn
(initget "Changedelta _Changedelta")
(setq Pt2 (getpoint Pt1 (strcat "\rSelect second point [Change Delta <" BEI_RC_DELTA ">]: ")))
(cond
((= Pt2 "Changedelta")
(setq Pt2 nil
      BEI_RC_DELTA nil)
(set_Delta)
)
((and (= Pt2 nil) (/= ptTst nil))
(insert_Delta)
(setq Pt2 T)
)
(T
(cond
(Pt2
(draw_Cloud)

(setq Pt3 (getpoint "\rSelect point to insert Delta symbol <Enter for none>: "))
(cond
(Pt3
(if (nentselp "" pt3)
(insert_Delta)
)
)
)
)
)
)
)
)
)
)
)
)
(princ)
)

Please let me know if you see any problems with this way of handling it.
« Last Edit: August 28, 2015, 07:02:35 PM by cmwade77 »

ChrisCarlson

  • Guest
Re: Determine if Enter has been Pressed
« Reply #3 on: August 31, 2015, 08:11:46 AM »
Completely crashes 2016, haven't narrowed it down but it locks up after selecting the second point

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Determine if Enter has been Pressed
« Reply #4 on: August 31, 2015, 11:59:36 AM »
Completely crashes 2016, haven't narrowed it down but it locks up after selecting the second point
That is very strange, it doesn't do that for me. I definitely would like to figure out why it is doing it for you, as it might do it for others.

ETA: I think I may know what the problem is. I didn't include the block that is needed, this should be put somewhere that is in your AutoCAD support paths.
« Last Edit: August 31, 2015, 04:24:26 PM by cmwade77 »