PDA

View Full Version : Place questions within a Dialog Box



Lions60
2006-12-04, 09:01 PM
I have some code with user input that shows up at the command line. I would like to take the questions that are being asked and put them in a dialogue box that will pop up. After the information has been put into the dialogue box the info gets stored back to the variables i have designated and the program completes its run.



(defun dtr (a)
(* pi (/ a 180.00))
)
(defun rtd (a)
(/ (* a 180.00) pi)
)

(defun C:CV()
(setq old_osnap (getvar "osmode"))
(setvar "osmode" 0)
(setq height (getreal "\nEnter Height of Unit Less base: "))
(setq Leng (getreal "\nEnter Length of Unit: "))
(setq width (getreal "\nEnter Width of Unit: "))
(setq base (getreal "\nEnter Base Rail Height: "))

;; call out main program
(blayout)
(setvar "osmode" old_osnap)
)

(defun blayout ()
(setq pnt1 (getpoint "\nSelect placement of lower left hand corner of AHU: "))
(setq pnt2 (polar pnt1 (dtr 0)leng))
(setq pnt3 (polar pnt2 (dtr 90)height))
(setq pnt4 (polar pnt3 (dtr 180) leng))
(setq pnt5 (polar pnt4 (dtr -90)height))
(command "line" pnt1 pnt2 pnt3 pnt4 pnt5 "")

;; Drawing base rail

(setq pnt6 (polar pnt1 (dtr -90) Base))
(setq pnt7 (polar pnt6 (dtr 0) leng))
(setq pnt8 (polar pnt7 (dtr 90) base))

(command "line" pnt1 pnt6 pnt7 pnt8"")
(tlayout)
);; end of blayout

(defun tlayout ()
;; Drawing Top view

(setq tpnt1 (polar pnt4 (dtr 90) 60))
(setq tpnt2 (polar tpnt1 (dtr 0) leng))
(setq tpnt3 (polar tpnt2 (dtr 90) width))
(setq tpnt4 (polar tpnt3 (dtr 180) leng))
(setq tpnt5 (polar tpnt4 (dtr -90) width))

(command "line" tpnt1 tpnt2 tpnt3 tpnt4 tpnt5"")
(toffset)
);; end of tlayout

(defun toffset ()

;; Drawing offset top

(setq toffset1(list (+(car tpnt4)2) (- (cadr tpnt4) 2)))
(setq toffset2(list (-(car tpnt3)2) (- (cadr tpnt3) 2)))
(setq toffset3(list (-(car tpnt2)2) (+ (cadr tpnt2) 2)))
(setq toffset4(list (+(car tpnt1)2) (+ (cadr tpnt1) 2)))

(setq toffset5(list (+(car tpnt4)2) (cadr tpnt4)))
(setq toffset6(list (-(car tpnt3)2) (cadr tpnt3)))
(setq toffset7(list (-(car tpnt2)2) (cadr tpnt2)))
(setq toffset8(list (+(car tpnt1)2) (cadr tpnt1)))

(command "line" toffset8 toffset5"")(command "line" toffset7 toffset6"")
(command "line" toffset1 toffset2"")(command "line" toffset3 toffset4"")
(boffset)
);; end of toffset

(defun boffset ()
;; Drawing offset bottom

(setq offset1(list (car pnt4) (- (cadr pnt4) 2.25)))
(setq offset2(list (car pnt3) (- (cadr pnt3) 2.25)))

(setq offset3(list (+(car pnt4) 2) (- (cadr pnt4) 2.25)))
(setq offset4(list (- (car pnt3) 2) (-(cadr pnt3) 2.25)))
(setq offset5(list (- (car pnt2) 2) (cadr pnt2)))
(setq offset6(list (+(car pnt1) 2) (cadr pnt1)))


(command "line" offset1 offset2"")(command "line" offset6 offset3"")(command "line" offset5 offset4"")
(modules)
)
(defun modules ()
(if (tblsearch "layer" "Construction")
(command "-layer" "s" "Construction")
(command "-layer" "m" "Construction" "c" "red" "Construction" "")
);;end of if
(while (< (car offset6) (car pnt2))
(setq mod(getreal "\nEnter Module length"))
(setq pnt2 (polar pnt2 (dtr 180)mod))
(setq pnt3 (polar pnt3 (dtr 180)mod))
(command "Xline" pnt2 pnt3 "")
(setq ent1 (ssget "X" '((0 . "XLINE"))))
(command "_.chprop" ent1 "" "la" "Construction" "")
);; end of while
(la)
)
(defun la()
(command "clayer" "0" "")
)

madcadder
2006-12-04, 09:18 PM
I have one at home that would be a perfect example for you.

I started writing this for a company a while back and moved before they were ever approved.

This takes the info from a dialog and draws out a part.

It has an "X" toggle switch for control of which of two parts to draw.
"grey out" lines that are not needed.
etc.

Will pop it onto the flash drive tonight and bring it in tomorrow.

Adesu
2006-12-05, 12:51 AM
Hi Lions,
here your code after I revised,sorry if you find not yet perfect
LSP File


(defun dtr (a)
(* pi (/ a 180.00))
)
(defun rtd (a)
(/ (* a 180.00) pi)
)

(defun C:CV (/ ans base data_ba data_he data_le data_wi
dcl_id height leng old_osnap widtH)
(setq dcl_id (load_dialog "CV.DCL"))
(if
(not (new_dialog "cv" dcl_id))
(exit)
)
(set_tile "he" "10")
(set_tile "le" "20")
(set_tile "wi" "30")
(set_tile "ba" "40")
(mode_tile "he" 2)
(mode_tile "le" 2)
(mode_tile "wi" 2)
(mode_tile "ba" 2)
(action_tile "he" "(setq data_he (get_tile \"he\"))")
(action_tile "le" "(setq data_le (get_tile \"le\"))")
(action_tile "wi" "(setq data_wi (get_tile \"wi\"))")
(action_tile "ba" "(setq data_ba (get_tile \"ba\"))")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq ans (start_dialog))
(unload_dialog dcl_id)

(setq old_osnap (getvar "osmode"))
(setvar "osmode" 0)
(setq height (atoi data_he))
(setq Leng (atoi data_le))
(setq width (atoi data_wi))
(setq base (atoi data_ba))

;; call out main program
(blayout)
(setvar "osmode" old_osnap)
)

(defun blayout ()
(setq pnt1 (getpoint "\nSelect placement of lower left hand corner of AHU: "))
(setq pnt2 (polar pnt1 (dtr 0)leng))
(setq pnt3 (polar pnt2 (dtr 90)height))
(setq pnt4 (polar pnt3 (dtr 180) leng))
(setq pnt5 (polar pnt4 (dtr -90)height))
(command "line" pnt1 pnt2 pnt3 pnt4 pnt5 "")

;; Drawing base rail

(setq pnt6 (polar pnt1 (dtr -90) Base))
(setq pnt7 (polar pnt6 (dtr 0) leng))
(setq pnt8 (polar pnt7 (dtr 90) base))
(command "line" pnt1 pnt6 pnt7 pnt8"")
(tlayout)
);; end of blayout

(defun tlayout ()
;; Drawing Top view

(setq tpnt1 (polar pnt4 (dtr 90) 60))
(setq tpnt2 (polar tpnt1 (dtr 0) leng))
(setq tpnt3 (polar tpnt2 (dtr 90) width))
(setq tpnt4 (polar tpnt3 (dtr 180) leng))
(setq tpnt5 (polar tpnt4 (dtr -90) width))
(command "line" tpnt1 tpnt2 tpnt3 tpnt4 tpnt5"")
(toffset)
);; end of tlayout

(defun toffset ()

;; Drawing offset top

(setq toffset1(list (+(car tpnt4)2) (- (cadr tpnt4) 2)))
(setq toffset2(list (-(car tpnt3)2) (- (cadr tpnt3) 2)))
(setq toffset3(list (-(car tpnt2)2) (+ (cadr tpnt2) 2)))
(setq toffset4(list (+(car tpnt1)2) (+ (cadr tpnt1) 2)))
(setq toffset5(list (+(car tpnt4)2) (cadr tpnt4)))
(setq toffset6(list (-(car tpnt3)2) (cadr tpnt3)))
(setq toffset7(list (-(car tpnt2)2) (cadr tpnt2)))
(setq toffset8(list (+(car tpnt1)2) (cadr tpnt1)))
(command "line" toffset8 toffset5"")
(command "line" toffset7 toffset6"")
(command "line" toffset1 toffset2"")
(command "line" toffset3 toffset4"")
(boffset)
);; end of toffset

(defun boffset ()
;; Drawing offset bottom
(setq offset1(list (car pnt4) (- (cadr pnt4) 2.25)))
(setq offset2(list (car pnt3) (- (cadr pnt3) 2.25)))
(setq offset3(list (+(car pnt4) 2) (- (cadr pnt4) 2.25)))
(setq offset4(list (- (car pnt3) 2) (-(cadr pnt3) 2.25)))
(setq offset5(list (- (car pnt2) 2) (cadr pnt2)))
(setq offset6(list (+(car pnt1) 2) (cadr pnt1)))
(command "line" offset1 offset2"")
(command "line" offset6 offset3"")
(command "line" offset5 offset4"")
(modules)
)
(defun modules ()
(if
(tblsearch "layer" "Construction")
(command "-layer" "s" "Construction")
(command "-layer" "m" "Construction" "c" "red" "Construction" "")
);;end of if
(while
(< (car offset6) (car pnt2))
(setq mod(getreal "\nEnter Module length"))
(setq pnt2 (polar pnt2 (dtr 180)mod))
(setq pnt3 (polar pnt3 (dtr 180)mod))
(command "Xline" pnt2 pnt3 "")
(setq ent1 (ssget "X" '((0 . "XLINE"))))
(command "_.chprop" ent1 "" "la" "Construction" "")
);; end of while
(la)
)

(defun la()
(command "clayer" "0" "")
)


and this is DCL File


cv : dialog {label = "CV MANAGER";
: column {label = "Fill in data here";
: edit_box {label = "Height";
key = "he";}
: edit_box {label = "Length";
key = "le";}
: edit_box {label = "Width";
key = "wi";}
: edit_box {label = "Base";
key = "ba";}}
ok_cancel;}



I have some code with user input that shows up at the command line. I would like to take the questions that are being asked and put them in a dialogue box that will pop up. After the information has been put into the dialogue box the info gets stored back to the variables i have designated and the program completes its run.



(defun dtr (a)
(* pi (/ a 180.00))
)
(defun rtd (a)
(/ (* a 180.00) pi)
)

(defun C:CV()
(setq old_osnap (getvar "osmode"))
(setvar "osmode" 0)
(setq height (getreal "\nEnter Height of Unit Less base: "))
(setq Leng (getreal "\nEnter Length of Unit: "))
(setq width (getreal "\nEnter Width of Unit: "))
(setq base (getreal "\nEnter Base Rail Height: "))

;; call out main program
(blayout)
(setvar "osmode" old_osnap)
)

(defun blayout ()
(setq pnt1 (getpoint "\nSelect placement of lower left hand corner of AHU: "))
(setq pnt2 (polar pnt1 (dtr 0)leng))
(setq pnt3 (polar pnt2 (dtr 90)height))
(setq pnt4 (polar pnt3 (dtr 180) leng))
(setq pnt5 (polar pnt4 (dtr -90)height))
(command "line" pnt1 pnt2 pnt3 pnt4 pnt5 "")

;; Drawing base rail

(setq pnt6 (polar pnt1 (dtr -90) Base))
(setq pnt7 (polar pnt6 (dtr 0) leng))
(setq pnt8 (polar pnt7 (dtr 90) base))

(command "line" pnt1 pnt6 pnt7 pnt8"")
(tlayout)
);; end of blayout

(defun tlayout ()
;; Drawing Top view

(setq tpnt1 (polar pnt4 (dtr 90) 60))
(setq tpnt2 (polar tpnt1 (dtr 0) leng))
(setq tpnt3 (polar tpnt2 (dtr 90) width))
(setq tpnt4 (polar tpnt3 (dtr 180) leng))
(setq tpnt5 (polar tpnt4 (dtr -90) width))

(command "line" tpnt1 tpnt2 tpnt3 tpnt4 tpnt5"")
(toffset)
);; end of tlayout

(defun toffset ()

;; Drawing offset top

(setq toffset1(list (+(car tpnt4)2) (- (cadr tpnt4) 2)))
(setq toffset2(list (-(car tpnt3)2) (- (cadr tpnt3) 2)))
(setq toffset3(list (-(car tpnt2)2) (+ (cadr tpnt2) 2)))
(setq toffset4(list (+(car tpnt1)2) (+ (cadr tpnt1) 2)))

(setq toffset5(list (+(car tpnt4)2) (cadr tpnt4)))
(setq toffset6(list (-(car tpnt3)2) (cadr tpnt3)))
(setq toffset7(list (-(car tpnt2)2) (cadr tpnt2)))
(setq toffset8(list (+(car tpnt1)2) (cadr tpnt1)))

(command "line" toffset8 toffset5"")(command "line" toffset7 toffset6"")
(command "line" toffset1 toffset2"")(command "line" toffset3 toffset4"")
(boffset)
);; end of toffset

(defun boffset ()
;; Drawing offset bottom

(setq offset1(list (car pnt4) (- (cadr pnt4) 2.25)))
(setq offset2(list (car pnt3) (- (cadr pnt3) 2.25)))

(setq offset3(list (+(car pnt4) 2) (- (cadr pnt4) 2.25)))
(setq offset4(list (- (car pnt3) 2) (-(cadr pnt3) 2.25)))
(setq offset5(list (- (car pnt2) 2) (cadr pnt2)))
(setq offset6(list (+(car pnt1) 2) (cadr pnt1)))


(command "line" offset1 offset2"")(command "line" offset6 offset3"")(command "line" offset5 offset4"")
(modules)
)
(defun modules ()
(if (tblsearch "layer" "Construction")
(command "-layer" "s" "Construction")
(command "-layer" "m" "Construction" "c" "red" "Construction" "")
);;end of if
(while (< (car offset6) (car pnt2))
(setq mod(getreal "\nEnter Module length"))
(setq pnt2 (polar pnt2 (dtr 180)mod))
(setq pnt3 (polar pnt3 (dtr 180)mod))
(command "Xline" pnt2 pnt3 "")
(setq ent1 (ssget "X" '((0 . "XLINE"))))
(command "_.chprop" ent1 "" "la" "Construction" "")
);; end of while
(la)
)
(defun la()
(command "clayer" "0" "")
)

Lions60
2006-12-05, 01:07 PM
Thanks Adesu your code works great. I am also interested in seeing your program you wrote madcadder. Sounds very interesting.

madcadder
2006-12-05, 04:06 PM
I yanked out the guts and left you everything up through the dialog box. You don't need the actual drawing of the objects to get the point and it will make it easier to read.

Adesu
2006-12-05, 11:52 PM
You are welcome


Thanks Adesu your code works great. I am also interested in seeing
your program you wrote madcadder. Sounds very interesting.

madcadder
2006-12-06, 01:53 PM
my file didn't upload.

ok. round two.