I am using a Modal form and need to be able to pick an origin point from a command button.
I tried to use a modeless Dialog, but autolisp runs through the whole program without letting me set the variables first.
It uses the default settings only.
When I use the Modal Dialog, It works well until I want to pick an origin point from a command button.
I cant seem to go from Modal to Autocad and back again.
Is there any way to make the autolisp wait until the Modeless form is complete?
Hello,
you can find a solution here (http://www.opendcl.com/forum/index.php?topic=557.msg2519#msg2519) and in the samples folder.
Good luck!
Fred
I understand where you going with this, but is this for a Modal,Modeless or doesn't it matter?
Also, I can't seem to find this Samples folder. :-[
Ah, ok, the code in the link is not directly in the sample folder, but something similar. The code in the link is for modal forms, because your question was related to a modal form I think. Using modeless forms you can pick a point without closing the form (But maybe you want hide it meanwhile using hide method.).
In the sample folder you find the selections.lsp.
Fred
Writing a loop to show and re-show your dialog is only needed for modal dialogs. For modeless dialogs, there are other issues to deal with that make them much more complicated. The sample files are in a subfolder under the main OpenDCL Studio installation folder.
Sorry, I haven't read your last sentence correctly:
Search for c:\Program Files\OpenDCL\ENU\Samples. (If ENU is your language)
Fred
Thanks for quick responses!
Where is that Samples folder?
Have you found the smaples now?
Fred
Ok! Got it!
I thought it was on the web site somewhere!
Thanks for the help!
Hello again,
I managed to get the point from autocad and I it shows the form.
Now I can not get the textboxes that show the X: Y: Z: coordinated to update to the new values.
It almost seems like it does no initialize over again. Is that right?
(defun C:BillsShopDrawing (/)
(command "OPENDCL")
(setq Spot(list 0 0 0))
(setq lg 100)
(setq wd 96)
(setq ht 90)
(SETQ bflag T)
(WHILE bflag ; To fire it up
(SETQ bflag nil)
(dcl_Project_Load "BillsShopDrawing")
(dcl_Form_Show BillsShopDrawing_form1);jump to open form and set variables
(princ)
); end while
(setvar "osmode" 175)
(setvar "highlight" 1)
);end defun
(defun c:BillsShopDrawing_form1_OnInitialize (/ OrX OrY OrZ)
(setq OrX(car Spot))
(setq OrY(cadr Spot))
(setq OrZ(caddr Spot))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox1 (itoa lg))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox2 (itoa wd))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox3 (itoa ht))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox4 (itoa OrX))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox5 (itoa OrY))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox6 (itoa OrZ))
)
(defun c:BillsShopDrawing_form1_SetOrigin_OnClicked (/)
(SETQ bflag T)
(dcl_FORM_CLOSE BillsShopDrawing_form1)
(SETVAR "BLIPMODE" 1)
(SETQ Spot(GETPOINT "\nSelect point: "))
(SETVAR "BLIPMODE" 0)
(VL-CMDF "REDRAW")
)
Try putting the form_close at the end of your OnClicked function. I think you want to (setq SPOT...) *before* you close and reshow the form.
If I place the form close after the getpoint command, It will not allow me to pick a point in space.
This is a modal form. You either have to be in the form or in autocad.
Hello william17051,
try this code, it should work.
(defun C:BillsShopDrawing (/)
(command "OPENDCL")
(dcl_Project_Load "BillsShopDrawing") ; load it just only one time
(setq Spot(list 0 0 0))
(setq lg 100)
(setq wd 96)
(setq ht 90)
(SETQ bflag T)
(WHILE bflag ; To fire it up
(SETQ bflag nil)
(setq intResult (dcl_Form_Show BillsShopDrawing_form1)) ; jump to open form and set variables
(cond
((= intResult 3)
(SETVAR "BLIPMODE" 1)
(SETQ Spot(GETPOINT "\nSelect point: "))
(SETVAR "BLIPMODE" 0)
(VL-CMDF "REDRAW")
(SETQ bflag T))
); cond
); end while
(setvar "osmode" 175)
(setvar "highlight" 1)
);end defun
(defun c:BillsShopDrawing_form1_OnInitialize (/ OrX OrY OrZ)
(setq OrX(car Spot))
(setq OrY(cadr Spot))
(setq OrZ(caddr Spot))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox1 (itoa lg))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox2 (itoa wd))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox3 (itoa ht))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox4 (itoa OrX))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox5 (itoa OrY))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox6 (itoa OrZ))
); c:BillsShopDrawing_form1_OnInitialize
(defun c:BillsShopDrawing_form1_SetOrigin_OnClicked (/)
(dcl_FORM_CLOSE BillsShopDrawing_form1 3) ; the given argument will be the returning value of Form_Show method
); c:BillsShopDrawing_form1_SetOrigin_OnClicked
I suggest you to post code within the code-tag for better formatting.
Have a closer look to this posting (http://www.opendcl.com/forum/index.php?topic=557.msg2519#msg2519).
Fred
Sorry, you're right; the point acquisition should be inside the (while) loop that shows the form. I see Fred has fixed you up.
Ok, I like the way you set it up.
How do I get textbox 4,5,6 to update with the new x,y,z values?
Thanks for your patience by the way!
The form shows but the values are not updated after picking the point.
You've already done. Have a look into the OnInitialize-function. The OnInitialize event will be called when the form will be shown again. and there you wrote
(setq OrX(car Spot))
(setq OrY(cadr Spot))
(setq OrZ(caddr Spot))
and then
(dcl_Control_SetText BillsShopDrawing_form1_TextBox4 (itoa OrX))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox5 (itoa OrY))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox6 (itoa OrZ))
It should work.
Fred
Well it does not update. ???
It continues to to use the original 0,0,0.
I thought it would update as well.
I just noticed in the command prompt after the getpoint command it is giving me an error.
Command: _BillsShopDrawing
Select point: Program ERROR
Resetting environment ; error: An error has occurred inside the *error*
functionbad argument type: consp nil
1
Command: 'VLIDE
Command:
Im not sure why yet. :o
Hm, go far ahead from the ucs origin - itoa is given back a text from an integer. Try a (rtos OrX 2 4) instead.
I didn't check you code - I only moved som things.
I will take a closer look.
Fred
Thanks Fred,
Your help is greatly appreciated! ;)
Ahm, I cannot see any mistake at the code. Please be so kind to upload
a) the project file and
b) your *error* function
Fred
As far as an error code, Well I dont have one. :-\ What you have, I have.
Sort of a newbee here. Never really had an error function.
Here is the project file. And code.
(defun C:BillsShopDrawing (/)
(command "OPENDCL")
(dcl_Project_Load "BillsShopDrawing") ; load it just only one time
(setq Spot(list 1 1 1))
(setq lg 100)
(setq wd 96)
(setq ht 90)
(SETQ bflag T)
(WHILE bflag ; To fire it up
(SETQ bflag nil)
(setq intResult (dcl_Form_Show BillsShopDrawing_form1)) ; jump to open form and set variables
(cond
((= intResult 3)
(SETVAR "BLIPMODE" 1)
(SETQ Spot(GETPOINT "\nSelect point: "))
(SETVAR "BLIPMODE" 0)
(VL-CMDF "._REDRAW")
(SETQ bflag T))
); cond
); end while
(setvar "osmode" 175)
(setvar "highlight" 1)
);end defun
(defun c:BillsShopDrawing_form1_OnInitialize (/ OrX OrY OrZ)
(setq OrX(car Spot))
(setq OrY(cadr Spot))
(setq OrZ(caddr Spot))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox1 (itoa lg))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox2 (itoa wd))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox3 (itoa ht))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox4 (rtos OrX 2 4))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox5 (rtos OrY 2 4))
(dcl_Control_SetText BillsShopDrawing_form1_TextBox6 (rtos OrZ 2 4))
); c:BillsShopDrawing_form1_OnInitialize
(defun c:BillsShopDrawing_form1_SetOrigin_OnClicked (/)
(dcl_FORM_CLOSE BillsShopDrawing_form1 3) ; the given argument will be the returning value of Form_Show method
); c:BillsShopDrawing_form1_SetOrigin_OnClicked
Your text bozes contain an integer filter, so they are rejecting any setting that is not an integer. The (rtos) is resulting in a real number, which is rejected. Try changing the third argument to (rtos) from a 4 to zero, then it should work.
You guys are awsome ;D!
Works great!
Thanks for all the help!
Bill