你如何检查存在
Autocad Civil 3D 2010。我试图通过lisp将一组视口比例导入到图形中。问题是,当我重置比例列表时,它只加载civil Scale。我还需要建筑规模。
我可以很容易地单独加载天平,如下所示:
(命令“-scalelistedit”“add”“1/16\”=1'-0\“0.0625:12”“e”);
但是,如果该比例已经存在,则scalelistedit需要稍有不同的选项,因此脚本暂停。
我在寻找这样的东西:
(如果(tblsearch“ViewportScale”“3/22\”=1'-0\“”)
(命令“-scalelistedit”add“3/32”=1'-0“Y”0.0938:12“e”)
(命令“-scalelistedit”“add”“3/32\”=1'-0\“0.0938:12”“e”)
)
但是,我在任何地方都找不到要搜索的有效表的列表,所以我甚至无法验证tblsearch命令在这里是否有效。
有什么建议吗? 也许在我走得太远之前,在Acad 2010中,自动将视口比例引入图形的标准方法是什么? 我不确定,我在很大程度上使用了视口工具栏,但我相信它可以设置缩放百分比。 我希望这能让你朝着正确的方向前进。
来自Acad帮助部分
视口的属性
Displays the properties of the selected layout viewport.
Property name
(by category)
Description
;
Geometry
Center X
Center Y
Center Z
Specifies the X,Y,Z coordinate values for the center of the viewport Width Specifies the width of the viewport; the width of a viewport is the X axis measurement of the area within a viewport frame Height Specifies the height of the viewport; the height of a viewport is the Y axis measurement of the viewport frame
;
Misc
On Determines whether the viewport is on or off
Clipped Determines whether viewport clipping is on or off
Display locked Determines whether viewport locking is on or off
Standard scale Specifies the standard scale for the viewport
Custom scale Specifies a custom scale for the viewport
UCS per viewport Determines whether the UCS is saved with the viewport or not
Shade Plot Specifies how views are plotted
要清楚的是,我并没有试图设置单个视口的比例。我试图填充窗口底部的可用视口列表,以及可以通过运行“Scalelistedit”命令手动编辑的列表。 嗨,马特,
此功能可以帮助您检查存在哪些刻度:
(defun GetScaleList (/ dic l)
(vl-load-com)
;; Lee Mac~25.03.10
(if (not (vl-catch-all-error-p
(setq dic (vl-catch-all-apply
(function vla-item)
(list (vla-get-Dictionaries
(vla-get-ActiveDocument
(vlax-get-acad-object))) "ACAD_SCALELIST")))))
(vlax-for scl dic
(setq l (cons (cdr (assoc 300 (entget (vlax-vla-object->ename scl)))) l))))
l)
另一个:
(defun GetScaleList (/ dic)
(vl-load-com)
;; Lee Mac~25.03.10
(if (setq dic (dictsearch (namedobjdict) "ACAD_SCALELIST"))
(mapcar
(function
(lambda (x) (cdr (assoc 300 (entget (cdr x))))))
(vl-remove-if-not
(function
(lambda (x) (= 350 (car x)))) dic))))
如果您要使用Lee Mac在上文第#6页中的第二个选项,您可以填充比例列表。不过,您需要编辑以下内容以满足您对建筑比例的需求,类似于您在第1篇文章中的示例。
(setq scllst (getscalelist))
(if (not (member'"1\" = 1'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 1'" "1:1"))
(if (not (member'"1\" = 2'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 2'" "1:2" "e"))
(if (not (member'"1\" = 3'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 3'" "1:3" "e"))
(if (not (member'"1\" = 4'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 4'" "1:4" "e"))
(if (not (member'"1\" = 5'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 5'" "1:5" "e"))
(if (not (member'"1\" = 10'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 10'" "1:10" "e"))
(if (not (member'"1\" = 20'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 20'" "1:20" "e"))
(if (not (member'"1\" = 30'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 30'" "1:30" "e"))
(if (not (member'"1\" = 40'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 40'" "1:40" "e"))
(if (not (member'"1\" = 50'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 50'" "1:50" "e"))
(if (not (member'"1\" = 60'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 60'" "1:60" "e"))
(if (not (member'"1\" = 80'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 80'" "1:80" "e"))
(if (not (member'"1\" = 100'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 100'" "1:100" "e"))
(if (not (member'"1\" = 150'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 150'" "1:150" "e"))
(if (not (member'"1\" = 200'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 200'" "1:200" "e"))
(if (not (member'"1\" = 400'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 400'" "1:400" "e"))
(if (not (member'"1\" = 500'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 500'" "1:500" "e"))
(if (not (member'"1\" = 2000'" scllst))(vl-cmdf "-scalelistedit" "a" "1\" = 2000'" "1:2000" "e"))
也许用一种更简洁的方式来表达拉里
(setq scllst (getscalelist))
(mapcar
(function
(lambda (name ratio)
(if (not (vl-position name scllst))
(vl-cmdf "_.-scalelistedit" "_a" name ratio "_e"))))
'("1\" = 1'" "1\" = 2'" "1\" = 3'")
'("1:1" "1:2" "1:3"))
好多了。。。我必须学习并掌握mapcar&lambda
前一段时间,我为了一个特定的问题做了上述操作——它奏效了,所以我退出了。 只需将lambda视为任何其他子功能,mapcar就可以正常使用它
我们可以将上述内容改写为:
(defun checkScale (name ratio)
(if (not (vl-position name scllst))
(vl-cmdf "_.-scalelistedit" "_a" name ratio "_e")))
(setq scllst (getscalelist))
(mapcar 'checkScale
'("1\" = 1'" "1\" = 2'" "1\" = 3'")
'("1:1" "1:2" "1:3"))
页:
[1]
2