View Full Version : looping and store user input??
d_m_hopper
2008-02-08, 07:59 PM
(initget 1 "3 4 5")
(setq numelevs (getint "\How many elevations are you planning for? <3,4,5>: "))
(cond
(
(equal numelevs 3)
(command
"_.insert" "*w:/blocks/elev/elevbdr3" "0,0" blscale "0"
)
)
(
(equal numelevs 4)
(command
"_.insert" "*w:/blocks/elev/elevbdr4" "0,0" blscale "0"
)
)
(
(equal numelevs 5)
(command
"_.insert" "*w:/blocks/elev/elevbdr5" "0,0" blscale "0"
)
)
)
)
)
;;;User input wall height
(setq wall_height (getdist "\nEnter Wall Height: "))
I have an elevation routine that I run at work, it asks the user a few questions...(How many elevations are you planning for?, and wall height) what I want to do but do not know how to do is make this loop thru as many times as specified by user. The wall height is stored, so I know it can be used again. But I don't know how to make it loop, based on number of planned elevations.
Currently when you input the # of elevations it inserts a block based on that number, then you select wall to elevate, insert elevation in space...routine done. You have rerun routine, enter wall height again then repeat, then repeat command until done.
I have attached routine, and will attach drawing if needed.
thanks
T.Willey
2008-02-08, 08:05 PM
Maybe something like
(while
(or
(initget 1 "3 4 5")
(setq numelevs (getint "\n How many elecations are you planning for [3/4/5]? "))
)
(command "_.insert" (strcat "*w:/blocks/elev/elevbdr" (itoa numelevs)) '(0. 0. 0.) blscale 0.0)
(if (not wall_height)
(setq wall_height (getdist "\n Enter wall height: "))
)
)
d_m_hopper
2008-02-08, 08:41 PM
Maybe something like
(while
(or
(initget 1 "3 4 5")
(setq numelevs (getint "\n How many elecations are you planning for [3/4/5]? "))
)
(command "_.insert" (strcat "*w:/blocks/elev/elevbdr" (itoa numelevs)) '(0. 0. 0.) blscale 0.0)
(if (not wall_height)
(setq wall_height (getdist "\n Enter wall height: "))
)
)
(command "_.insert" (strcat "*w:/blocks/elev/elevbdr" (itoa numelevs))
could you explain this line^^^ please
T.Willey
2008-02-08, 08:43 PM
(command "_.insert" (strcat "*w:/blocks/elev/elevbdr" (itoa numelevs))
could you explain this line^^^ please
Since the only difference in the block names to insert was the number at the end, I did it this way to make it simpler. What it does is allow you to enter an integer, and then convert the integer to a string to insert the correct block.
d_m_hopper
2008-02-08, 08:50 PM
Since the only difference in the block names to insert was the number at the end, I did it this way to make it simpler. What it does is allow you to enter an integer, and then convert the integer to a string to insert the correct block.
thank you for the education, had no idea what itoa did
T.Willey
2008-02-08, 08:52 PM
thank you for the education, had no idea what itoa did
You're welcome.
CAB2k
2008-02-09, 03:18 PM
I had another view on the request, perhaps I miss read it.
I thought the OP wanted to collect wall heights for each elevation.
So 3 elevations would need 3 wall heights.
(defun c:test ()
(initget 1 "3 4 5")
(setq numelevs (getint "\n How many elecations are you planning for [3/4/5]? "))
(command "_.insert"
(strcat "*w:/blocks/elev/elevbdr" (itoa numelevs)) '(0. 0. 0.) blscale 0.0)
;; get from user each wall height into a list '(8 10 8 12 ...)
(setq cnt 1)
(while (<= numelevs cnt)
(initget 7)
(setq temp (getdist (strcat "\n Enter wall height for elev #" (itoa cnt) " : ")))
(setq all_wall_heights (cons temp all_wall_heights))
(setq cnt (1+ cnt))
)
)
d_m_hopper
2008-02-13, 02:44 PM
I had another view on the request, perhaps I miss read it.
I thought the OP wanted to collect wall heights for each elevation.
So 3 elevations would need 3 wall heights.
(defun c:test ()
(initget 1 "3 4 5")
(setq numelevs (getint "\n How many elecations are you planning for [3/4/5]? "))
(command "_.insert"
(strcat "*w:/blocks/elev/elevbdr" (itoa numelevs)) '(0. 0. 0.) blscale 0.0)
;; get from user each wall height into a list '(8 10 8 12 ...)
(setq cnt 1)
(while (<= numelevs cnt)
(initget 7)
(setq temp (getdist (strcat "\n Enter wall height for elev #" (itoa cnt) " : ")))
(setq all_wall_heights (cons temp all_wall_heights))
(setq cnt (1+ cnt))
)
)
does not ask for wall height? I will continue to trouble shoot, thanks for help guys
CAB2k
2008-02-13, 03:49 PM
Sorry, misplaced the cnt var.
(defun c:test (/ numelevs cnt temp all_wall_heights)
(initget 1 "3 4 5")
(setq numelevs (getint "\n How many elecations are you planning for [3/4/5]? "))
;(command "_.insert"
; (strcat "*w:/blocks/elev/elevbdr" (itoa numelevs)) '(0. 0. 0.) blscale 0.0)
;; get from user each wall height into a list '(8 10 8 12 ...)
(setq cnt 1)
(while (<= cnt numelevs)
(initget 7)
(setq temp (getdist (strcat "\n Enter wall height for elev #" (itoa cnt) " : ")))
(setq all_wall_heights (cons temp all_wall_heights))
(setq cnt (1+ cnt))
)
)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.