Jump to content

My First Dialog Box ~ Comments/Criticism Welcome


Recommended Posts

Posted

Hi Guys,

 

So, I thought I'd finally venture into the world of DCL... scary as it is :o

 

Please find below my very first DCL attempt - just using an old code I made to increment integer text :)

 

Comments and Criticism are much appreciated and any pointers are welcome.

 

Cheers

 

Lee

 


(defun c:sums  (/ ss dcTag fSel)
 (vl-load-com)

 (defun selAdd     ()
   (setq fSel '(1+))
   (set_tile "sel_text" "Plus One Selected"))

 (defun selSub     ()
   (setq fSel '(1-))
   (set_tile "sel_text" "Minus One Selected"))

 (setq dcTag (load_dialog "AddOne.dcl"))
 (if (not (new_dialog "adder" dcTag)) (exit))
 (action_tile "sel_add" "(selAdd)")
 (action_tile "sel_sub" "(selSub)")
 (action_tile "accept" "(done_dialog)")
 (start_dialog)
 (unload_dialog dcTag)

 (if (setq ss (ssget (list (cons 0 "TEXT,MTEXT")
   (if    (getvar "CTAB") (cons 410 (getvar "CTAB"))
      (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (mapcar '(lambda (x) (entmod (subst (cons 1 (itoa (eval (append fSel (list (atoi (cdr (assoc 1 x)))))))) (assoc 1 x) x)))
         (mapcar 'entget (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))))
   (princ "\n<!> No Selection Set <!>"))

 (princ))

// Add One DCL Attempt
// Increment Numerical Text Sign Selector

adder : dialog {

   label = "Specify Increment Direction";

   : text {

       label = "";
       key = "sel_text";
       alignment = centered;

       } // text

   : row {

       : button {

           label = "+1";
           key = "sel_add";
           fixed_width = true;
           mnemonic = "+";

           } // button

       : button {
           
           label = "-1";
           key = "sel_sub";
           fixed_width = true;
           mnemonic = "-";

           } // button

       } // row

   ok_only;

} // dialog 

Thank you for your time :)

Posted

Not bad Lee_Mac,

 

But not that it may be that important, I noticed the dcl & lisp have two different names. I tend to think that it would be difficult to know that the two files belong with each other.

I have seen it done this way before, But I have a preference to keeping the files with the same name.

 

Great job and hope to see alot more.

I can just imagine how far you would take it.

The Buzzard

Posted

Ahh, good point Buzzard ~ the original LISP was called "addone" and then I changed it to "sums" for some reason..., but I can see your point about the DCL having the same name - it would probably decrease chances of error as well :thumbsup:

 

I must say, to start with the DCL language is much easier than I expected - everything seems pretty self explanatory, and there doesn't seem to be much to learn in the way of functions - but then I haven't gotten too deep into it yet...

 

I ran your DCL (CDL) the other day to see how a proper DCL would look and I must say, it looks very professional indeed (half the reason I decided to dive in and learn a bit of DCL myself). There are so many applications for it - I have a few LISPs in which the users is given an option menu to select from, and these would become much more professional if converted to a dialog box format.

 

Thanks once again for your comments Buzzard - I shall see how far the rabbit-hole goes with DCL... :P :P :P

 

 

Cheers

 

Lee

Posted

One of the good things about dcl files are that you can control the user input with preset data. This avoids the users from making errors with input you would normally type at the command prompt. Also its right in your face in the drawing editor area. You can use ALERTS to show the user when they make a wrong selection.

 

All around I think they are worth the effort.

Posted

Attached is a program I know you would enjoy. It creates a simple dialog with an image tile. Before you run the program, draw something on the screen. Run the program and it will create a program with the dialog box and an image in the tile of the object you just drew.

It places the made program in a temp directory on drive C:.

The made program will be called vimage.lsp with a dcl file call vimage.dcl. The slide it creates is a windows meta file. The list for the image is within the program. This is a good way to create images for libraries without the need for external slides. This program was written by Viper from another forum I use to belong to.

 

 

One nice neat package.

Enjoy

Mimage2.lsp

Posted

Here is one more program and I think you might remember this one. I was looking for some help with it and got it. This program was created from the start with the program mimage2.lsp and built upon from there. I just used the above program then to create all the few simple images that are in the SL program. When you view this program you will notice I did not need to use external slides. I use one image_tile and change the image when scrolling thru the popup list. From what I have learned from you so far, I will be able to improve on this program as well with the use of cons and assoc. It will consolidate my programming greatly. I hope you will get much use out of it as I have gotton. Its a real time saver.

 

Again enjoy and I cannot wait to see what you will come up it next.

 

The Buzzard

SL.zip

Posted

Thank you for your kind contributions Buzzard - they are very informative :)

 

I like the SL program, and remember the name when helping you on the forum at some point (good to see it all works!). I like the use of the image as a preview tile before the users inserts the block into the drawing. - very professional.

 

Thanks

 

Lee

Posted

When you start working with dialog boxes the whole new world opens up and you will start writing more complex programs. Learning DCL is great but it does have a few drawbacks depending on the complexity of the program. If you are going to get into making more and more dialog boxes I suggest looking into openDCL . it’s free and has way more flexibility than regular DCL. You can drag and drop controls onto a form and position them anywhere. Also you have more choices of dialog box types to work with, DCL only has one type. If you’re going to learn dialog boxes you might as well learn something that has a lot more options

Posted

Thank you for your suggestion John, I shall look into OpenDCL - is it a separate program? And is it available free?

Posted

download the stuido and make sure it's the stable version you dont want the newest because of buggs. opendcl is an open source project so things happen.

the runtimes are the arx files needed to make it work. so if you write a program and give it to some one else you will have to give them the runtime arx files as well.

once you get it installed you want to spend time learning how to make it load and unload into autocad. it's a bit of a learning curve but once you figure it out it's sweet. also go to the site and read the fourms there is a lot of help there.

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