Aller au contenu

BOITE DE DIALOGUE SUR DEUX COLONNES


PHILPHIL

Messages recommandés

Bonjour

 

 

comment programmer pour que la boite est deux colonnes de 10 nommées au lieu d'une seule

 

a déplacer si le sujet n'est pas au bon endroit

 

merci

 

Phil

 

(defun 20inputbox (box msg1 msg2 msg3 msg4 msg5 msg6 msg7 msg8 msg9 msg10 msg11 msg12 msg13 msg14 msg15 msg16 msg17 msg18 msg19 msg20 val1 val2 val3 val4 val5 val6 val7 val8 val9 val10 val11 val12 val13 val14 val15 val16 val17 val18 val19 val20 / temp file dcl_id lst)
 (defun subr (str / pos)
   (if (and (< 36 (strlen str)) (setq pos (vl-string-position 32 (substr str 1 36) nil t)))
     (strcat ":text_part{label=\"" (substr str 1 pos) "\";}" (subr (substr str (+ 2 pos))))
     (strcat ":text_part{label=\"" str "\";}")
   )
 )
 (setq temp (vl-filename-mktemp "Tmp.dcl")
       file (open temp "w")
 )
 (write-line (strcat "xInputBox:dialog{key=\"box\";initial_focus=\"val1\";
     :edit_box{label="
                     (vl-prin1-to-string msg1)
                     ";key=\"val1\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg2)
                     ";key=\"val2\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg3)
                     ";key=\"val3\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg4)
                     ";key=\"val4\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg5)
                     ";key=\"val5\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg6)
                     ";key=\"val6\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg7)
                     ";key=\"val7\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg8)
                     ";key=\"val8\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg9)
                     ";key=\"val9\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg10)
                     ";key=\"val10\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg11)
                     ";key=\"val11\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg12)
                     ";key=\"val12\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg13)
                     ";key=\"val13\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg14)
                     ";key=\"val14\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg15)
                     ";key=\"val15\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg16)
                     ";key=\"val16\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg17)
                     ";key=\"val17\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg18)
                     ";key=\"val18\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg19)
                     ";key=\"val19\";edit_width=36;allow_accept=true;}spacer;
     :edit_box{label="
                     (vl-prin1-to-string msg20)
                     ";key=\"val20\";edit_width=36;allow_accept=true;}spacer;
                     ok_cancel; }"
             )
             file
 )
 (close file)
 (setq dcl_id (load_dialog temp))
 (if (not (new_dialog "xInputBox" dcl_id))
   (exit)
 )
 (foreach n '("box" "val1" "val2" "val3" "val4" "val5" "val6" "val7" "val8" "val9" "val10" "val11" "val12" "val13" "val14" "val15" "val16" "val17" "val18" "val19" "val20" ) (set_tile n (eval (read n))))
 (action_tile
   "accept"
   "(setq v1 (get_tile \"val1\")
          v2 (get_tile \"val2\")
          v3 (get_tile \"val3\")
          v4 (get_tile \"val4\")
          v5 (get_tile \"val5\")
          v6 (get_tile \"val6\")
          v7 (get_tile \"val7\")
          v8 (get_tile \"val8\")
          v9 (get_tile \"val9\")
          v10 (get_tile \"val10\")
          v11 (get_tile \"val11\")
          v12 (get_tile \"val12\")
          v13 (get_tile \"val13\")
          v14 (get_tile \"val14\")
          v15 (get_tile \"val15\")
          v16 (get_tile \"val16\")
          v17 (get_tile \"val17\")
          v18 (get_tile \"val18\")
          v19 (get_tile \"val19\")
          v20 (get_tile \"val20\")
)


   
(done_dialog)"
 )
 (start_dialog)
 (unload_dialog dcl_id)
 (vl-file-delete temp)
 v1
 v2
 v3
 v4
 v5
 v6
 v7
 v8
 v9
 v10
 v11
 v12
 v13
 v14
 v15
 v16
 v17
 v18
 v19
 v20
)

Autodesk Architecture 2023 sous windows 11 64

24 pouces vertical + 30 pouces horizontal + 27 pouces horizontal

Lien vers le commentaire
Partager sur d’autres sites

Salut,

 

Pour faire deux colonnes, il suffit de faire ne rangée (row) avec deux colonnes (column)

 

Un exemple de fichiers dcl qui ferait un peu ce que tu veux :

 

test : dialog {
 label = "Test";
 : row {
   : column {
     :edit_box { label="Valeur 1"; key="val1"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 2"; key="val2"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 3"; key="val3"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 4"; key="val4"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 5"; key="val5"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 6"; key="val6"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 7"; key="val7"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 8"; key="val8"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 9"; key="val9"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 10"; key="val10"; edit_width=36; allow_accept=true; } spacer;
   }
   spacer;
   :column  {
     :edit_box { label="Valeur 11"; key="val11"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 12"; key="val12"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 13"; key="val13"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 14"; key="val14"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 15"; key="val15"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 16"; key="val16"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 17"; key="val17"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 18"; key="val18"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 19"; key="val19"; edit_width=36; allow_accept=true; } spacer;
     :edit_box { label="Valeur 20"; key="val20"; edit_width=36; allow_accept=true; } spacer;
   }
 }
 spacer;
 ok_cancel;
}

 

Il suffit de transcrire ça pour écrire le fichier DCL "à la volée".

Comme LISP est un langage de traitement de liste, il me semble qu'il serait plus judicieux d'utiliser des listes, ou mieux des listes d'associations pour les données en entrée et surtout pour la valeur de retour (ta routine ne renvoie que la valeur de l'évaluation de la dernière expression, soit : v20).

 

Dans l'exemple suivant les arguments sont :

- le titre de la boite de dialogue

- une liste de 20 paires pointées du type (message . valeur)

et la valeur de retour est une liste de même type.

 

(defun 20inputbox (box lst / temp file keys i dcl_id res)
 (setq temp (vl-filename-mktemp "Tmp.dcl")
       file (open temp "w")
       keys '("val1"
              "val2"
              "val3"
              "val4"
              "val5"
              "val6"
              "val7"
              "val8"
              "val9"
              "val10"
              "val11"
              "val12"
              "val13"
              "val14"
              "val15"
              "val16"
              "val17"
              "val18"
              "val19"
              "val20"
             )
 )
 (write-line "xInputBox:dialog{key=\"box\";initial_focus=\"val1\"; :row{ :column{" file)
 (setq i 0)
 (repeat 10
   (write-line (strcat ":edit_box{label="
                       (vl-prin1-to-string (car (nth i lst)))
                       ";key=\"val"
                       (itoa (setq i (1+ i)))
                       "\";edit_width=36;allow_accept=true;}spacer;"
               )
               file
   )
 )
 (write-line "} :column{" file)
 (repeat 10
   (write-line (strcat ":edit_box{label="
                       (vl-prin1-to-string (car (nth i lst)))
                       ";key=\"val"
                       (itoa (setq i (1+ i)))
                       "\";edit_width=36;allow_accept=true;}spacer;"
               )
               file
   )
 )
 (write-line "}}  spacer; ok_cancel; }" file)
 (close file)
 (setq dcl_id (load_dialog temp))
 (if (not (new_dialog "xInputBox" dcl_id))
   (exit)
 )
 (set_tile "box" box)
 (mapcar 'set_tile keys (mapcar 'cdr lst))
 (action_tile
   "accept"
   "(setq res (mapcar 'cons (mapcar 'car lst) (mapcar 'get_tile keys))) (done_dialog)"
 )
 (start_dialog)
 (unload_dialog dcl_id)
 (vl-file-delete temp)
 res
)

Gilles Chanteau - gileCAD -
Développements sur mesure pour AutoCAD
ADSK_Expert_Elite_Icon_S_Color_Blk_125.png

Lien vers le commentaire
Partager sur d’autres sites

Oups!...

J'avais oublie : "colonnes nommées".

La fonction prend désormais 4 arguments :

- le titre de la boite de dialogue

- le nom de la première colonne

- le nom de la seconde colonne

- une liste de 20 paires pointées du type (message . valeur)

 

(defun 20inputbox (box col1 col2 lst / temp file keys i dcl_id res)
 (setq temp (vl-filename-mktemp "Tmp.dcl")
       file (open temp "w")
       keys '("val1"
              "val2"
              "val3"
              "val4"
              "val5"
              "val6"
              "val7"
              "val8"
              "val9"
              "val10"
              "val11"
              "val12"
              "val13"
              "val14"
              "val15"
              "val16"
              "val17"
              "val18"
              "val19"
              "val20"
             )
 )
 (write-line (strcat
               "xInputBox:dialog{key=\"box\";initial_focus=\"val1\"; :row{ :column{label=\""
               col1
               "\";"
             )
             file
 )
 (setq i 0)
 (repeat 10
   (write-line (strcat ":edit_box{label="
                       (vl-prin1-to-string (car (nth i lst)))
                       ";key=\"val"
                       (itoa (setq i (1+ i)))
                       "\";edit_width=36;allow_accept=true;}spacer;"
               )
               file
   )
 )
 (write-line (strcat
               "} :column{label=\""
               col2
               "\";"
             )
             file
 )
 (repeat 10
   (write-line (strcat ":edit_box{label="
                       (vl-prin1-to-string (car (nth i lst)))
                       ";key=\"val"
                       (itoa (setq i (1+ i)))
                       "\";edit_width=36;allow_accept=true;}spacer;"
               )
               file
   )
 )
 (write-line "}}  spacer; ok_cancel; }" file)
 (close file)
 (setq dcl_id (load_dialog temp))
 (if (not (new_dialog "xInputBox" dcl_id))
   (exit)
 )
 (set_tile "box" box)
 (mapcar 'set_tile keys (mapcar 'cdr lst))
 (action_tile
   "accept"
   "(setq res (mapcar 'cons (mapcar 'car lst) (mapcar 'get_tile keys))) (done_dialog)"
 )
 (start_dialog)
 (unload_dialog dcl_id)
 (vl-file-delete temp)
 res
)

Gilles Chanteau - gileCAD -
Développements sur mesure pour AutoCAD
ADSK_Expert_Elite_Icon_S_Color_Blk_125.png

Lien vers le commentaire
Partager sur d’autres sites

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !

Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant
×
×
  • Créer...

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer. Politique de confidentialité