Author Topic: Need some ideas for a nested menu  (Read 1721 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
Need some ideas for a nested menu
« on: December 22, 2017, 01:13:34 PM »
I want to create a nested drop down menu for a cui button.

Currently we can only have one level of drop downs.
Button
Drop Down
Items [1]

What I want is
Button
Drop Down [1]
Items [1]
Drop Down [2]
[items [2]
etc..

DCL might be a better approach but I don't want to switch focus away from the drawing area. The user needs some simplicity. If DCL is used I think the user would have to click through the menus, then terminate the DCL with an OK button.

A bit of info on my project.
I call it smart leader.
I cannot share the entire lisp program due to non disclosures.
Several callouts are standard and specific with jurisdictions. We work with many jurisdictions and each prefer to use their own verbiage. We need every person to be consistent on how we call out standard features in our cad drawings. For example. Some cities prefer "Sidewalk" some prefer "S/W" some don't have a preference.
I created a script that draws a leader based on the jurisdiction and object that is being called out. It grabs text from an external txt documents to prefill the leader text.
Example of the external txt document used to prefill leader text.

sample.txt
Code: [Select]
REMOVE & REPLACE <L>' X <W>' SIDEWALK PANELThe <L> and <W> are tags for the script to replace it with user input.

smartleader example
Code: [Select]
(defun c:smleader()
(setq L (getint "\nWhat is the length"))
(setq W (getint "\nWhat is the width"))
;;code to replace <W> &<L>
;;code to retrieive sample.txt
;;code to draw a leader with final string

Any ideas?


« Last Edit: December 22, 2017, 01:20:50 PM by dubb »

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Need some ideas for a nested menu
« Reply #1 on: December 22, 2017, 01:35:51 PM »
  • Roast Beef with a garlic and black pepper rub
  • Pan Fried Haddock with a lemon-caper reduction.
  • Chicken with cranberry orange glaze. 

ohhh wrong type of menu! 
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

dubb

  • Swamp Rat
  • Posts: 1105
Re: Need some ideas for a nested menu
« Reply #2 on: December 22, 2017, 01:51:24 PM »
Yummy! Holiday cooking notes taken. :idea:

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Need some ideas for a nested menu
« Reply #3 on: December 22, 2017, 05:48:55 PM »
i am not sure that it's what you want but have a look at https://www.theswamp.org/index.php?topic=32261.0

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Need some ideas for a nested menu
« Reply #4 on: December 23, 2017, 02:18:23 AM »
I find this interesting, but its not in tree structure:
https://www.theswamp.org/index.php?topic=13477.0
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Need some ideas for a nested menu
« Reply #5 on: December 23, 2017, 06:15:55 AM »
Another option:

An OpenDCL control bar with a tree control.
Advantages:
  • Modeless
  • Dockable
  • Multiple nodes can be and stay expanded (fewer clicks)
  • Possibility to store and restore an 'expanded state'

dubb

  • Swamp Rat
  • Posts: 1105
Re: Need some ideas for a nested menu
« Reply #6 on: December 26, 2017, 11:09:54 AM »
Thanks! Those look very interesting.

BIGAL

  • Swamp Rat
  • Posts: 1425
  • 40 + years of using Autocad
Re: Need some ideas for a nested menu
« Reply #7 on: December 27, 2017, 05:07:33 AM »
My version of
(setq L (getint "\nWhat is the length"))
(setq W (getint "\nWhat is the width"))

Have a look at AH:Getval2
Code: [Select]
; Input  Dialog box with variable title
; multiple lines of dcl input supported
; add extra lines if required by copying code defun
; By Alan H 2015
(vl-load-com)

; 1 line dcl
; sample code (ah:getval1 "Line 1" 5 4 "-")
(defun AH:getval1 (title width limit def1 / fo fname)
; you can hard code a directory if you like for dcl file
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
(write-line "ddgetval : dialog {" fo)
(write-line " : row {" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = "  (chr 34) "key1" (chr 34) ";") fo)
(write-line  (strcat " label = "  (chr 34) title (chr 34) ";"  )   fo)
; these can be replaced with shorter value etc
(write-line (strcat "     edit_width = " (rtos width 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit 2 0) ";" ) fo)
(write-line "   is_enabled = true;" fo)
(write-line "    }" fo)
(write-line "  }" fo)
(write-line "ok_only;}" fo)
(close fo)

(setq dcl_id (load_dialog  fname))
; pt is a list 2 numbs -1 -1 centre ('(20 20))
;(not (new_dialog "test" dch "" *screenpoint*))
(if (not (new_dialog "ddgetval" dcl_id))
(exit))
(set_tile "key1" (setq val1 def1))
(action_tile "key1" "(setq val1 $value)")
(mode_tile "key1" 3)
(start_dialog)
(done_dialog)
(unload_dialog dcl_id)
; returns the value of val1 as a string
(vl-file-delete fname)
) ; defungetval1

; 2 line dcl
; sample code (ah:getval2 "Line 1" 5 4 "1" "Line2" 8 7 "2")
(defun AH:getval2 (title1 width1 limit1 def1 title2 width2 limit2 def2 / fo fname)
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
(write-line "ddgetval2 : dialog {" fo)
(write-line " : column {" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
(write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
(write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_only;}" fo)
(close fo)

; code part
(setq dcl_id (load_dialog  fname))
(if (not (new_dialog "ddgetval2" dcl_id))
(exit))
(mode_tile "key1" 3)
(set_tile "key1" (setq val1 def1))
(action_tile "key1" "(setq val1 $value)")
(mode_tile "key2" 3)
(set_tile "key2" (setq val2 def2))
(action_tile "key2" "(setq val2 $value)")
(start_dialog)
(done_dialog)
(unload_dialog dcl_id)
; returns the value of val1 and val2 as strings
(vl-file-delete fname)
) ; defungetval2

; 3 line dcl
; sample code (ah:getval3 "Line 1" 5 4 "0.9" "Line 2" 8 7 "wow" "Line 3" 6 4 "123")

(defun AH:getval3 (title1 width1 limit1 def1 title2 width2 limit2 def2 title3 width3 limit3 def3 / fo fname)
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
(write-line "ddgetval3 : dialog {" fo)
(write-line " : column {" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
(write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
(write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key3" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title3 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width3 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit3 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_only;}" fo)
(close fo)

; code part
(setq dcl_id (load_dialog  fname))
(if (not (new_dialog "ddgetval3" dcl_id))
(exit))
(mode_tile "key1" 3)
(set_tile "key1" (setq val1 def1))
(action_tile "key1" "(setq val1 $value)")
(mode_tile "key2" 3)
(set_tile "key2" (setq val2 def2))
(action_tile "key2" "(setq val2 $value)")
(mode_tile "key3" 3)
(set_tile "key3" (setq val3 def3))
(action_tile "key3" "(setq val3 $value)")
(start_dialog)
(done_dialog)
(unload_dialog dcl_id)
; returns the value of val1 val2 and val3 as strings
(vl-file-delete fname)
) ; defungetval3

; 4 line dcl
; sample code (ah:getval4 "Line 1" 5 4 "0.9" "Line 2" 8 7 "wow" "Line 3" 6 4 "123" "Line 4" 6 4 "456")

(defun AH:getval4 (title1 width1 limit1 def1 title2 width2 limit2 def2 title3 width3 limit3 def3  title4 width4 limit4 def4 / fo fname)
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
(write-line "ddgetval3 : dialog {" fo)
(write-line " : column {" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
(write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
(write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key3" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title3 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width3 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit3 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key4" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title4 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width4 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit4 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_only;}" fo)
(close fo)

; code part
(setq dcl_id (load_dialog  fname))
(if (not (new_dialog "ddgetval3" dcl_id))
(exit))
(mode_tile "key1" 3)
(set_tile "key1" (setq val1 def1))
(action_tile "key1" "(setq val1 $value)")
(mode_tile "key2" 3)
(set_tile "key2" (setq val2 def2))
(action_tile "key2" "(setq val2 $value)")
(mode_tile "key3" 3)
(set_tile "key3" (setq val3 def3))
(action_tile "key3" "(setq val3 $value)")
(mode_tile "key4" 3)
(set_tile "key4" (setq val4 def4))
(action_tile "key4" "(setq val4 $value)")
(start_dialog)
(done_dialog)
(unload_dialog dcl_id)
; returns the value of val1 val2 and val3 as strings
(vl-file-delete fname)
) ; defungetval4

; 5 line dcl
; sample code (ah:getval5 "Line 1" 5 4 "0.9" "Line 2" 8 7 "wow" "Line 3" 6 4 "123" "Line 4" 6 4 "456" "Line 5" 6 4 "789")

(defun AH:getval5 (title1 width1 limit1 def1 title2 width2 limit2 def2 title3 width3 limit3 def3  title4 width4 limit4 def4  title5 width5 limit5 def5 / fo fname)
;(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
(setq fo (open (setq fname "c:\\acadtemp\\ddgetval5.dcl") "w"))
(write-line "ddgetval3 : dialog {" fo)
(write-line " : column {" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
(write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
(write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key3" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title3 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width3 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit3 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key4" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title4 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width4 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit4 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key5" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title5 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width5 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit5 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_only;}" fo)
(close fo)

; code part
(setq dcl_id (load_dialog  fname))
(if (not (new_dialog "ddgetval3" dcl_id))
(exit))
(mode_tile "key1" 3)
(set_tile "key1" (setq val1 def1))
(action_tile "key1" "(setq val1 $value)")
(mode_tile "key2" 3)
(set_tile "key2" (setq val2 def2))
(action_tile "key2" "(setq val2 $value)")
(mode_tile "key3" 3)
(set_tile "key3" (setq val3 def3))
(action_tile "key3" "(setq val3 $value)")
(mode_tile "key4" 3)
(set_tile "key4" (setq val4 def4))
(action_tile "key4" "(setq val4 $value)")
(mode_tile "key5" 3)
(set_tile "key5" (setq val5 def5))
(action_tile "key5" "(setq val5 $value)")
(start_dialog)
(done_dialog)
(unload_dialog dcl_id)
; returns the value of val1 val2 and val3 as strings
;(vl-file-delete fname)
) ; defungetval5

It started life as a 3 line input another poster now has it at 8 line version.

Almost forgot example code for 2 inputs
Code: [Select]
(if (not ah:getval2)(Load "getvals"))
(ah:getval2 "Line 1" 5 4 "1" "Line2" 8 7 "2")
; returns val1 & val2 as strings
(setq L (atof val1))
(setq w (atof val2))
« Last Edit: December 27, 2017, 05:12:02 AM by BIGAL »
A man who never made a mistake never made anything