prodromosm 发表于 2022-7-5 20:25:00

dcl和lisp帮助

嗨,我的朋友和哈里新年!!!
 
我使用此lisp代码来管理图形中插入块的比例。
 
这段代码很简单
 

( DEFUN C:SETSC ()
   (SETQ CURSC (getvar "useri1" ))
   (princ "the print scale is 1:")(princ cursc)
   (setq newsc (getint "\nNew scale1:"))
   (setvar "useri1" newsc)
   (setq a1 (getvar "useri1"))
   (princ "\n The new print scale is 1:")(princ newsc)(princ)
)

 
我正在尝试使用dcl更新此代码
 
dcl代码
-------------

setsc1: dialog {
        label = "print scale";



: text_part {
            label = " ";
        key = "useri1";
alignment = left;
}

spacer_1;

: boxed_column {
    label = " scale ";

   : radio_column {
      : radio_button { label = "1 : 10"; key = "10"; }
      : radio_button { label = "1 : 20"; key = "20"; }
      : radio_button { label = "1 : 50"; key = "50"; }
      : radio_button { label = "1 : 100"; key = "100"; }
      : radio_button { label = "1 : 200"; key = "200"; }
      : radio_button { label = "1 : 500"; key = "500"; }
      : radio_button { label = "1 : 1000"; key = "1000"; }
      : radio_button { label = "1 : 2000"; key = "2000"; }
      : radio_button { label = "1 : 5000"; key = "5000"; }
      : radio_button { label = "1 : 10000"; key = "10000"; }
   }

}

: edit_box {
label = "Other scale    1: ";
key = "newsc";
alignment = left;
edit_limit = 30;
edit_width = 10;
fixed_width = true ;
allow_accept = true ;
}
spacer_1;

ok_cancel_help;

spacer_1;
: errtile {
width = 34;
}
: text_part {
            label = " © 2015";
        key = "selection_msg";
alignment = right;
}
}
//DCL CODING ENDS HERE


 
新lisp代码
----------------
 

( DEFUN C:SETSC1 ()
(setq dcl_id (load_dialog "setsc1.dcl"))

    (if (not (new_dialog "setsc1" dcl_id))
(exit )
    );if
   (SETQ CURSC (getvar "useri1" ))
;    (setq newsc (getint "\nNew scale1:"))
   (setvar "useri1" newsc)
   (setq a1 (getvar "useri1"))
)


 
我很困惑,因为我不知道如何让这一切顺利进行。有人能帮忙吗?
 
谢谢

prodromosm 发表于 2022-7-5 20:35:22

有什么想法吗?
 
谢谢

hanhphuc 发表于 2022-7-5 20:39:57

 
嗨,prodromosm,
也许是这个?
注意:我假设您的dcl名为setsc1。dcl和处于有效的支持路径中

(defun c:SETSC (/ dd dcl newsc pass)
;hanhphuc 07/01/2015 *happy new year*
(if (and (setq fn (findfile "setsc1.dcl")) (setq dcl (load_dialog fn))) ;_ end of and
   (progn (setq newsc (if (or (= "" (setq newsc(getvar "users1"))) (not (numberp (read newsc))))
               "10"
               newsc
               ) ;_ end of if
       ) ;_ end of setq
   (new_dialog "setsc1" dcl)
   (set_tile "newsc" newsc)
          (set_tile newsc "1")
   (mapcar ''((x) (action_tile x "(set_tile \"newsc\" (get_attr $key \"key\"))"))
           '("10" "20" "50" "100" "200" "500" "1000" "2000" "5000" "10000")
           ) ;_ end of mapcar
   (action_tile "accept" "(setq newsc (get_tile \"newsc\"))(done_dialog dcl)")
   (setq dd (start_dialog))
   (if (setq pass(numberp (read newsc)))
   (setvar "users1" newsc)
   ) ;_ end of if
   (set_tile "newsc" newsc)
   ) ;_ end of progn
   ) ;_ end of if
(unload_dialog dcl)
(if (and (/= dd 0) pass)
   (alert (strcat "\nThe new print scale is 1: " newsc))
   ;(alert "Invalid :-( ")
   ) ;_ end of if
(princ)
)

prodromosm 发表于 2022-7-5 20:49:37

你好,韩。谢谢你的尝试,但是这个代码不起作用。。。

hanhphuc 发表于 2022-7-5 20:53:57

 
很抱歉,之前的帖子我以为你的文件名是setsc。(缺少扩展名*.dcl)
所以我把它改成了setsc1。dcl
 
注意:警报只是一个示例输出。
您可以将newsc修改并转换为numberp
HTH公司

prodromosm 发表于 2022-7-5 20:59:50

代码现在正在运行,但规模没有改变。我不知道;我不知道问题出在哪里??
 
 
dcl代码
 


setsc1: dialog {
        label = "print scale";



: text_part {
            label = " ";
        key = "useri1";
alignment = left;
}

spacer_1;

: boxed_column {
    label = " scale ";

   : radio_column {
      : radio_button { label = "1 : 10"; key = "10"; }
      : radio_button { label = "1 : 20"; key = "20"; }
      : radio_button { label = "1 : 50"; key = "50"; }
      : radio_button { label = "1 : 100"; key = "100"; }
      : radio_button { label = "1 : 200"; key = "200"; }
      : radio_button { label = "1 : 250"; key = "250"; }
      : radio_button { label = "1 : 500"; key = "500"; }
      : radio_button { label = "1 : 1000"; key = "1000"; }
      : radio_button { label = "1 : 2000"; key = "2000"; }
      : radio_button { label = "1 : 5000"; key = "5000"; }
      : radio_button { label = "1 : 10000"; key = "10000"; }
   }

}

: edit_box {
label = "new scale    1: ";
key = "newsc";
alignment = left;
edit_limit = 30;
edit_width = 10;
fixed_width = true ;
allow_accept = true ;
}
spacer_1;

ok_cancel_help;

spacer_1;
: errtile {
width = 34;
}
: text_part {
            label = " ©1.1-2015";
        key = "selection_msg";
alignment = right;
}
}
//DCL CODING ENDS HERE


 
 
lisp代码

(defun c:SETSC1 (/ dd dcl newsc pass)
(if (and (setq fn (findfile "setsc1.dcl")) (setq dcl (load_dialog fn))) ;_ end of and
   (progn (setq newsc (if (or (= "" (setq newsc(getvar "users1"))) (not (numberp (read newsc))))
               "10"
               newsc
               ) ;_ end of if
       ) ;_ end of setq
   (new_dialog "setsc1" dcl)
   (set_tile "newsc" newsc)
          (set_tile newsc "1")
   (mapcar ''((x) (action_tile x "(set_tile \"newsc\" (get_attr $key \"key\"))"))
           '("10" "20" "50" "100" "200" "500" "1000" "2000" "5000" "10000")
           ) ;_ end of mapcar
   (action_tile "accept" "(setq newsc (get_tile \"newsc\"))(done_dialog dcl)")
   (setq dd (start_dialog))
   (if (setq pass(numberp (read newsc)))
   (setvar "users1" newsc)
   ) ;_ end of if
   (set_tile "newsc" newsc)
   ) ;_ end of progn
   ) ;_ end of if
(unload_dialog dcl)
(if (and (/= dd 0) pass)
   (alert (strcat "\nThe new print scale is 1: " newsc))
   ;(alert "Invalid :-( ")
   ) ;_ end of if
(princ)
)

hanhphuc 发表于 2022-7-5 21:09:03

dcl代码
</blockquote>您应该能够利用产值新闻来修改自己
上面的例子是:(alert(strcat“\n新的打印比例是1:“newsc”)
 
我不确定您是否要插入新块或修改现有块(可以在属性对话框中更改)
插入示例:

(vl-load-com)
(vla-InsertBlock object InsertionPoint Name (atof newsc) (atof newsc) 1.0 0.0 )
; example newsc applied to Xscale, Yscale in red.

cadfan 发表于 2022-7-5 21:15:36

 
你好,韩先生,你很专业。你今天看起来很棒。你有空吗?
 
我有个问题,你能帮我吗?
http://www.cadtutor.net/forum/showthread.php?90298-智能线路

hanhphuc 发表于 2022-7-5 21:21:22

嗨,卡德凡,谢谢,但我还没有资格
 
我认为M.R(MarkoRibar)在这个论坛上有一个类似的lisp,它以一定的角度画线,但我不记得了。
请耐心在这里搜索。。
 
编辑:>在此处找到

prodromosm 发表于 2022-7-5 21:29:45

谢谢你,我会测试的。。
页: [1]
查看完整版本: dcl和lisp帮助