sadhu 发表于 2022-7-6 11:34:45

如果..返回对话框。。需要hel

在下面的代码中,我有这个,如果喜欢的话
 
我想用返回Edit1框(如果为空)进行编译并在那里获得焦点的东西来替换“退出”。Edit1位于DCL对话框中。可能需要重新启动对话框。
 
 
 
;-------------start dialog------------
(setq dcl_id (load_dialog "hello_sp.dcl")) ; Load the DCL file.
(if (not (new_dialog "hello_sp" dcl_id))   ; Initialize the dialog.
   (exit)                              ; Exit if this doesn't
                                       ; work.
)
;------------set values in dialog box----


(set_tile "discesa" (rtos a1 2 2))
(set_tile "masetto1" (rtos a2 2 2))
(set_tile "salita" (rtos miodist 2 2))
(set_tile "tolleranza" (rtos tolleranza 2 2))
(set_tile "orriz" (rtos d1 2 2))
(set_tile "note_" "Ricordati bracci per il Q.E. e dorsali")
(set_tile "grand_dist" (rtos tot2 2 2))
(set_tile "grand_dist_" "GRAND TOTAL (SQ)")
   
(set_tile "Text1" "Numero Braccio")
(set_tile "Edit1" "")
(set_tile "Text2" "Diametro Tubo [*=25]")
(set_tile "Edit2" "")
(set_tile "Text3" "Tipo Linea")
(set_tile "Edit3" "")
; Dialog Actions
(action_tile "Edit1" "(setq Edit1 $value)")
(action_tile "Edit2" "(setq Edit2 $value)")
(action_tile "Edit3" "(setq Edit3 $value)")

;------------end - set values in dialog box----

(start_dialog)                        ; Display the dialog   ; box.

(if (= Edit1 "")
(progn
(Alert "Campo No. braccio non puo essere vuoto")
(exit)))

(unload_dialog dcl_id)                  ; Unload the DCL file.
(princ)

BearDyugin 发表于 2022-7-6 11:40:06

(action_tile "Edit1"
"(if (= (setq Edit1 $value) \"\")
    (progn
    (Alert \"The field is empty\")
    (mode_tile \"Edit1\" 2)
    )
)"
)

sadhu 发表于 2022-7-6 11:44:36

我复制了你的代码
(action_tile "Edit1"
"(if (= (setq Edit1 $value) \"\")
    (progn
    (Alert \"The field is empty\")
    (mode_tile \"Edit1\" 2)
    )
)"
)并更换
我在构建输出中得到了这个错误。
 
 

BearDyugin 发表于 2022-7-6 11:49:34

当然,因为你传递了一个斜杠,这是必要的,因为反逗号“被认为是字符串中的反逗号,字符串的一部分,而不是其末端
不要受斜杠和反逗号的影响,因为习惯性的格式是在action\u tile中写的,所以可以这样写

(action_tile
"Edit1"
(vl-prin1-to-string
   (quote
   (if (= (setq Edit1 $value) "")
(progn
(Alert "The field is empty")
(mode_tile "Edit1" 2)
)
   )
   )
)
)
 
为了好,有必要在Ok上这样写
 

(action_tile
"accept"
(vl-prin1-to-string
   (quote
   (if Edit1
(done_dialog)
(progn
(Alert "The field of Edit1 is empty")
(mode_tile "Edit1" 2)
)
   )
   )
)
)

sadhu 发表于 2022-7-6 11:51:40

我无法让它工作。“if”命令没有注意到edit1为空,程序正常运行。
 
我复制了以下代码:
然后像这样插入它:
 
;-------------start dialog------------
(setq dcl_id (load_dialog "hello_sp.dcl")) ; Load the DCL file.
(if (not (new_dialog "hello_sp" dcl_id))   ; Initialize the dialog.
   (exit)                              ; Exit if this doesn't
                                       ; work.
)
;------------set values in dialog box----


(set_tile "discesa" (rtos a1 2 2))
(set_tile "masetto1" (rtos a2 2 2))
(set_tile "salita" (rtos miodist 2 2))
(set_tile "tolleranza" (rtos tolleranza 2 2))
(set_tile "orriz" (rtos d1 2 2))
(set_tile "note_" "Ricordati bracci per il Q.E. e dorsali")
(set_tile "grand_dist" (rtos tot2 2 2))
(set_tile "grand_dist_" "GRAND TOTAL (SQ)")
   
(set_tile "Text1" "Numero Braccio")
(set_tile "Edit1" "")
(set_tile "Text2" "Diametro Tubo [*=25]")
(set_tile "Edit2" "")
(set_tile "Text3" "Tipo Linea")
(set_tile "Edit3" "")
; Dialog Actions
(action_tile "Edit1" "(setq Edit1 $value)")
(action_tile "Edit2" "(setq Edit2 $value)")
(action_tile "Edit3" "(setq Edit3 $value)")

;------------end - set values in dialog box----

(start_dialog)                        ; Display the dialog   ; box.

(action_tile
"Edit1"
(vl-prin1-to-string
   (quote
   (if (= (setq Edit1 $value) "")
   (progn
   (Alert "The field is empty")
   (mode_tile "Edit1" 2)
   )
   )
   )
)
)
   
;(if (= Edit1 "")
;(progn
; (Alert "Campo No. braccio non puo essere vuoto")
;(exit)))

(unload_dialog dcl_id)                  ; Unload the DCL file.
(princ)

Lee Mac 发表于 2022-7-6 11:55:37

我想:
 

(action_tile "Edit1"
(vl-prin1-to-string
   (quote
   (progn
       (if (= (setq Edit1 $value) "")
         (progn
         (Alert "The field is empty") (mode_tile "Edit1" 2)))))))

sadhu 发表于 2022-7-6 12:00:22

李,我把你的代码放在下面,但“如果”没有“注意”Edit1框是空的。
 
只是想让您知道,您的代码被插入到“开始”对话框和“卸载”对话框命令之间。(我也尝试在开始对话框之前插入)
 
 
这样地:
 
(setq dcl_id (load_dialog "hello_sp.dcl")) ; Load the DCL file.
(if (not (new_dialog "hello_sp" dcl_id))   ; Initialize the dialog.
(exit)                              ; Exit if this doesn't
                                       ; work.
)
;------------set values in dialog box----

(set_tile "discesa" (rtos a1 2 2))
(set_tile "masetto1" (rtos a2 2 2))
(set_tile "salita" (rtos miodist 2 2))
(set_tile "tolleranza" (rtos tolleranza 2 2))
(set_tile "orriz" (rtos d1 2 2))
(set_tile "note_" "Ricordati bracci per il Q.E. e dorsali")
(set_tile "grand_dist" (rtos tot2 2 2))

(set_tile "grand_dist_" "GRAND TOTAL (SQ)")

(set_tile "Text1" "Numero Braccio")
(set_tile "Edit1" "")
(set_tile "Text2" "Diametro Tubo [*=25]")
(set_tile "Edit2" "")
(set_tile "Text3" "Tipo Linea")
(set_tile "Edit3" "")
; Dialog Actions
(action_tile "Edit1" "(setq Edit1 $value)")
(action_tile "Edit2" "(setq Edit2 $value)")
(action_tile "Edit3" "(setq Edit3 $value)")



;------------end - set values in dialog box----

(start_dialog); Display the dialog box.

(action_tile "Edit1"
(vl-prin1-to-string
   (quote
   (progn
       (if (= (setq Edit1 $value) "")
         (progn
         (Alert "The field is empty") (mode_tile "Edit1" 2)))))))

;(if (= Edit1 "")
;(progn
;(Alert "Campo No. braccio non puo essere vuoto")
;(exit)))

(unload_dialog dcl_id)                  ; Unload the DCL file.
(princ)

;(setq lay "RH MEASURE Layer" );- writes total value to drawing Layer
;(alert "Inserisci NUMERO BRACCIO /
[*] DIA.TUBO 25 - TIPO LINEA ")

;(setq braccio (getstring "\nInserisci NUMERO BRACCIO /
[*] DIA.TUBO 25 - TIPO LINEA:"))

(and (setq pnt (getpoint "\nPunto di inserimento misura / Specify Text placement point: "))
    (entmakex (list '(0 . "MTEXT")
                  '(100 . "AcDbEntity")
                  '(100 . "AcDbMText")
             ;(cons 8 lay)
                     (cons 1 (strcat "(" Edit1 Edit2 ")" (rtos tot2 2 2) Edit3))
             (cons 7 (getvar 'textstyle))
                     (cons 10 pnt)
             (cons 40 0.08)
            ) ;_ list
    ) ;_ entmakex
) ;_ and

;------------------------

)
(princ "\nType sq to run Grand Distance(sq)")
(princ)


sadhu 发表于 2022-7-6 12:03:15

当我使用它时,它是存在的。
 
(if (= Edit1 "")
(progn
(Alert "Campo R non puo essere vuoto")
(exit)

))

BearDyugin 发表于 2022-7-6 12:07:10

sadhu,完全显示DCL和LISP

sadhu 发表于 2022-7-6 12:09:41

 
 
dcl:
hello_sp : dialog {
   
   label = "Sadhu says";

   //first box - ** srl

   : boxed_column {
   label = "** srl";

       //second box - Dati di base
      
//startline 1
: boxed_column {
   label = "Dati di base";
: row {
   : column {
   width = 10;
   fixed_width = true;
   
   : text {
       key = "discesa_";
       label = "Discesa         ";//
   }
   }
   : text {
       key = "discesa";
       label = "Sanjay";//Prompt from lsp file
      
       width = 18;
   fixed_width_font = true;
   
   }
    }
   
//spacer;

//end line 1

//startline 1 bis


: row {
   : column {
   width = 10;
   fixed_width = true;
   
   : text {
       key = "tolleranza_";
       label = "Tolleranza   ";//
   }
   }
   : text {
       key = "tolleranza";
       label = "San";//Prompt from lsp file
      
       width = 18;
   fixed_width_font = true;
   
   }
    }
   
//spacer;

//end line 1 bis




//startline 2
: row {
   : column {
   width = 10;
   fixed_width = true;
   
   : text {
       key = "masetto1_";
       label = "Masetto_1      ";//Prompt from lsp file
   }
   }
   : text {
       key = "masetto1";
       label = "jay";//Prompt from lsp file
      
       width = 18;
   fixed_width_font = true;
   
   }
    }//end line 2
    } //second box - Dati di base
//spacer;



//third box - dati inseriti


   : boxed_column {
       label = "Dati inseriti";

      //start salita inserita
: row {
   : column {
   width = 10;
   fixed_width = true;
   
   : text {
       key = "Salita_";
       label = "Salit�* Inserita";//Prompt from lsp file
   }
   }
   : text {
       key = "salita";
       label = "";//Prompt from lsp file
      
       width = 18;
   fixed_width_font = true;
   
   }
    } //end salita inserita

   //start distanza orrizontale
: row {
   : column {
   width = 10;
   fixed_width = true;
   
   : text {
       key = "orriz_";
       label = "Dist Orrizon.";//Prompt from lsp file
   }
   }
   : text {
       key = "orriz";
       label = "";//Prompt from lsp file
      
       width = 18;
   fixed_width_font = true;
   
   }
    } //end distanza orrizontale

   
    }// end third box - dati inseriti
//spacer;


spacer;
spacer;
spacer;


//startfourth box Grand
: boxed_column {


//startlast line Grand
: row {
   : column {
   width = 10;
   fixed_width = true;
   
   : text {
       key = "grand_dist_";
       label = "GRANDTOTAL   ";//Prompt from lsp file
   }
   }
   : text {
       key = "grand_dist";
       label = "Sanjay";//Prompt from lsp file
      
       width = 18;
   fixed_width_font = true;
   
   }
    }    //endlast line Grand
   }   //endtfourth box Grand



//start insert numero braccio / tubo / linee

: row {//<
   fixed_width = true;
   : column {
   width = 35;
   fixed_width = true;
   spacer;
   : text {
       key = "Text1";
       label = "";//Text1$ from lsp file
   }
   }
   : edit_box {
   key = "Edit1";//Edit1$ from lsp file
   edit_width = 9.42;
   fixed_width = true;
   allow_accept = true;
   initial_focus = true;
   
   }
}//>
: row {//<
   fixed_width = true;
   : column {
   width = 35;
   fixed_width = true;
   spacer;
   : text {
       key = "Text2";
       label = "";//Text2$ from lsp file
   }
   }
   : edit_box {
   key = "Edit2";//Edit2$ from lsp file
   edit_width = 9.42;
   fixed_width = true;
   }
}//>
: row {//<
   fixed_width = true;
   : column {
   width = 35;
   fixed_width = true;
   spacer;
   : text {
       key = "Text3";
       label = "";//Text3$ from lsp file
   }
   }
   : edit_box {
   key = "Edit3";//Edit3$ from lsp file
   edit_width = 9.42;
   fixed_width = true;
   }
}//>

//endinsert numero braccio / tubo / linee



   
    }    //endlast line Grand


spacer;
spacer;
spacer;
spacer;
spacer;
spacer;

: button {
   key = "accept";
   label = "OK";
   is_default = true;
   width = 18;
   fixed_width = true;
   alignment = centered;

} //end button


//startnote
: row {
   : column {
   width = 10;
   fixed_width = true;
   
   : text {
       key = "note_";
       label = "Note: ";//Prompt from lsp file
      width = 40;
       fixed_width_font = true;
   }
   } //end note
spacer;
spacer;
spacer;
spacer;

            }//end fourth box Grand
                } //end first box - rh srl

lisp:红色是我想要替换的(退出)
 
13
页: [1] 2
查看完整版本: 如果..返回对话框。。需要hel