After making the multi lisps always thought has to be a simple way to make dcl code from a dwg, so this is a real rough 1st go for multi radio buttons, it makes a dcl, but further down the track will do make dcl or lisp code.
The example uses a block with 1 attribute, the attribute holds the label to be used, in future will hard code the block name so Radio, Toggle, Edit etc are auto implied in code.
Just select dcl dialog name, heading label, then the buttons . You can test using "Test"
In the multi radio buts I do a loop to work out which button has been selected but may do a cond instead as easier to understand.
Appreciate any comments at this stage as I said very much 1st go.
; make dcl from blocks
; By AlanH Nov 2022
(defun wow ( /)
(setq fo (open (setq fname "d:\\acadtemp\\dcl2lisp.dcl") "W"))
(setq colrow (strcase (getstring "\nRow or Col R C")))
(setq dclname (cdr (assoc 1 (entget (car (entsel "\npick dcl name text"))))))
(setq dclhead (cdr (assoc 1 (entget (car (entsel "\npick heading text"))))))
(prompt "Pick the block objects ")
(setq ss (ssget '((0 . "INSERT"))))
(write-line (strcat dclname " : dialog {") fo)
(write-line (strcat "Label = " "\"" dclhead "\"" " ;") fo)
(write-line ": row {" fo)
(if (= colrow "C")
(write-line ": boxed_radio_column {" fo)
(write-line ": boxed_radio_row {" fo)
)
(setq x 1)
(repeat (setq k (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq k (- k 1)))))
(setq atts (vlax-invoke obj 'Getattributes))
(repeat (setq j (length atts))
(write-line " : radio_button {" fo)
(write-line (strcat "key = " "\"" "Rb" (rtos x 2 0) "\"" " ;") fo)
(write-line (strcat "label = " "\"" (vla-get-textstring (nth (setq j (1- j)) atts)) "\"" " ;") fo)
(write-line " }" fo)
(write-line "spacer_1 ;" fo)
(setq x (1+ X))
)
)
(write-line "}" fo)
(write-line "}" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_cancel ;" fo)
(write-line "}" fo)
(close fo)
)
(wow)
(defun c:test ( / )
(defun butpressed ( )
(alert "various ways of checking button presed")
)
(setq dcl_id (load_dialog fname))
(if (not (new_dialog dclname dcl_id) )
(exit)
)
(action_tile "accept" "(butpressed ) (done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
dwg to dcl.dwg