Dynamic DCL

Dynamic DCL

etilley327KA
Advocate Advocate
325 Views
1 Reply
Message 1 of 2

Dynamic DCL

etilley327KA
Advocate
Advocate

Looking for help on the coding for this. I'm trying to create a DCL that will display frozen, thawed and layer buttons from the drawing. The layers will change, and the setup of the buttons will need to be dynamic. Heres what I'm going for and the function to write the dcl that I have so far.

etilley327KA_0-1697318072635.png

(setq layer-list00 '((layer1,1)(layer2,1)(layer3,0)(layer4,1)))

(defun write-layer-dcl (/ layer-info layer-name frozen-status frozen-label thawed-label)

 (if (= layer-list00 nil)
   (princ "\nNo active layers found.")
   (progn
     (setq fname01 (vl-filename-mktemp "mylayerdialog.dcl"))
     (if (and fname01 (setq fn01 (open fname01 "w")))
       (progn
         (write-line
          "LAYERS_dcl1 : dialog {"
          "  label = \"LAYERS\";"
          "  : row {"
          "    children_alignment = top;"
          "    children_fixed_height = true;"
          "    : boxed_column {"
          "      label = \"FROZEN\";" fn01)
         
         (foreach layer-info layer-list00
           (setq layer-name (car layer-info))
           (setq frozen-status (cadr layer-info))
           (if (= frozen-status 1)
             (setq frozen-label "X")
             (setq frozen-label "")
           )
           (write-line
            (strcat "      : button {"
                    "        label = \"" frozen-label "\";"
                    "        key = \"FRZ1_" layer-name "\";"
                    "      }" fn01)
           )
         )

         (write-line
          "    }"
          "    : boxed_column {"
          "      label = \"THAW\";" fn01)

         (foreach layer-info layer-list00
           (setq layer-name (car layer-info))
           (setq frozen-status (cadr layer-info))
           (if (= frozen-status 1)
             (setq thawed-label "")
             (setq thawed-label "X")
           )
           (write-line
            (strcat "      : button {"
                    "        label = \"" thawed-label "\";"
                    "        key = \"THW1_" layer-name "\";"
                    "      }" fn01)
           )
         )

         (write-line
          "    }"
          "    : boxed_column {"
          "      label = \"LAYERS IN USE [SELECT TO ISOLATE] \";"
          "      children_fixed_height = true;" fn01)

         (foreach layer-info layer-list00
           (setq layer-name (car layer-info))
           (write-line
            (strcat "      : button {"
                    "        label = \"" layer-name "\";"
                    "        key = \"LayoutHeader_" layer-name "\";"
                    "      }" fn01)
           )
         )

         (write-line
          "    }"
          "  }"
          "  ok_only;"
          "}" fn01)

         (if fn01 (close fn01))
       )
     )
   )
 )
)
0 Likes
326 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

You may need a 4th column with a toggle for the select layer, you can do multi toggle picks, press OK and re update the dcl. Do you need the key = (strcat \"LayoutHeader_\" layer-name). I am not sure if you can pick a edit box and it automatically uses that as select and close dcl.

 

Radio button is like this select button say Rb2 and it closes. The but reflects a number matching an item in say your layer list.

(setq x 1)
(repeat (- (length butlst) 1)
(setq k (strcat "Rb" (rtos x 2 0)))
(action_tile k  (strcat "(setq but "  (rtos x 2 0) ")" "(done_dialog)"))
(setq x (+ x 1))
)

Have a look for my Multi radio, Getvals & Toggles, Multi GETVALS 2col lisps you may get some ideas in there for the lisp code of calling the dcl and getting values.

 

 

0 Likes