Picking origin point with modal form

Started by william17051, March 12, 2009, 05:31:12 AM

Previous topic - Next topic

william17051

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?

Fred Tomke

Hello,

you can find a solution here and in the samples folder.
Good luck!

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

william17051

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. :-[

Fred Tomke

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
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

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.

Fred Tomke

Sorry, I haven't read your last sentence correctly:

Search for c:\Program Files\OpenDCL\ENU\Samples. (If ENU is your language)

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

william17051

Thanks for quick responses!

Where is that Samples folder?

Fred Tomke

Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

william17051

Ok! Got it!
I thought it was on the web site somewhere!
Thanks for the help!

william17051

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")
 
    )

owenwengerd

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.

william17051

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.

Fred Tomke

#12
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.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

Sorry, you're right; the point acquisition should be inside the (while) loop that shows the form. I see Fred has fixed you up.

william17051

#14
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.