Prompting with a Dynamic Options list

Prompting with a Dynamic Options list

eakos1
Advocate Advocate
1,319 Views
9 Replies
Message 1 of 10

Prompting with a Dynamic Options list

eakos1
Advocate
Advocate

I've made this code, this is at the beginning of my program. It works fine with typing the letters but with mouse clicking only the last one "S" letter is active - only this is blue. 

eakos1_0-1704837837424.png

 

Is it possible to make somehow all the letters available also for click on it ?

 

   (if (null global:min_r)
      (setq global:min_r 3.0)
   )
   (if (null global:delta_r)
      (setq global:delta_r 0.1)
   )
   (if (null global:width) ;; width of the changed ARCs in the polyline
      (setq global:width 0.25)
   )
   (if (null global:change_width)
      (setq global:change_width "Y")
   )
   (if (null global:side)
      (setq global:side 0.1)
   )
   (if (null global:mode)
      (setq global:mode 0) ;; 0=fillet, 1=left-right increase
   )

   (setq tmp (getstring	(strcat	"\nRAD_C_V04: [W]idth of the changed ARCs:<"
				(rtos global:width)
				"> "
				"[C]hange the width? Yes/No <"
				global:change_width
				"> "
				"[O]ption: 0:fillet - 1: left/right width increase <"
				(itoa global:mode)
				"> "
				"[M]inimum radius <"
				(rtos global:min_r)
				"> "
				"[D]elta radius <"
				(rtos global:delta_r)
				"> "
				"[S]ide distance of wave increase <"
				(rtos global:side)
				"> "
			) ;_ strcat

	     ) ;_ getstring
   ) ;_ setq

 

 

 

 

0 Likes
Accepted solutions (1)
1,320 Views
9 Replies
Replies (9)
Message 2 of 10

matt.worland
Advisor
Advisor

Have you looked into using getkword?

Something like this:

(initget 0 "Small Medium Large")
(setq strInput (cond ((getkword "\nSelect arrow size [Small/Medium/Large] <Medium>: ")) ("Medium")))
(cond	
	((= strInput "Small")
	 ;Do stuff for small
	)
	((= strInput "Medium")
	 ;Do stuff for medium
	)
	((= strInput "Large")
	 ;Do stuff for large
	)
)

 

If my reply was helpful, please give a "Thumbs Up" or "Accept as Solution"
0 Likes
Message 3 of 10

paullimapa
Mentor
Mentor

you have to use initget followed by getkword with certain formatting like this:

 

(setq stropt "Change Option Minimum Delta Side")
(setq selopt (vl-string-translate " " "/" stropt)) 
; converts to "Change/Option/Minimum/Delta/Side"
(progn(initget stropt)(getkword (strcat"\nSelect One [" selopt "]:")))
; Command prompt will show:
; Select One [Change/Option/Minimum/Delta/Side]:
; Now you can select an option

 

Also when you set dynmode to 1 or 3 during the getkword prompt when the cursor moves from the command prompt into the drawing area a cursor menu appears to choose from:

paullimapa_0-1704839318855.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 10

komondormrex
Mentor
Mentor
Accepted solution

maybe like this

(setq tmp (getstring	(strcat	"\nRAD_C_V04: [Width of the changed ARCs: <"
				(rtos global:width)
				"> /"
				"Change the width? Yes\\No <"
				global:change_width
				"> /"
				"Option: 0:fillet - 1: left\\right width increase <"
				(itoa global:mode)
				"> /"
				"Minimum radius <"
				(rtos global:min_r)
				"> /"
				"Delta radius <"
				(rtos global:delta_r)
				"> /"
				"Slide distance of wave increase <"
				(rtos global:side)
				"> ]"
			) ;_ strcat
	     ) ;_ getstring
   )
Message 5 of 10

ВeekeeCZ
Consultant
Consultant

I would mimic the current format. The first line is the current setting, the second one is the prompt for setting.

 

eekeeCZ_0-1704881668888.png

 

 

(defun c:test ()
  
  (or global:min_r 	(setq global:min_r 3.0))
  (or global:delta_r 	(setq global:delta_r 0.1))
  (or global:width 	(setq global:width 0.25));; positive=change, negavive=don't
  (or global:side	(setq global:side 0.1))
  (or global:mode	(setq global:mode 0)) ;; 0=fillet, 1=left-right increase

  
  (setq dz (getvar 'dimzin)) (setvar 'dimzin 8)
  (princ (strcat "\nCurrent settings: "
		 "Width = " (if (minusp global:width)
			      "don't change"
			      (strcat "change to " (rtos global:width)))
		 ", Mode = " (if (= 0 global:mode) "FILLET" "L-R INCREASE")
		 ", Minimum rad = " (rtos global:min_r)
		 ", Delta rad = " (rtos global:delta_r)
		 ", Slide dist = " (rtos global:side)))
  (setvar 'dimzin dz)

  
  (initget "Width mOde Minimum Delta Slide")
  (setq tmp (entsel "\nRAD_C_V04 Select first object or [Width/mOde/Minimum/Delta/Slide]: "))
  
  (princ)
  )

 

Message 6 of 10

eakos1
Advocate
Advocate

Many thanks! This is what I imagined 🙂

 

0 Likes
Message 7 of 10

eakos1
Advocate
Advocate

I think this will be the first part of my code.

I could never figure out the the whole text should be between square brackets [ ] and with / can be divided. 😀

 

  (or global:min_r 	  (setq global:min_r 3.0))
  (or global:delta_r 	  (setq global:delta_r 0.1))
  (or global:width 	  (setq global:width 0.25));; positive=change, negavive=don't
  (or global:change_width (setq global:change_width "Y")
  (or global:side	  (setq global:side 0.1))
  (or global:mode	  (setq global:mode 0)) ;; 0=fillet, 1=left-right increase

(setq tmp "x"); jut setup something value 
(while (/= tmp "")
(setq tmp (getstring (strcat "\nRAD_C_V04: [Width of the changed ARCs: <"
			     (rtos global:width)
			     "> /"
			     "Change the width? Yes\\No <"
			     global:change_width
			     "> /"
			     "Option: 0 = fillet or 1 = left\\right width increase <"
			     (itoa global:mode)
			     "> /"
			     "Minimum radius <"
			     (rtos global:min_r)
			     "> /"
			     "Delta radius <"
			     (rtos global:delta_r)
			     "> /"
			     "Slide distance of wave increase <"
			     (rtos global:side)
			     "> ]"
		     ) ;_ strcat
	  ) ;_ getstring
) ;_ setq

(cond
  ((= (strcase tmp) "W")
   (setq global:width
	  (cond	((getreal "\nGive the new width of changed ARCs: "))
		(1)
	  ) ;_ cond
   ) ;_ setq
  )
  ((= (strcase tmp) "M") (setq global:min_r (getreal "\nGive the new minimum radius: ")))
  ((= (strcase tmp) "D") (setq global:delta_r (getreal "\nGive the new delta radius: ")))
  ((= (strcase tmp) "S") (setq global:side (getreal "\nGive the side increase for waves: ")))
  ((= (strcase tmp) "C")
   (progn
     (initget "Y N")
     (setq global:change_width
	    (getkword (strcat "\nDo you want to increase the width of the changed ARCs [Y/N]: <"
			      global:change_width
			      ">"
		      ) ;_ strcat
	    ) ;_ getkword
     ) ;_ setq
   ) ;_ progn
  )
  ((= (strcase tmp) "O")
   (progn
     (initget "0 1")
     (setq global:mode
	    (atoi (getkword (strcat "\nChose one option 0:fillet 1:wave width increase [0/1]: <"
				    (itoa global:mode)
				    ">"
			    ) ;_ strcat
		  ) ;_ getkword
	    ) ;_ atoi
     ) ;_ setq
   ) ;_ progn
  )
) ;_ cond
)

 

0 Likes
Message 8 of 10

Sea-Haven
Mentor
Mentor

Another rather than initget, 

 

 

(if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already
(setq ans (ah:butts 1 "V"   '("Please select " "Width" "Node" "Min rad " "Delta rad" ))) ; ans holds the button picked value as a string

 

SeaHaven_0-1704937748718.png

 

 

0 Likes
Message 9 of 10

eakos1
Advocate
Advocate

 

Now I can create an "button" to change the fillet radius. Now if I dont push the button the program goes further. 

But if I click on it how can I handle it? Change the radius and ask again for the fist point. 

 

(setq r_original_fillet (getvar 'filletrad))
(if (not G:Fillet_rad)
  (setq G:Fillet_rad 2.5)
) ;_ if
(setvar 'filletrad G:Fillet_rad)

(initget "R_fillet")
(setq pts1 (getpoint (strcat "Select the 1st set of wave elements by a cross line or [R_fillet <" (rtos G:Fillet_rad)">]: ")))
(setq	pts2 (getpoint pts1 "2nd point of cross line: ")
	ss1 (ssget "F" (list pts1 pts2) '((0 . "LINE,*POLYLINE") (-4 . "<NOT") (70 . 1) (-4 . "NOT>")))
  ) ;_ end of setq

 

eakos1_0-1708761636694.png

 

 

0 Likes
Message 10 of 10

eakos1
Advocate
Advocate

In the main time I could figure it out.

 

  (while (not (listp pts1))
    (initget "R_fillet")
    (setq pts1 (getpoint (strcat "Select the 1st set of wave elements by a cross line or [R_fillet <"
				 (rtos G:Fillet_rad)
				 ">]: "
			 ) ;_ strcat
	       ) ;_ getpoint
    ) ;_ setq
    (if	(= pts1 "fillet")
	(progn
	  (setq G:Fillet_rad (getreal (strcat "Give the new fillet radius: <" (rtos G:Fillet_rad) ">")))
	  (setvar 'filletrad G:Fillet_rad)
	) ;_ progn
    ) ;_ if
  ) ;_ while

 

0 Likes