需要小帮助,获得普林斯
大家好,我正在做一个lisp,并试图在屏幕上显示一条错误消息,说明出了什么问题以及为什么不能继续。
这是我的错误消息。它应该只显示一个。目前,它正在做这两件事。有人能告诉我为什么要这样做吗?
“***错误***绘图单位不是公制。请尝试英寸选项”
“***错误***绘图单位不是英寸。请尝试公制选项”
请原谅我的“不太干净”LISP编码方法。
我已经发布了截短的LISP,这里提到的一些defun没有附上。
谢谢
(defun C:PRES2A (/ OIU Dunits)
(setq OIU (getvar "insunits"))
(initget "I M")
(setq Dunits (getkword "\nIs this Inch template or Metric? (I,M) <Inches>:"))
(if (= Dunits nil) (setq Dunits "I"))
(if (and (= Dunits "I")
(= OIU 1)
(not (tblsearch "LAYER" "FORMAT"))
)
(progn
(Inch)
(blkrem)
(alert "\nblocks cleaning complete.")
); end progn
(princ "\n*** Error *** Drawing unit is not Inches. Try Metric option")
);end if
(if (and (= Dunits "M")
(= OIU 4)
(not (tblsearch "LAYER" "FORMAT"))
)
(progn
(Metric)
(blkrem)
(alert "\nBlocks cleaning complete.")
); end progn
(princ "\n*** Error *** Drawing unit is not Metric. Try Inch option")
);end if
(princ)
) ; end of program
变量Dunits的选择是“I”或“M”,因此如果Dunits是“I”,则它不能是“M”,反之亦然。如果表达足够的话。
请记住,INSUNIT有20个可能的值。
此外,该表达式(非(tblsearch“LAYER”“FORMAT”))应位于程序的开头,因为它是一个要求,与Dunits值无关。 像这样的?我猜你画的单位不是1或4。如上所述;有点多余,但我刚刚添加到您的代码中。
(defun c:pres2a (du / iu)
(setq iu (getvar 'insunits))
(if
(= iu (or 1 4))
(progn
(initget "i m")
(if
(= du nil)
(setq du "i")
)
(setq du (getkword (strcat "\nIs the drawing imperial or metric <" du "> : ")))
(if
(and
(= du "i")
(= iu 1)
(not (tblsearch "LAYER" "FORMAT"))
)
(progn
(Inch)
(blkrem)
(alert "\nblock cleaning complete")
)
(princ "\n*** Error *** Drawing unit not imperial, use metric option!")
)
(if
(and
(= du "m")
(= iu 4)
(not (tblsearch "LAYER" "FORMAT"))
)
(progn
(metric)
(blkrem)
(alert "\nblock cleaning complete")
)
(princ "\n*** Error *** Drawing unit not metric, use imperial option!")
)
)
(princ "\nYou silly goose, units must be inches or millimeters!")
)
(princ)
)
你好,pBe
我认为你在这一点上是正确的。我需要在起跑线上加上这个。
嗨CheSyn
绘图单位始终为公制或英制,仅此两种。
:)
这就是为什么我要写这个lisp:图形是从Solidworks转换到AutoCAD的。dwg格式。进入AutoCAD后,我需要删除整个图纸,只保留内部对象。同时删除不再需要的标准块。由于英寸和公制的模板大小不同,我需要获取单位信息,以验证我是否错误地运行了要删除的错误坐标。
tblsearch是我最近添加的安全功能。如果有人意外或故意在标准AutoCAD图形上运行此实用程序,则模板包含一个名为“Format”的图层,该图层将检测并终止。我看到我的一些用户滥用了我的试用工具,但他们并不知道其中的原因。这是我最近学到的东西。但我确实希望他们把它搞乱,这样我就可以一步一步地进一步改进它。
谢谢你们的帮助。
当做
页:
[1]