Jump to content

Need help with proper spacing in a dialog box


Recommended Posts

Posted

Hello!

 

I have a dialog box routine and I need help with the spacing of the items I have in it so that it would look nice and professional. It doesn't do anything yet, I'd like to get the spacing figured out first, seems like the more difficult part so far. I have attached a zip file that contains all the codes and image files, in case they are necessary, and an image of what the dialog box looks like currently.

 

Thank you for your time and attention, it is much appreciated!

 

Drafter_Joe

Dialog Box.PNG

SlideImage.zip

Posted

Every tile in a DCL dialog requires a certain amount of space. Tiles with longer labels require more horizontal space. On average the tiles in the top row of your dialog are wider making it the row that determines the total width of the dialog. In the bottom row there is horizontal room to spare and this is used to space the tiles further apart.

The only way to create proper vertical alignment is to supply both the width and the fixed_width attributes for most tiles and to base the width of each tile on the tile of the same type with the longest label.

 

  1. Keep in mind that a margin is added to the right of each label. This margin is ca. 30% of the width of the text. Choose short labels to avoid large margins.
  2. Try to use more descriptive keys. Something like "eb5" is not very clear, "circInCircDia1" is.
  3. I personally would get rid of the radio_buttons and turn the images into image_buttons instead. Or I would use 'radios' without labels.

Posted

how about :

 

 

 

 

 

(defun c:tst ( / box_type dcl-id)
 (setq box_type "rectangle" dcl-id (load_dialog "SlideImage.DCL"))
 (new_dialog "Main_Dialog" dcl-id)(update_dialog)
 (action_tile "rb_rectangle" "(setq box_type \"rectangle\")(update_Dialog)")
 (action_tile "rb_rounded" "(setq box_type \"rounded\")(update_Dialog)")
 (action_tile "rb_circle1" "(setq box_type \"circle1\")(update_Dialog)")
 (action_tile "rb_circle2" "(setq box_type \"circle2\")(update_Dialog)")
 (action_tile "accept" "(done_dialog 1)")
 (action_tile "accept" "(done_dialog 0)")
 (start_dialog)
 (unload_dialog dcl-id)
 (princ)
)
(defun update_dialog ( / x y slide)
 (cond
   ((= box_type "rectangle")(setq slide (findfile "test1.sld"))(set_tile "rb_rectangle" "1"))
   ((= box_type "rounded")  (setq slide (findfile "test2.sld"))(set_tile "rb_rounded" "1"))
   ((= box_type "circle1")  (setq slide (findfile "test3.sld"))(set_tile "rb_circle1" "1"))
   ((= box_type "circle2")  (setq slide (findfile "test4.sld"))(set_tile "rb_circle2" "1")))
 (setq x (dimx_tile "im_box_type") y (dimy_tile "im_box_type"))
 (start_image "im_box_type")
  (fill_image 0 0 x y -2);wipe
   (slide_image 0 -20 x y slide)
    (end_image)
)

Main_Dialog : dialog { label = "Slide from Image";
 : row {
   : boxed_radio_column {
     : radio_button { key = "rb_rectangle"; label = "Rectangle";}
     : radio_button { key = "rb_rounded"; label = "Rounded";}
     : radio_button { key = "rb_circle1"; label = "Circle1";}
     : radio_button { key = "rb_circle2"; label = "Circle2";}}
   : column {
     : image { key = "im_box_type"; width = 14; height = 10; color = -2;}
     : row {
       : edit_box { key = "eb_dia1"; label = "Dia.1";}
       : edit_box { key = "eb_dia2"; label = "Dia.2";}}
     : row {
       : edit_box { key = "eb_x"; label = " X  = ";}
       : edit_box { key = "eb_y"; label = " Y  = ";}}
   }
 }
 spacer;
 ok_cancel;
}

gr. Rlx

dialog.png

Posted

@ Rlx:

You are using spaces in the labels in an attempt to align edit_boxes. As you can see for yourself the vertical alignment is not perfect (and may vary depending on the font used for the labels). As explained in my previous post, setting both the width and the fixed_width attributes is the way to solve this.

Posted (edited)
@ Rlx:

You are using spaces in the labels in an attempt to align edit_boxes. As you can see for yourself the vertical alignment is not perfect (and may vary depending on the font used for the labels). As explained in my previous post, setting both the width and the fixed_width attributes is the way to solve this.

 

 

jip , I am aware of that , but because it is a very short label it's no big deal. To get it perfect you can create a row with 4 columns , first column for dia1 & X , second for the two editboxes , third for dia2 & Y and the last for the other edit boxes. Normally I would do it this way but the labels are so short , in this case , the effect is minimal.

 

 

 

But for the fans :

 

 



Main_Dialog : dialog { label = "Slide from Image";
 : row {
   : boxed_radio_column {
     : radio_button { key = "rb_rectangle"; label = "Rectangle";}
     : radio_button { key = "rb_rounded"; label = "Rounded";}
     : radio_button { key = "rb_circle1"; label = "Circle1";}
     : radio_button { key = "rb_circle2"; label = "Circle2";}}
   : column {
     : image { key = "im_box_type"; width = 14; height = 10; color = -2;}
     : row {
       : column { : text { label = "X";} : text { label = "Y";}}
       : column { : edit_box { key = "eb_x"; } : edit_box { key = "eb_y";}}
       : column { : text { label = "Dia.1";} : text { label = "Dia.2";}}
       : column { : edit_box { key = "eb_dia1"; } : edit_box { key = "eb_dia2";}}
     }
   }
 }
 spacer;
 ok_cancel;
}


There are some disadvantages using fixed width and height , for instance when you want to resize your image , the size for your edit box will remain the same. Use colums and your design will stretch with it... but that's up 2U...

 

 

 

gr. Rlx

dialog2.png

Edited by rlx
Posted

Hey Guys!

 

@Roy_043:

Thank you, Roy_043 for your advice! I would be making changes to names and such before I was done, more descriptive is definitely a better way to go. My original thought was to have the images be clickable, what I found on that seemed a little complicated to me. I will work at this and where it goes. :)

 

@rlx:

Thank you, rlx for your code! What you have is certainly far more streamlined. I like what I see here, nice and tidy. I haven't had a chance to test out your code yet, but I will for sure soon.

 

Thanks to you both, and others like you, on these forums helping those of us who know there's a better way but were just not very sure of how to go about it!

 

Cheers! :beer:

Posted

You're welcome drafter_joe. If you so desire I can also make a version with a clickable image, but sometimes trying yourself is half the fun :-) I'm sure I already have some threads on this forum with some kind of example , just surch for my user name. The first one that comes to mind would be RlxPaste. One would use the '$reason' parameter with the action-tile code. Just make sure to include some form of data checking , if you double click one of your images , all the edit boxes needed for the type you clicked , have a valid value.

 

gr. Rlx

Posted

rlx,

 

I appreciate the offer for the clickable image. Yes, I will give it a try on my own after I do a search as you suggested next chance I get. I will report back if I made any headway in that area.

 

I'm curious as to your time of experience with dcl? Your code was very compact for what was very long for me. Have you been formally taught or self taught?

 

Thank you!

Drafter_Joe

Posted

Attached is my take on the program: personally, I like any dialog images to appear embedded as part of the interface, and the use of a slide library reduces the number of files which need to be distributed.

 

slidelibraryexample.gif

 

AutoLISP Code:

(defun c:test ( / dch )
   (cond
       (   (<= (setq dch (load_dialog "test.dcl")) 0)
           (princ "\nUnable to find/load test.dcl file.")
       )
       (   (not (new_dialog "test" dch))
           (princ "\nUnable to display dialog.")
       )
       (   (set_tile "dcl" "Slide Library Example")
           (foreach key '("sl1""sl2""sl3""sl4")
               (action_tile key "(updatetiles $key)")
           )
           (set_tile "sl1" "1")
           (updatetiles "sl1")
           (start_dialog)
       )
   )
   (if (< 0 dch) (unload_dialog dch))
   (princ)
)
(defun updatetiles ( key )
   (   (lambda ( x y )
           (start_image "sld")
           (fill_image 0 0 x y -15)
           (slide_image 0 0 x y (strcat "test(" key ")"))
           (end_image)
           (mapcar 'mode_tile '("ed1""ed2""ed3""ed4""ed5")
               (cadr
                   (assoc key
                      '(   ("sl1" (0 0 1 1 1))
                           ("sl2" (0 0 0 1 1))
                           ("sl3" (1 1 1 0 1))
                           ("sl4" (1 1 1 0 0))
                       )
                   )
               )
           )
       )
       (dimx_tile "sld") (dimy_tile "sld")
   )
)

 

DCL Code (to be saved as test.dcl):

edit : edit_box
{
   edit_width = 12;
   width = 20;
   fixed_width = true;
}
test : dialog
{
   key = "dcl"; spacer;
   : row
   {
       spacer;
       : radio_column
       {
           fixed_height = true;
           : radio_button { label = "Rectangle"; key = "sl1"; }
           : radio_button { label = "Rounded";   key = "sl2"; }
           : radio_button { label = "Circle";    key = "sl3"; }
           : radio_button { label = "Pipe";      key = "sl4"; }
       }
       : image
       {
           key = "sld";
           width = 33.5;
           fixed_width = true;
           aspect_ratio = 0.66;
       }
       : column
       {
           fixed_height = true;
           : edit { label = "X:";  key = "ed1"; }
           : edit { label = "Y:";  key = "ed2"; }
           : edit { label = "R:";  key = "ed3"; }
           : edit { label = "D1:"; key = "ed4"; }
           : edit { label = "D2:"; key = "ed5"; }
       }
       spacer;
   }
   spacer_1; ok_cancel;
}

 

The above files along with the Slide Library file are attached.

test.zip

  • Like 1
Posted

fragile beauty,Thank you, and learning.

 

test.slb Can package vlx?

Posted
rlx,

 

I appreciate the offer for the clickable image. Yes, I will give it a try on my own after I do a search as you suggested next chance I get. I will report back if I made any headway in that area.

 

I'm curious as to your time of experience with dcl? Your code was very compact for what was very long for me. Have you been formally taught or self taught?

 

Thank you!

Drafter_Joe

 

 

I have had no autocad or lisp school. Just by trial and error and learning from the masters , Big Al , Tharwat and Lee

Posted (edited)
Attached is my take on the program: personally, I like any dialog images to appear embedded as part of the interface, and the use of a slide library reduces the number of files which need to be distributed.

 

[ATTACH]59250[/ATTACH]

 

AutoLISP Code:

(defun c:test ( / dch )
   (cond
       (   (<= (setq dch (load_dialog "test.dcl")) 0)
           (princ "\nUnable to find/load test.dcl file.")
       )
       (   (not (new_dialog "test" dch))
           (princ "\nUnable to display dialog.")
       )
       (   (set_tile "dcl" "Slide Library Example")
           (foreach key '("sl1""sl2""sl3""sl4")
               (action_tile key "(updatetiles $key)")
           )
           (set_tile "sl1" "1")
           (updatetiles "sl1")
           (start_dialog)
       )
   )
   (if (< 0 dch) (unload_dialog dch))
   (princ)
)
(defun updatetiles ( key )
   (   (lambda ( x y )
           (start_image "sld")
           (fill_image 0 0 x y -15)
           (slide_image 0 0 x y (strcat "test(" key ")"))
           (end_image)
           (mapcar 'mode_tile '("ed1""ed2""ed3""ed4""ed5")
               (cadr
                   (assoc key
                      '(   ("sl1" (0 0 1 1 1))
                           ("sl2" (0 0 0 1 1))
                           ("sl3" (1 1 1 0 1))
                           ("sl4" (1 1 1 0 0))
                       )
                   )
               )
           )
       )
       (dimx_tile "sld") (dimy_tile "sld")
   )
)

DCL Code (to be saved as test.dcl):

edit : edit_box
{
   edit_width = 12;
   width = 20;
   fixed_width = true;
}
test : dialog
{
   key = "dcl"; spacer;
   : row
   {
       spacer;
       : radio_column
       {
           fixed_height = true;
           : radio_button { label = "Rectangle"; key = "sl1"; }
           : radio_button { label = "Rounded";   key = "sl2"; }
           : radio_button { label = "Circle";    key = "sl3"; }
           : radio_button { label = "Pipe";      key = "sl4"; }
       }
       : image
       {
           key = "sld";
           width = 33.5;
           fixed_width = true;
           aspect_ratio = 0.66;
       }
       : column
       {
           fixed_height = true;
           : edit { label = "X:";  key = "ed1"; }
           : edit { label = "Y:";  key = "ed2"; }
           : edit { label = "R:";  key = "ed3"; }
           : edit { label = "D1:"; key = "ed4"; }
           : edit { label = "D2:"; key = "ed5"; }
       }
       spacer;
   }
   spacer_1; ok_cancel;
}

The above files along with the Slide Library file are attached.

 

 

Looks great Lee! (the mode_tile part)

Edited by rlx
Posted
Attached is my take on the program: personally, I like any dialog images to appear embedded as part of the interface, and the use of a slide library reduces the number of files which need to be distributed.

 

[ATTACH]59250[/ATTACH]

 

AutoLISP Code:

(defun c:test ( / dch )
   (cond
       (   (<= (setq dch (load_dialog "test.dcl")) 0)
           (princ "\nUnable to find/load test.dcl file.")
       )
       (   (not (new_dialog "test" dch))
           (princ "\nUnable to display dialog.")
       )
       (   (set_tile "dcl" "Slide Library Example")
           (foreach key '("sl1""sl2""sl3""sl4")
               (action_tile key "(updatetiles $key)")
           )
           (set_tile "sl1" "1")
           (updatetiles "sl1")
           (start_dialog)
       )
   )
   (if (< 0 dch) (unload_dialog dch))
   (princ)
)
(defun updatetiles ( key )
   (   (lambda ( x y )
           (start_image "sld")
           (fill_image 0 0 x y -15)
           (slide_image 0 0 x y (strcat "test(" key ")"))
           (end_image)
           (mapcar 'mode_tile '("ed1""ed2""ed3""ed4""ed5")
               (cadr
                   (assoc key
                      '(   ("sl1" (0 0 1 1 1))
                           ("sl2" (0 0 0 1 1))
                           ("sl3" (1 1 1 0 1))
                           ("sl4" (1 1 1 0 0))
                       )
                   )
               )
           )
       )
       (dimx_tile "sld") (dimy_tile "sld")
   )
)

 

DCL Code (to be saved as test.dcl):

edit : edit_box
{
   edit_width = 12;
   width = 20;
   fixed_width = true;
}
test : dialog
{
   key = "dcl"; spacer;
   : row
   {
       spacer;
       : radio_column
       {
           fixed_height = true;
           : radio_button { label = "Rectangle"; key = "sl1"; }
           : radio_button { label = "Rounded";   key = "sl2"; }
           : radio_button { label = "Circle";    key = "sl3"; }
           : radio_button { label = "Pipe";      key = "sl4"; }
       }
       : image
       {
           key = "sld";
           width = 33.5;
           fixed_width = true;
           aspect_ratio = 0.66;
       }
       : column
       {
           fixed_height = true;
           : edit { label = "X:";  key = "ed1"; }
           : edit { label = "Y:";  key = "ed2"; }
           : edit { label = "R:";  key = "ed3"; }
           : edit { label = "D1:"; key = "ed4"; }
           : edit { label = "D2:"; key = "ed5"; }
       }
       spacer;
   }
   spacer_1; ok_cancel;
}

 

The above files along with the Slide Library file are attached.

 

Thank you Lee! It looks great! You even went the next step, making only the necessary edit boxes available with the corresponding choice. This is where I was headed next. I will enjoy learning how your code works. I have another slide to add and a couple of more edit boxes.

 

Bravo, old chap! Cheers! :beer:

Posted
I have had no autocad or lisp school. Just by trial and error and learning from the masters , Big Al , Tharwat and Lee

 

Wow! I would say the time you've invested has been well worth it!

Posted
Attached is my take on the program: personally, I like any dialog images to appear embedded as part of the interface, and the use of a slide library reduces the number of files which need to be distributed.

 

[ATTACH]59250[/ATTACH]

 

Lee,

 

By chance could you incorporate my drawing below, but done by your standards as seen in your previous attachment, as the 5th choice, please? I can see how to add the two extra edit boxes, but to attempt the slide like the ones you've done already, would frustrate me terribly. That's not even considering the slide library, very new to me.

 

Capture.PNG

 

Thank you!

 

Drafter_Joe

Posted
fragile beauty,Thank you, and learning.

 

Thank you for your kind words!

 

test.slb Can package vlx?

 

To my knowledge, unfortunately not.

 

Looks great Lee! (the mode_tile part)

 

Cheers!

 

Thank you Lee! It looks great! You even went the next step, making only the necessary edit boxes available with the corresponding choice. This is where I was headed next. I will enjoy learning how your code works. I have another slide to add and a couple of more edit boxes.

 

Bravo, old chap! Cheers! :beer:

 

Thanks Joe! - Feel free to ask if you have any questions about the code.

 

By chance could you incorporate my drawing below, but done by your standards as seen in your previous attachment, as the 5th choice, please? I can see how to add the two extra edit boxes, but to attempt the slide like the ones you've done already, would frustrate me terribly. That's not even considering the slide library, very new to me.

 

Sure - please try the attached.

 

Lee

test.zip

Posted (edited)

Slide Library

 

Step 1 is make sld's

Step2 is use individually or make a Slide Library SLB, note can have multiple SLB's

 

Step 1 again

Get what you want to appear full size on your screen, a suggestion is be prepared to get a bit aggressive so the image is clear, remove stuff that really does not need to be in SLD.

 

MSLIDE its that simple and save.

 

I use 0.9xp this is just a subtle zoom out before making slide you will have to experiment.

 

How do I check if it worked ? Easy VSLIDE.

 

Step2 make a SLB, advantage is you can have 1 file but with a 100 sld's in it.

You need SLIDELIB.EXE look below

 

This is a good how it works https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Creating-a-slide-library.html

 

This link refers to a comment that you can not update SLB once done but there is other software available and free have it at home. Allows removal, addition, replacement.

 

script your slide creation

Filedia 0
open S:\AUTODESK\BLOCKS\AMBULANCe\ambalance_access.dwg zoom extents zoom 0.9x mslide ambalance_access
open S:\AUTODESK\BLOCKS\AMBULANCe\ambalance_access_side.dwg zoom extents zoom 0.9x mslide ambalance_access_side
open S:\AUTODESK\BLOCKS\AMBULANCe\ambalance_access_side1.dwg zoom extents zoom 0.9x mslide ambalance_access_side1
open S:\AUTODESK\BLOCKS\AMBULANCe\ambalance_perspective.dwg zoom extents zoom 0.9x mslide ambalance_perspective
open S:\AUTODESK\BLOCKS\AMBULANCe\ambo zoom extents zoom 0.9x mslide ambo
open S:\AUTODESK\BLOCKS\AMBULANCe\Ambulance.dwg zoom extents zoom 0.9x mslide Ambulance
filedia 1

slidelib.zip

Screen Shot 09-15-16 at 01.18 PM.PNG

Edited by BIGAL
Posted

Sure - please try the attached.Lee

 

Looks great, Lee! Thank you!

 

 

Feel free to ask if you have any questions about the code.Lee

 

Yes, I have a question, or two, about the section of code below.

(mapcar 'mode_tile '("ed1""ed2""ed3""ed4""ed5""ed6""ed7")
               (cadr
                   (assoc key
                      '(   ("sl1" (0 0 1 1 1 1 1))
                           ("sl2" (0 0 1 1 0 1 1))
                           ("sl3" (1 1 1 1 1 0 1))
                           ("sl4" (1 1 1 1 1 0 0))
                           ("sl5" (0 0 0 0 1 0 1))
                       )
                   )
               )
           )

I think I can see overall what is happening here, this what makes the edit boxes available or not available?

 

Could you kindly explain the "1's" and the "0's", please?

 

Joe

Posted
Slide Library

 

Step 1 is make sld's

Step2 is use individually or make a Slide Library SLB, note can have multiple SLB's

 

Step 1 again

Get what you want to appear full size on your screen, a suggestion is be prepared to get a bit aggressive so the image is clear, remove stuff that really does not need to be in SLD.

 

MSLIDE its that simple and save.

 

I use 0.9xp this is just a subtle zoom out before making slide you will have to experiment.

 

How do I check if it worked ? Easy VSLIDE.

 

Step2 make a SLB, advantage is you can have 1 file but with a 100 sld's in it.

You need SLIDELIB.EXE look below

 

This is a good how it works https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Creating-a-slide-library.html

 

This link refers to a comment that you can not update SLB once done but there is other software available and free have it at home. Allows removal, addition, replacement.

 

script your slide creation

Filedia 0
open S:\AUTODESK\BLOCKS\AMBULANCe\ambalance_access.dwg zoom extents zoom 0.9x mslide ambalance_access
open S:\AUTODESK\BLOCKS\AMBULANCe\ambalance_access_side.dwg zoom extents zoom 0.9x mslide ambalance_access_side
open S:\AUTODESK\BLOCKS\AMBULANCe\ambalance_access_side1.dwg zoom extents zoom 0.9x mslide ambalance_access_side1
open S:\AUTODESK\BLOCKS\AMBULANCe\ambalance_perspective.dwg zoom extents zoom 0.9x mslide ambalance_perspective
open S:\AUTODESK\BLOCKS\AMBULANCe\ambo zoom extents zoom 0.9x mslide ambo
open S:\AUTODESK\BLOCKS\AMBULANCe\Ambulance.dwg zoom extents zoom 0.9x mslide Ambulance
filedia 1

 

Thanks BIGAL! I appreciate your directions and thanks for the file! I'll definitely be experimenting with this.

 

Joe

Posted (edited)

Figured out the 1 or 0 1 is on look at the right side of the dialouge x y x1 y1 etc as you click the different types very nice Lee could come in handy.

 

Lee a question I use slides etc in dcl's etc but your code does not stipulate how to use Test.slb is it just because of where I have placed the slb to have a look at it or did you leave it out on purpose ?

 

Answered my own question, for any one else test.slb must be in a predefined search directory.

 

Slide library example for a big library SLB name = ctone, (slide name)

 

(setq ai_pts_lst '("ctone(TLDS)" "ctone(dsdn)" "ctone(trds)"
                  "ctone(dsr)" "ca3blank" "ctone(DSL)"
                  "ctone(blds)" "ctone(dsup)" "ctone(brds)")
)

Edited by BIGAL

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