jhune 发表于 2022-7-5 20:35:12

代码错误

大家好,
 
有人能帮我解决代码问题吗?
 
dcl代码工作正常,但lisp代码似乎有一些
问题你能检查一下我需要做什么才能使它在我的autocad中执行吗?
 
DCL代码:
 
IBlock:dialog{
label="BLOCK SELECTION";
:column {
:row{
:row{

:radio_column {
key="radio";
label="VIEW";

:radio_button{
key="plan";
label=" PLAN";
}
:radio_button{
key="side";
label=" SIDE";
}
:radio_button{
key="front";
label=" FRONT";
}

}
:column{
:radio_column {
key="radio2";
label="BLOCK TYPE";

:radio_button{
label= "Block1";
key="B1";
value="1";
}
:radio_button{
label= "Block2";
key="B2";
}

}

}
}
}

:row{
:button{
key="accept";
label=" OK ";
is_default=true;
height=3.5;

}
:button{
key="cancel";
label=" CANCEL ";
is_default=false;
is_cancel=true;
height=3.5;
}
}
}
}
 
LISP代码:
(defun saveVars()

(setq plan(atoi(get_tile "plan")))
(setq side(atoi(get_tile "side")))
(setq front(atoi(get_tile "front")))
(setq b1(atoi(get_tile "B1")))
(setq b2(atoi(get_tile "B2")))



;;;--PLAN VIEW--

(setqp1(strcat path "Block1p")
p2(strcat path "Block2p")
)

;;;--SIDE VIEW--

(setqs1(strcat path "Block1s")
      s2(strcat path "Block2s")

)

;;;--SIDE VIEW--

(setqf1(strcat path "Block1f")
      f2(strcat path "Block2f")

)
      
)
(defun C:IBlock()
(setvar "cmdecho" 0)
(setq oldOsmode(getvar "osmode"))
(setvar "osmode" 0)

;;;--- Load the dialog box

(setq dcl_id (load_dialog "c:\\Lisp\\Programs\\Iblock.dcl"))

;;;--- See if it is ready

(if (not (new_dialog "Iblock" dcl_id) ) (exit))

;;;--- If an action event occurs, do this function

(action_tile "cancel" "(setq ddiag 1)(done_dialog)")
(action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
;(saveVars)


;;;--- Display the dialog box
(start_dialog)
(unload_dialog dcl_id)
;;;--- If the CANCEL button was pressed - display message

(if (= ddiag 1)
(princ "\n \n ...IBblock Cancelled. \n ")
)

;;;--- If the OKAY button was pressed

(if (= ddiag 2)

      

(command "-insert" (if(and(= plan 1)(= b1 1)) p1
   
             (if(and(= plan 1)(= b2 1)) p2

             (if(and(= side 1)(= b1 1)) s1

                 (if(and(= side 1)(= b2 1)) s2

                   (if(and(= front 1)(= b1 1)) f1

                     (if(and(= front 1)(= b2 1)) f2

                           ))))))) pause 1 1 pause)
         




(setvar "cmdecho" 175)

(princ)

)
 
 
伊布洛克。LSP
伊布洛克。DCL

Tharwat 发表于 2022-7-5 20:42:49

为什么要删除与此请求相同的最后一个线程?

jhune 发表于 2022-7-5 20:48:20

我没有删除它。这就是为什么我再次发布它,本来应该检查它,但我找不到它。

Tharwat 发表于 2022-7-5 20:50:57

 
好的,没问题。
 
变量路径为零,那么块的完整路径是什么?

jhune 发表于 2022-7-5 20:58:12

对不起,我忘了放小路了。
 
但在加载时仍然出现语法错误
 
(setq路径“c:\\Lisp\\Library”\\)

Tharwat 发表于 2022-7-5 21:01:41

现在试试这个,让我知道。
 

(defun c:IBlock (/ os dcl_id plan side front b1 b2 bk)
;;        Modified by Tharwat 10.12.2014                ;;
(setq dcl_id (load_dialog "c:\\Lisp\\Programs\\Iblock.dcl"))
(if (not (new_dialog "IBlock" dcl_id))
   (exit)
   (progn
   (action_tile "cancel" "(setq ddiag 1)(done_dialog)")
   (action_tile
       "accept"
       "(setq plan (atoi (get_tile \"plan\"))
                                  side (atoi (get_tile \"side\"))
                                  front (atoi (get_tile \"front\"))
                                  b1 (atoi (get_tile \"B1\"))
                                  b2 (atoi (get_tile \"B2\")))
                                  (done_dialog)"
   )
   (start_dialog)
   (unload_dialog dcl_id)
   )
)
(if (= ddiag 1)
   (princ "\n ...IBblock Cancelled. \n ")
   (progn
   (cond ((and (= plan 1)
               (= b1 1)
            )
            (setq bk "Block1p")
         )
         ((and (= plan 1)
               (= b2 1)
            )
            (setq bk "Block2p")
         )
         ((and (= side 1) (= b1 1))
            (setq bk "Block1s")
         )
         ((and (= side 1) (= b2 1))
            (setq bk "Block2s")
         )
         ((and (= front 1) (= b1 1))
            (setq bk "Block1f")
         )
         ((and (= front 1) (= b2 1))
            (setq bk "Block2f")
         )
   )
   (if (and bk (findfile (setq bk (strcat "c:\\Lisp\\Library\\" bk ".dwg"))))
       (progn
         (setq os (getvar "osmode"))
         (setvar "osmode" 0)
         (command "_.-insert" bk pause 1. 1. pause)
       (setvar "osmode" os)
       )
       (alert
         (strcat "\n Name of Block < " bk " > is not found !!")
       )
   )
   )
)
(princ)
)

jhune 发表于 2022-7-5 21:04:51

嗨,塔瓦,
 
代码正在正确上传,但只要我单击所需的视图和块类型,就找不到块的Nae。我附上了一张剪断的图片,我已经在path文件夹中插入了require块文件。
 

Tharwat 发表于 2022-7-5 21:10:39

请用Dcl文件中的替换此部分(如蓝色所示),然后重试。
 

: radio_button { key = "plan";
label = " PLAN";
value = "1";
}

jhune 发表于 2022-7-5 21:15:18

嗨,塔瓦,
 
我已经更新了它,它是相同的错误之前。

Tharwat 发表于 2022-7-5 21:19:16

以上代码已更新,请重试。
页: [1] 2
查看完整版本: 代码错误