Jump to content

dcl start up


aloy

Recommended Posts

Hi everyone,

I have problem in getting one dcl versions started in my drawing. The AfraLISP version starts very well when lsp function is run. However Terrycad version given below does not work well although a dialog is created when tested separately. It appears the terrycad version ultimately leads to better pixel control to give a better appearance. What can be the reason?. Here are the two files:

cl_settings : default_dcl_settings { audit_level = 3; }

//---------------------------------------------------------------------------------------------------------

// MyFirst

//---------------------------------------------------------------------------------------------------------

MyFirst : dialog {

label = " Hello World";

spacer;

: text {

label = "This is my first dialog.";

alignment = centered;

}

spacer;

ok_only;

}//MyFirst

 

(defun c:MyFirst (/ Dcl_Id%)

(princ "\nMyFirst")(princ)

; Load Dialog

(setq Dcl_Id% (load_dialog "MyFirst.dcl"))

(new_dialog "MyFirst" Dcl_Id%)

; Dialog Actions

(start_dialog)

; Unload Dialog

(unload_dialog Dcl_Id%)

(princ)

);defun c:MyFirst

 

Is there a way the dialog could made to appear after running the lisp?.

 

My ultimate aim is to give a better appearance to the dialog shown below:

 

Thanking in advance

 

 

 

 

Hi Aloy , right after you use start_dialog , you call (unload_dialog) so it terminates right after you start it. You have to add a action_tile for the ok button and unload it after the ok button is pressed

 

 

gr. Rlx

Link to comment
Share on other sites

  • Replies 151
  • Created
  • Last Reply

Top Posters In This Topic

  • aloy

    72

  • rlx

    67

  • Lee Mac

    6

  • stevesfr

    3

Top Posters In This Topic

Posted Images

right after you use start_dialog, you call (unload_dialog) so it terminates right after you start it. You have to add a action_tile for the ok button and unload it after the ok button is pressed

 

I must disagree: start_dialog will not terminate until the user closes the dialog via a done_dialog expression, the code is correct to place the unload_dialog expression after the start_dialog expression. action_tile expressions are not required for tiles for which the action is already predefined - consider the following simple example:

(defun c:test ( / *error* dch dcl des )

   (defun *error* ( m )
       (if (< 0 dch) (unload_dialog dch))
       (if (= 'file (type des)) (close des))
       (if (and (= 'str (type dcl)) (setq dcl (findfile dcl)))
           (vl-file-delete dcl)
       )
       (princ)
   )
   (if (and (setq dcl (vl-filename-mktemp "test.dcl"))
            (setq des (open dcl "w"))
            (write-line "test : dialog { label = \"Hello World!\"; spacer; : text { label = \"Hello World!\"; alignment = centered; } spacer; ok_only; }" des)
            (not (setq des (close des)))
            (< 0 (setq dch (load_dialog dcl)))
            (new_dialog "test" dch)
       )
       (start_dialog)
   )
   (*error* nil)
   (princ)
)

Link to comment
Share on other sites

I must disagree: start_dialog will not terminate until the user closes the dialog via a done_dialog expression, the code is correct to place the unload_dialog expression after the start_dialog expression. action_tile expressions are not required for tiles for which the action is already predefined - consider the following simple example:

(defun c:test ( / *error* dch dcl des )

   (defun *error* ( m )
       (if (< 0 dch) (unload_dialog dch))
       (if (= 'file (type des)) (close des))
       (if (and (= 'str (type dcl)) (setq dcl (findfile dcl)))
           (vl-file-delete dcl)
       )
       (princ)
   )
   (if (and (setq dcl (vl-filename-mktemp "test.dcl"))
            (setq des (open dcl "w"))
            (write-line "test : dialog { label = \"Hello World!\"; spacer; : text { label = \"Hello World!\"; alignment = centered; } spacer; ok_only; }" des)
            (not (setq des (close des)))
            (< 0 (setq dch (load_dialog dcl)))
            (new_dialog "test" dch)
       )
       (start_dialog)
   )
   (*error* nil)
   (princ)
)

 

 

my mistake , just never put it there myself.

 

 

btw aloy , loose the first line in your dcl file

 

 



//---------------------------------------------------------------------------------------------------------
// MyFirst
//---------------------------------------------------------------------------------------------------------
MyFirst : dialog {
 label = " Hello World";
 spacer;
 : text {
   label = "This is my first dialog.";
   alignment = centered;
 }
 spacer;
 ok_only;
}//MyFirst

 

 

I asume you don't try to save the dcl code and the lisp code in the same file! Save above code in myfirst.dcl and the lisp part in myfirst.lsp or whatever name you like

 

 

gr.Rlx

Link to comment
Share on other sites

Out of curiosity, how would you opt to write the code?

 

I would include it in the exit/ error handler (does that make me a bad person? ;-)

 

but I admit sometimes I don't border at all (ok,ok , I'm bad)

 

gr. Rlx

Link to comment
Share on other sites

rlx,

We are going round and round the mulberry tree. My dialog would not simply load. Can I know the exact code (lsp) to run the dialog in my first posting?.

 

Regards,

 

Aloy.

Link to comment
Share on other sites

I have the following dilemma:

 

When I load the dcl code:

 

test_dcl1

 
: dialog

{
label = "Test Dialog No 1";

: text
{
label = "This is a Test Message";
alignment = centered;
}

: button
{
key = "accept";
label = "Close";
is_default = true;
fixed_width = true;
alignment = centered;
}

}
//DCL CODING ENDS HERE

[b]with the following lisp:[/b]

(prompt "\nType TEST_DCL1 to run...")

(defun C:TEST_DCL1 ()

(setq dcl_id (load_dialog "test_dcl1.dcl"))

    (if (not (new_dialog "test_dcl1" dcl_id))
 (exit )
    );if

(action_tile "accept"
   "(done_dialog)"
);action_tile

(start_dialog)
(unload_dialog dcl_id)

(princ)

);defun
(princ)
;AUTOLISP CODING ENDS HERE

[b]it runs smoothly and generate the dialog.[/b]

However when I try to load the following dcl :

samp1 : dialog {				//dialog name
     label = "Structural Holes" ;		//give it a label

    ok_cancel ;				//predifined OK/Cancel
    					
    }						//end dialog

[b]with the following lisp:[/b]

(defun C:samp1 ()					;define function	
 
 (setq dcl_id (load_dialog "samp1.dcl"))		;load dialog

 (if (not (new_dialog "samp1" dcl_id)			;test for dialog

     );not

   (exit)						;exit if no dialog

 );if

    (action_tile
   "cancel"						;if cancel button pressed
   "(done_dialog) (setq userclick nil)"		;close dialog, set flag
   );action_tile

 (action_tile
   "accept"						;if O.K. pressed
   " (done_dialog)(setq userclick T))"		;close dialog, set flag
 );action tile

 (start_dialog)					;start dialog

 (unload_dialog dcl_id)				;unload

(princ)

);defun C:samp

(princ)

 

it gives me an error message. In all cases the files are in the desktop. What could be the reason?.

 

Thanks

Aloy

Edited by rkmcswain
added [CODE] tags
Link to comment
Share on other sites

I have the following dilemma:

 

When I load the dcl code:

 

test_dcl1

 

: dialog

 

{

label = "Test Dialog No 1";

 

: text

{

label = "This is a Test Message";

alignment = centered;

}

 

: button

{

key = "accept";

label = "Close";

is_default = true;

fixed_width = true;

alignment = centered;

}

 

}

//DCL CODING ENDS HERE

 

with the following lisp:

 

(prompt "\nType TEST_DCL1 to run...")

 

(defun C:TEST_DCL1 ()

 

(setq dcl_id (load_dialog "test_dcl1.dcl"))

 

(if (not (new_dialog "test_dcl1" dcl_id))

(exit )

);if

 

(action_tile "accept"

"(done_dialog)"

);action_tile

 

(start_dialog)

(unload_dialog dcl_id)

 

(princ)

 

);defun

(princ)

;AUTOLISP CODING ENDS HERE

 

it runs smoothly and generate the dialog.

 

However when I try to load the following dcl :

 

samp1 : dialog { //dialog name

label = "Structural Holes" ; //give it a label

 

ok_cancel ; //predifined OK/Cancel

 

} //end dialog

 

with the following lisp:

 

(defun C:samp1 () ;define function

 

(setq dcl_id (load_dialog "samp1.dcl")) ;load dialog

 

(if (not (new_dialog "samp1" dcl_id) ;test for dialog

 

);not

 

(exit) ;exit if no dialog

 

);if

 

(action_tile

"cancel" ;if cancel button pressed

"(done_dialog) (setq userclick nil)" ;close dialog, set flag

);action_tile

 

(action_tile

"accept" ;if O.K. pressed

" (done_dialog)(setq userclick T))" ;close dialog, set flag

);action tile

 

(start_dialog) ;start dialog

 

(unload_dialog dcl_id) ;unload

 

(princ)

 

);defun C:samp

 

(princ)

 

it gives me an error message. In all cases the files are in the desktop. What could be the reason?.

 

Thanks

Aloy

 

 

Hi Aloy,

 

 

Very little / no time today / this weekend but I think your own comment lines are in the way. Your dcl file gave me an error to until I lost all the comments and reduced it to : samp1 : dialog { label = "Structural Holes"; ok_cancel;}

 

 

read http://docs.autodesk.com/ACDMAC/2015/ENU/index.html?url=files/GUID-1A629E01-828D-402E-965F-DE76F1BF28AD.htm,topicNumber=d30e339314

 

 

Good luck

 

 

gr. Rlx.

Link to comment
Share on other sites

Hi Lee Mac,

Does the last three conditions of 'if' statement say: do not close des, load and lauch dcl even if dch is negative ?. I get the dialog with ok button after running your lisp. How to run lisp without the dcl being crated with it?.

 

Regards,

 

Aloy.

Link to comment
Share on other sites

I have the following dilemma:

 

When I load the dcl code:

 

test_dcl1

 

: dialog

 

{

label = "Test Dialog No 1";

 

: text

{

label = "This is a Test Message";

alignment = centered;

}

 

: button

{

key = "accept";

label = "Close";

is_default = true;

fixed_width = true;

alignment = centered;

}

 

}

//DCL CODING ENDS HERE

 

with the following lisp:

 

(prompt "\nType TEST_DCL1 to run...")

 

(defun C:TEST_DCL1 ()

 

(setq dcl_id (load_dialog "test_dcl1.dcl"))

 

(if (not (new_dialog "test_dcl1" dcl_id))

(exit )

);if

 

(action_tile "accept"

"(done_dialog)"

);action_tile

 

(start_dialog)

(unload_dialog dcl_id)

 

(princ)

 

);defun

(princ)

;AUTOLISP CODING ENDS HERE

 

it runs smoothly and generate the dialog.

 

However when I try to load the following dcl :

 

samp1 : dialog { //dialog name

label = "Structural Holes" ; //give it a label

 

ok_cancel ; //predifined OK/Cancel

 

} //end dialog

 

with the following lisp:

 

(defun C:samp1 () ;define function

 

(setq dcl_id (load_dialog "samp1.dcl")) ;load dialog

 

(if (not (new_dialog "samp1" dcl_id) ;test for dialog

 

);not

 

(exit) ;exit if no dialog

 

);if

 

(action_tile

"cancel" ;if cancel button pressed

"(done_dialog) (setq userclick nil)" ;close dialog, set flag

);action_tile

 

(action_tile

"accept" ;if O.K. pressed

" (done_dialog)(setq userclick T))" ;close dialog, set flag

);action tile

 

(start_dialog) ;start dialog

 

(unload_dialog dcl_id) ;unload

 

(princ)

 

);defun C:samp

 

(princ)

 

it gives me an error message. In all cases the files are in the desktop. What could be the reason?.

 

Thanks

Aloy

 

 

Buzzy week pff. Awel , in the case of your dialog not working , just curious , is your desktop path in the search path of autocad? You can check if your dialog is really loaded by checking (setq dcl_id (load_dialog "samp1.dcl")) and if dcl_id is -1 then your dialog is not in your searchpath. You can also try (findfile "sample1.dcl"). If this returns nil try saving your files , both lisp and dcl to a folder that is somewhere in your searchpath. You can check this with the options command , first tab , file support path... I really doubt your desktop is listed there. Try to make for example the folder c:/temp/lisp/ , put your files there and add this folder in the options dialog to the file support path.

 

gr. Rlx

Link to comment
Share on other sites

rlx,

Yes, that does the trick. You have saved me from a lot of trouble. I will now concentrate on the second issue, ie populating the edit boxes with the results.

Thanks very much.

Regards,

Aloy

Link to comment
Share on other sites

rlx,

Yes, that does the trick. You have saved me from a lot of trouble. I will now concentrate on the second issue, ie populating the edit boxes with the results.

Thanks very much.

Regards,

Aloy

 

 

you're most welcome. Don't know if you ever looked at the last dcl / lsp I uploaded , with the Aloy_Recalculate_dialog sub in it. There you would do your calculations and update all the edit boxes. But it's just an example of course.

 

 

Good luck with your app!

 

 

gr. Rlx

Link to comment
Share on other sites

rlx,

I am still working on it but slow due to pressure of other work. In the mean time how best to limit the return values to two decimal places and also make the results in edit boxes non editable?.

Pl have a look at the lisp given below in conjunction with aloy.dcl given by you:

aloy.lsp

Link to comment
Share on other sites

rlx,

I am still working on it but slow due to pressure of other work. In the mean time how best to limit the return values to two decimal places and also make the results in edit boxes non editable?.

Pl have a look at the lisp given below in conjunction with aloy.dcl given by you:

 

Hi Aloy,

 

To limit the decimals of your result your can use (rtos # 2 2) where # is your nummer and 2 is for decimal and the other 2 is the number of decimal places.

 

To disable and edit box for editing i've given an example in my last aloy lsp. The part of interest for you is

 

(defun aloy_init ()
 (princ "\nAloy")
 (setq Dcl_Id% (load_dialog "aloy.dcl"))
 (setq eb-list
    ( list "eb_pipesize" "eb_manning" "eb_flow" "eb_slope"
       "eb_depthofflow" "eb_centralangle" "eb_fullboreflow"
       "eb_fullborevel"

       "eb_radius" "eb_wetted_peri" "eb_hydra_rai" "eb_nn_full"
       "eb_cross_sect" "eb_pipe_full" "eb_ave_velocity"
       "eb_roughness"))
)

in the init part i make al list of all edit box names and in the init-dialog part i disable all edit boxes that are for output only

 

(defun aloy_init_dialog ()
 (mapcar '(lambda(x)
        (if (not (member x '("eb_pipesize" "eb_depthofflow"
                 "eb_manning" "eb_slope")))
          (mode_tile x 1))) eb-list)
 (foreach tile eb-list
   (set_tile tile "0")
 )
)

 

the part that does the job is (mode_tile tile 1)

 

Good luck with your app and your work

 

gr. Rlx

Link to comment
Share on other sites

Hi rlx,

It worked as it should after the correction of a couple of typos. Is there a way to give two different background colors to the edit boxes?. My attempt to find a solution failed.

 

Regards,

 

Aloy

Link to comment
Share on other sites

Hi Aloy, well the answer is yes and no. The no part is for the editboxes in general. for the yes part take a look at this

 

 



(defun c:coltest (/ dclp)
  (setq dclp (load_dialog "Cad-tutor-dcl-color.dcl"))
  (new_dialog "colortest" dclp)
  (set_tile "testimage" "123.45")
  (start_dialog)
  (unload_dialog dclp)
  (princ)
)

colortest : dialog {label = "Color test";
  : image { key = "testimage";
    width = 10;
    height = 1.28;
    fixed_width = true;
    fixed_height = true;
    aspect_ratio = 1;
    color = 1;
  }
  spacer;
  ok_only;
}

got the inspiration from TerryCad btw... as i see it , it's a one way road. You set the color and stick by it or you would have to modify your dialog on the run. Or , you would have to use vectors to write to the image. I have seen Lee Mac doing it , can't remember which program , but it's a hell of a lot effort. Maybe some users at this forum have a better idea?

 

 

 

 

 

gr. Rlx

colortest.jpg

Edited by rlx
Link to comment
Share on other sites

Hi rlx,

If it is difficult I wont attempt it. I actually wanted to give one color for the data and another for the results. It is already there anyway though not very prominent. As for the image I will get into it later as I intend giving a diagram giving description of all the parameter just like in the case of the free calculator which I gave in my earlier posting.

 

Thanks for the help.

Aloy

Link to comment
Share on other sites

Hi rlx,

If it is difficult I wont attempt it. I actually wanted to give one color for the data and another for the results. It is already there anyway though not very prominent. As for the image I will get into it later as I intend giving a diagram giving description of all the parameter just like in the case of the free calculator which I gave in my earlier posting.

 

Thanks for the help.

Aloy

 

 

Your quite welcom. Just for fun I updated previous routine to be able to show colors

 

 

(defun c:coltest (/ dclp inp)
  (setq inp 0 dclp (load_dialog "Cad-tutor-dcl-color.dcl"))
  (new_dialog "colortest" dclp)
  (init-dialog)
  (action_tile "eb_input" "(update_dialog $value)")
  (start_dialog)
  (unload_dialog dclp)
  (princ)
)
(defun init-dialog ()
 (cond
   ((= inp 0)(setimagecolor "testimage" -1))
   ((< inp 0)(setimagecolor "testimage" 1))
   ((equal inp 1)(setimagecolor "testimage" 2))
   ((and (> inp 1)(< inp 2))(setimagecolor "testimage" 3))
   ((> inp 2)(setimagecolor "testimage" 1))
   (t (setimagecolor "testimage" -1)))
 (set_tile "eb_input" (rtos inp))
 (set_tile "testimage" (rtos inp))
)
(defun setimagecolor (im col / x y)
 (setq x (dimx_tile im) y (dimy_tile im))
 (start_image im)(fill_image 0 0 x y col)(end_image))
(defun update_dialog (val / inp)
 (setq inp (atof val)) (init-dialog))

colortest : dialog {label = "Color test";
 spacer;
 : row {
   : edit_box {key = "eb_input";}
   : text { label = " -> ";}
   : image { key = "testimage"; width = 10; height = 1.28;
             fixed_width = true; fixed_height = true; aspect_ratio = 1;}
 }
  spacer;
  ok_only;
}

just example how to color your output.

 

 

 

 

 

gr. Rlx

colortest.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...