多个增强属性ed
你好我是新来的,所以如果我要求一些已经写好的东西,不要生气。
所以,正如标题所说,我需要一个lisp例程来更改块的属性。
具体来说,我需要更改块中多个点的高程。
我在网上找到了一些lisp例程,但并没有达到我的预期。
这是一个最接近我要求的Lisp程序的句子:
(defun pluserr (msg)
(if msg (princ msg))
(command "_.undo" "_end")
(if ps (setvar "pickstyle" ps))
(if olderr (setq *error olderr))
(princ)
)
(defun c:smileytongue:lus (/ ps plusval ent elist numstr num tval plcs elist2)
(setq ps nil plusval nil ent nil elist nil numbstr nil num nil tval nil
plcs nil elis2 nil)
(setq olderr *error* *error* pluserr)
(command "_.undo" "_g")
(setq ps (getvar "pickstyle"))
(setvar "pickstyle" 0)
(setq plusval (getreal "\n Plus value: "))
(setq plcs (getint "\nHow many decimal places? <0>: "))
(if (null plcs) (setq plcs 0))
(setq ent (nentsel))
(while ent
(setq elist (entget (car ent)))
(setq numstr (cdr (assoc 1 elist)))
(setq num (atof numstr))
(setq tval (+ plusval num))
(setq total (rtos tval 2 plcs))
(setq elist2 (subst (cons 1 total) (cons 1 numstr) elist))
(entmod elist2)
(if (= (cdr (assoc 0 elist)) "ATTRIB")(command "regen"))
(setq ent (nentsel))
);end while
(setvar "pickstyle" ps)
(command "_.undo" "_end")
(setq *error olderr)
(princ)
)
好这很好,但它允许选择多个对象或整个块。
它还改变了点的整个高程,但我想将原始高程添加到新高程。举个例子:如果我有一个高程为230,33的点,并想“删除”该高程为0,5。所以一个新的高度是229,83。
因此,如果我为多个点更改此高程,则会将选定点的所有高程减0,5(或我确定的其他值)。
我附上了一张我的点块看起来是什么样子的照片
如果有人能帮助我,我会很高兴。
希望我能让你康复。。。。
(defun c:TesT (/ st ss i n e x)
(vl-load-com)
;; Tharwat 12. Dec. 2011 ;;
(cond ((not acdoc)
(setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
)
)
(if (and (setq st (getdist "\n Enter Number to substract :"))
(setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
)
(progn
(vla-StartUndoMark acdoc)
(repeat (setq i (sslength ss))
(setq n (entnext (ssname ss (setq i (1- i)))))
(while
(not
(eq (cdr (assoc 0 (setq e (entget n))))
"SEQEND"
)
)
(if (and
(eq (cdr (assoc 0 e)) "ATTRIB")
(not (eq (atof (cdr (assoc 1 e))) 0.))
)
(entmod
(subst (cons 1 (rtos (- (atof (cdr (assoc 1 e))) st)2 )) (assoc 1 e) e)
)
)
(setq n (entnext n))
)
)
(vla-EndUndoMark acdoc)
)
(princ)
)
(princ)
)
请阅读代码发布指南并编辑您的帖子。
现在很多人都是新手,大多数人不熟悉代码发布,但肯定会按时来 谢谢你的快速回复。
我测试了你的例程,它可以工作,但通过更改点高度(高程),它也会更改点编号。
我只想更改一个属性,即点高度(高程)。
还有一个问题,我试图将rtos精度设置为2位小数(rtos x 2 2),但我找不到这个设置数字的位置。我只找到了设置rtos模式的数字。
现在我将点高度精度设置为4位小数。(这对于我需要的东西来说有点太精确了)
请告诉我在哪里可以更改rtos精度? 不客气,科贝克。
更改例程中数字的精度,这与您在示例中所示的相同。
这是你可以改变精度的部分,你增加精度的数字也会增加。
(if (and
(eq (cdr (assoc 0 e)) "ATTRIB")
(not (eq (atof (cdr (assoc 1 e))) 0.)))
(entmod(subst (cons 1 (rtos (- (atof (cdr (assoc 1 e))) st) 2 2)) ;;;<-- Change the Blue colored number to see the changes in precisions.
(assoc 1 e) e)))
... Do't mean to step your toes there tharwat,i also post the same mod for your code on my post.我不是有意在那里踩你的脚,我也在我的帖子上为你发布了相同的mod代码。
完全没有,我的朋友。
我确实希望看到在同一问题上有许多编码方式。
干杯pBe。 非常感谢大家的帮助!
我试图理解这个lisp代码,有人能解释一下这部分代码的含义吗:“(0)”插入“)(66.1))”?
好的,现在出现了一个新问题。在以前的lisp例程中,我想添加或删除点高度(高程),但现在我需要将每个示例中相同点的文本高度从0.350更改为0.500。
有人能帮我做这个吗? Kocbek你需要一个不同的程序,基本上是对提供的程序的修改,唯一的区别是额外的一行
输入存在值
输入新值
该行也将更改,它不执行-(entmod(subst(cons 1(rtos)((atof(cdr(assoc 1 e)))st)2 2))(assoc 1 e)
上面的海报最好能有所改变,以防我搞砸了什么
Ps Tharwat getdist应该是getreal吗
页:
[1]
2