Author Topic: DCL dialog boxes with check box  (Read 206 times)

0 Members and 1 Guest are viewing this topic.

nini007

  • Mosquito
  • Posts: 12
DCL dialog boxes with check box
« on: October 04, 2017, 08:25:48 am »
Hello the forum :2funny:,
I need your lights about the DCL dialog boxes.
I would like with the example below, if possible with checkboxes in a dialog box to open and reload a lisp file.
I added a line open and load, I tried several combinations without success.

Is it possible  :idea:?


PS: site of the dcl database here: http://web2.airmail.net/terrycad/Tutorials/MyDialogs.htm

Thank you in advance

Code: [Select]
//---------------------------------------------------------------------------------------------------------
// MyToggles
//---------------------------------------------------------------------------------------------------------
  MyToggles : dialog {
   key = "Title";
   label = "";//Title$ from lsp file
   spacer;
: text {
     label = "Menu custom ;-)";
     alignment = centered;
   }
   : text {
     label = "--- Version: 21.09.2017 ---";
     alignment = centered;
   }
   
        : text {
        label = "";// to create a newline
        alignment = centered;
        }

   : text {
     label = "Test line";
     alignment = centered;
   }

        : text {
        label = "";// to create a newline
        alignment = centered;
        }

   : text {
     label = "Copyright©®™";
     alignment = centered;
   }

        : text {
        label = "";// to create a newline
        alignment = centered;
        }

// start case online
   : boxed_column {
     label = "File to open for modification";
     width = 34.26;
     fixed_width = true;
     : row {
       : toggle {
         key = "Toggle1";
         label = "File MyToggles.lsp";
         open = "C:\\Program Files\\Autodesk\\AutoCAD 2017\\Support\\Lisp\\A_tester\\MyToggles.lsp";
       }
       : toggle {
         key = "Toggle2";
         label = "file MyDialogs2.dcl";
         open = "C:\\Users\\toni\\AppData\\Roaming\\Autodesk\\AutoCAD 2017\\R21.0\\fra\\Support\\MyDialogs2.dcl";
       }
     }
  spacer;
// End case online



// start case in column
}
   : boxed_column {
     label = "File to be loaded after modification";
     width = 34.26;
     fixed_width = true;
     : toggle {
       key = "Toggle3";
       label = "MyToggles.lsp";
       load = "C:\\Program Files\\Autodesk\\AutoCAD 2017\\Support\\Lisp\\A_tester\\MyToggles.lsp";
     }
     : toggle {
       key = "Toggle4";
       label = "MyDialogs2.dcl";
       load = "C:\\Users\\toni\\AppData\\Roaming\\Autodesk\\AutoCAD 2017\\R21.0\\fra\\Support\\MyDialogs2.dcl";
     }
     : toggle {
       key = "Toggle5";
       label = "Toggle 5";
     }
     spacer;
// End case in column
   
   }
   spacer;
   ok_only;
 }//MyToggles


roy_043

  • Swamp Rat
  • Posts: 1477
  • BricsCAD 16
Re: DCL dialog boxes with check box
« Reply #1 on: October 04, 2017, 11:16:48 am »
That link is a nice tutorial. You should definitely study it. :idea:

nini007

  • Mosquito
  • Posts: 12
Re: DCL dialog boxes with check box
« Reply #2 on: October 05, 2017, 03:44:28 am »
Hello,
I just studied it and I did not find the solution :idiot2:.
In the tutorial I did not find how to load and open a file.
I am a novice in this field :blink:.
If you could tell me at least where is the solution it would be nice :smitten:.

Thank you for your help :-)
Best regards

roy_043

  • Swamp Rat
  • Posts: 1477
  • BricsCAD 16
Re: DCL dialog boxes with check box
« Reply #3 on: October 05, 2017, 09:16:43 am »
On many levels what you are doing makes little sense. Programming is more than just copy-pasting.

Try to get acquainted with the VLIDE editor. And if you still think you need some utility to reload the Lisp files you are working on, consider creating a function that reloads all files in a folder. That would be more flexible and efficient.

This topic may be useful:
https://www.theswamp.org/index.php?topic=15057.0

nini007

  • Mosquito
  • Posts: 12
Re: DCL dialog boxes with check box
« Reply #4 on: October 09, 2017, 06:22:59 am »
Hello,

Thank you for your answer :-D.

In fact the DCL dialog I want to set up, I would use it for two things :laugh:.

1. Every time I modify my personal menu, which I created several years ago, I want to have the version in order to find my archives. What I want to update with its check boxes is to open the DCL file and update the version of my menu and eventually reload the lisp that drives the DCL file without having to start AutoCAD or reload all lisp.

2. This is to learn a few things again and I could reuse it for another use.

Thank you in advance :-D.
Best regards

roy_043

  • Swamp Rat
  • Posts: 1477
  • BricsCAD 16
Re: DCL dialog boxes with check box
« Reply #5 on: October 10, 2017, 04:45:12 am »
I don't fully understand your intention. But if all you want to do is display the version number of your personal menu I suggest using the alert function. You can include something like this in your .mnl file:
Code: [Select]
(defun c:MyMenuVersion ()
  (alert
    (strcat
      "My Menu Version:"
      "\n"
      "\n20171010"
    )
  )
  (princ)
)

(princ "\nMy Menu Version: 20171010 ")
(princ)

nini007

  • Mosquito
  • Posts: 12
Re: DCL dialog boxes with check box
« Reply #6 on: October 16, 2017, 11:35:40 am »
Thank you for help and your file :grinwink: which is fine but is not really what I want to do :blink:.
My intention is to be able to edit my DCL file while remaining in the AutoCAD environment :lol:. I often modify my menu, so I must frequently open the explorer in order to open my file lsp / dcl, the goal is more to have to make his manipulations surly :-(. But from a button, box, etc. open the file directly and reload it.

thank you in advance

roy_043

  • Swamp Rat
  • Posts: 1477
  • BricsCAD 16
Re: DCL dialog boxes with check box
« Reply #7 on: October 16, 2017, 03:25:55 pm »
ManageMyFiles.lsp
Code: [Select]
(defun c:ManageMyFiles ( / N_ActionOpen N_ActionReload dcl)

  (defun N_ActionOpen ( / )
    (if (= "1" (get_tile "tglOpen1"))
      (startapp
        (strcat
          "notepad.exe "
          "\"" (get_attr "tglOpen1" "path") "\""
        )
      )
    )
    (if (= "1" (get_tile "tglOpen2"))
      (startapp
        (strcat
          "notepad.exe "
          "\"" (get_attr "tglOpen2" "path") "\""
        )
      )
    )
  )

  (defun N_ActionReload ( / )
    (if (= "1" (get_tile "tglReload1"))
      (load (get_attr "tglReload1" "path"))
    )
  )

  (if
    (or
      (< 0 (setq dcl (load_dialog "ManageMyFiles.dcl")))
      (prompt "\nError: dcl dialog not found ")
    )
    (progn
      (new_dialog "ManageMyFiles" dcl)
      (action_tile "btnOpen"   "(N_ActionOpen)")
      (action_tile "btnReload" "(N_ActionReload)")
      (action_tile "cancel"    "(done_dialog 0)")
      (start_dialog)
      (unload_dialog dcl)
    )
  )
  (princ)
)

ManageMyFiles.dcl
Code: [Select]
ManageMyFiles : dialog {
  label = "Manage My Files";
  : boxed_column {
    label = "Open";
    : toggle {
      key = "tglOpen1";
      label = "MyLisp.lsp";
      path = "D:\\MyFiles\\MyLisp.lsp"; // Custom attribute.
      value = "1";
    }
    : toggle {
      key = "tglOpen2";
      label = "MyLisp.dcl";
      path = "D:\\MyFiles\\MyLisp.dcl"; // Custom attribute.
      value = "1";
    }
    : button {
      key = "btnOpen";
      label = "Open selected files";
    }
  }
  : boxed_column {
    label = "Reload";
    : toggle {
      key = "tglReload1";
      label = "MyLisp.lsp";
      path = "D:\\MyFiles\\MyLisp.lsp"; // Custom attribute.
      value = "1";
    }
    : button {
      key = "btnReload";
      label = "Reload selected files";
    }
  }
  cancel_button;
}

nini007

  • Mosquito
  • Posts: 12
Re: DCL dialog boxes with check box
« Reply #8 on: October 17, 2017, 09:41:04 am »
Hello,
Thank you so much for your help and patience :-D.
That's exactly it, you're a chief :grinwink:.
Best regards :-)