ibanez_222 发表于 2022-7-6 08:21:47

比例列表编辑Lisp错误

我创建这个lisp是为了插入比例,但我得到了一个错误“无效选项关键字”,它把我踢出了例程。我想知道是否有办法解决这个问题。从我所能理解的是,假设它达到1/4“=1’-0”,并且比例已经在绘图中使用,它将回退该错误,并且不会继续。问题的另一部分是,它不会删除正在使用的比例,所以当它创建这些比例时,其中一些已经存在,所以删除它们都不起作用。有没有一种方法可以让它在不打破常规的情况下继续下去?任何帮助都将不胜感激。
 
我最初试图留在命令中,但我有一个想法,如果每次退出命令,如果规模存在,它将继续到下一次。以下是我目前掌握的情况:
 
(defun c:IS()
(setvar "cmdecho" 0)
(command "_.-scalelistedit" "d" "*" "e")
(command "_.-scalelistedit" "a" "1:1" "1:1" "e")
(command "_.-scalelistedit" "a" "1:2" "1:2" "e")
(command "_.-scalelistedit" "a" "1:4" "1:4" "e")
(command "_.-scalelistedit" "a" "1:8" "1:8" "e")
(command "_.-scalelistedit" "a" "1\" = 1'-0\"" "1:12" "e")
(command "_.-scalelistedit" "a" "1/2\" = 1'-0\"" "0.5:12" "e")
(command "_.-scalelistedit" "a" "1/4\" = 1'-0\"" "0.25:12" "e")
(command "_.-scalelistedit" "a" "3/16\" = 1'-0\"" "0.01875:12" "e")
(command "_.-scalelistedit" "a" "1/8\" = 1'-0\"" "0.125:12" "e")
(command "_.-scalelistedit" "a" "3/32\" = 1'-0\"" "0.09375:12" "e")
(command "_.-scalelistedit" "a" "1/16\" = 1'-0\"" "0.0625:12" "e")
(command "_.-scalelistedit" "a" "1/32\" = 1'-0\"" "0.03125:12" "e")
(command "_.-scalelistedit" "a" "1/64\" = 1'-0\"" "0.015625:12" "e")
(command "_.-scalelistedit" "a" "1\" = 10'-0\"" "1:120" "e")
(command "_.-scalelistedit" "a" "1\" = 20'-0\"" "1:240" "e")
(command "_.-scalelistedit" "a" "1\" = 25'-0\"" "1:300" "e")                           
(command "_.-scalelistedit" "a" "1\" = 30'-0\"" "1:360" "e")
(command "_.-scalelistedit" "a" "1\" = 40'-0\"" "1:480" "e")
(command "_.-scalelistedit" "a" "1\" = 50'-0\"" "1:600" "e")
(setvar "cmdecho" 1)
(princ "\nA quote: \"")
)
(prompt "Insert Scales Loaded.")
(princ)

 
这不会退出命令:
(defun c:IS()
(setvar "cmdecho" 0)
(command "_.-scalelistedit" "d" "*" "e")
(command "_.-scalelistedit" "a" "1:1" "1:1"
                            "a" "1:2" "1:2"
                            "a" "1:4" "1:4"
                            "a" "1:8" "1:8"
                            "a" "1\" = 1'-0\"" "1:12"
                            "a" "1/2\" = 1'-0\"" "0.5:12"
                            "a" "1/4\" = 1'-0\"" "0.25:12"
                            "a" "3/16\" = 1'-0\"" "0.01875:12"
                            "a" "1/8\" = 1'-0\"" "0.125:12"
                            "a" "3/32\" = 1'-0\"" "0.09375:12"
                            "a" "1/16\" = 1'-0\"" "0.0625:12"
                            "a" "1/32\" = 1'-0\"" "0.03125:12"
                            "a" "1/64\" = 1'-0\"" "0.015625:12"
                            "a" "1\" = 10'-0\"" "1:120"
                            "a" "1\" = 20'-0\"" "1:240"
                            "a" "1\" = 25'-0\"" "1:300"                           
                            "a" "1\" = 30'-0\"" "1:360"
                            "a" "1\" = 40'-0\"" "1:480"
                            "a" "1\" = 50'-0\"" "1:600" "e")
(setvar "cmdecho" 1)
(princ "\nA quote: \"")
)
(prompt "Insert Scales Loaded.")
(princ)

Ahankhah 发表于 2022-7-6 08:31:24

您必须从比例列表中删除1:1,因为即使删除所有比例,它也始终存在。

pBe 发表于 2022-7-6 08:33:51

(setvar专家5)
 

(defun c:IS_( / Scalelist i n)
   (setvar "cmdecho" 0)
   (setvar "expert" 5)
   (setq ScaleList
                (list
                      '("1:2" "1:2")
                      '("1:4" "1:4")
                      '("1:8" "1:8")
                      '("1\" = 1'-0\"" "1:12")
                      '("1/2\" = 1'-0\"" "0.5:12")
                      '("1/4\" = 1'-0\"" "0.25:12")
                      '("3/16\" = 1'-0\"" "0.01875:12")
                      '("1/8\" = 1'-0\"" "0.125:12")
                      '("3/32\" = 1'-0\"" "0.09375:12")
                      '("1/16\" = 1'-0\"" "0.0625:12")
                      '("1/32\" = 1'-0\"" "0.03125:12")
                      '("1/64\" = 1'-0\"" "0.015625:12")
                      '("1\" = 10'-0\"" "1:120")
                      '("1\" = 20'-0\"" "1:240")
                      '("1\" = 25'-0\"" "1:300")
                      '("1\" = 30'-0\"" "1:360")
                      '("1\" = 40'-0\"" "1:480")
                      '("1\" = 50'-0\"" "1:600"))
         )
   (command "_.-scalelistedit" "a")
   (repeat (setq i (length ScaleList))
         (setq n (nth (setq i (1- i)) ScaleList))
         (command
               (car n)
               (cadr n)
               (if (zerop i)
                     "e"
                     "a"))
         )
   (princ)
   )

SELFCAD 发表于 2022-7-6 08:38:30

如果我想抹掉所有的英寸刻度?

pBe 发表于 2022-7-6 08:42:31

 
什么意思?

SELFCAD 发表于 2022-7-6 08:50:44

我只想保持1:1、1:10、4:1。。。。结束以全部擦除
1/2 \“=1'-0…其他英寸刻度。。。

pBe 发表于 2022-7-6 08:54:09

在Annoscale列表中添加一项是一回事,但删除particualr named scale并不需要lisp代码
 
但是给你一个主意
 
(defun ScaleList (/ a)               
(foreach
          scle(dictsearch (namedobjdict) "ACAD_SCALELIST")
         (if (= 350 (car scle))
         (setq a (cons (cdr (assoc 300 (entget (cdr scle)))) a)))
   a
         )
   )
 
这将为您提供当前的scalelist,您只需找到要删除的并将其传递(命令“_。-scalelistedit”…)与我之前发布的内容类似

SELFCAD 发表于 2022-7-6 08:58:35

似乎是这样的问题:(命令“-scalelistedit”“d”“1/16”=1'-0”““e”)
1/16“=1'-0”。。。太多“”

pBe 发表于 2022-7-6 09:02:05

 
(命令“-scalelistedit”“d”“1/16\”=1'-0\“e”);
 
 

(defun c:ErInch(/ ScaleList)
(defun ScaleList(/ a)
   (foreach
          scle
            (dictsearch (namedobjdict) "ACAD_SCALELIST")
         (if (= 350 (car scle))
               (setq a    (cons (cdr(assoc
                                          300
                                          (entget
                                                (cdrscle))))
                              a)))
         a
         )
   )
   (foreach
            n(ScaleList)
         (wcmatch n "*\"")
         (command "_.-scalelistedit" "_D" n "e")
         )
   (princ)
   )

 
注意:如果比例是当前比例或由注释性对象支持,则无法删除该比例。
 
示例消息:
比例1“=1”被引用,因此无法删除。

SELFCAD 发表于 2022-7-6 09:07:44

太好了,谢谢!
页: [1] 2
查看完整版本: 比例列表编辑Lisp错误