从Pline到替换tex的区域
我需要一些帮助来解决lisp例程的问题。cad2009早期版本中的常规工作在2013年将不起作用。在拾取多段线后,我试图用平方英尺的面积替换文字值。我只能用平方英寸替换文字。
;;;CADDMAN: Area7.LSP Area Output (c) 2007 Kirby Turner
(defun c:area7 (/ a1)
(SETQ A1 (ENTSEL "Area of tract<pickobject>: "))
(command "area" "e" a1)
(setq el (getvar "area"))
(setq d1 144)
(setqfl (rtos (el 2 2))
(setqe1 ( / f1 d1)
;;;(rtos(/ e1 144.0) 2 3)
;;;(rtos (/ e1 144.0) 2 3)
(SETQED(ENTGET (CAR (NENTSEL "\nPick TEXT to change:"))))
(setvar"CMDECHO" 0)
(COMMAND"TEXTEVAL" 1)
(SETQ ED(SUBST (cons 1 e1)
(ASSOC 1 ED)
ED
)
)
(ENTMOD ED)
)
(alert
(strcat"area7.LSP"
"\n\n Type area7 to start"))
(princ)
我有这个
;获取区域。lsp-选定多段线图元的总面积。
(defun C:GetArea()
;turn off the system echo
(setvar "cmdecho" 0)
;set up a variable to hold the accumulated areas
(setq myArea 0)
;while the user keeps making a selection
(while(setq ent(entsel))
;if an entity was selected and not a point in space
(if(car ent)
(progn
;let AutoCAD get the area of the object...cheap yet effective way out...
;Note: AutoCAD stores the area in the system variable "Area"
(command "area" "Object" (car ent))
;print the area to the command line
(princ (strcat "\n Ε = " (rtos (getvar "Area") 2 2)" sq.m"))
;accumulate the area if it exist
(if (getvar "Area")(setq myArea(+ myArea (getvar "Area"))))
)
)
)
;ask for a text insertion point
(setq pt1(getpoint "\n pick a point: "))
;print the area in the drawing
(command "text" pt1 "" "" (strcat "E = "(rtos myArea 2 2)" sq.m"))
;suppress the last echo
(princ)
)
我有acad2012 你试过看这幅画的单位吗?也可以使用cvunits功能,而不仅仅是手动乘法/除法。
否则,你可以尝试其他各种例程,从许多在这些论坛(和其他论坛)上提供了他们的代码-只要做一个搜索,我相信你应该能够得到一些东西。E、 g.我的DimArea命令实际上在文本对象内放置了一个自动更新字段,该字段可以通过添加和/或减去多条多段线/图案填充等组成。 你需要在LISP中这样做吗?到2012年,我认为fields是一种更好的方法。
dJE 欢迎来到CADTutor。我倾向于同意,这可以很容易地在一个战场上完成,并且-dwgunits司令部可能会对报告该地区的部队有所了解。如果你真的想lisp,李Mac有至少3个不同的处理面积函数,其中这个链接将带你到一个。。。http://www.lee-mac.com/arealabel.html. 谢谢李!
页:
[1]