TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mobile on December 08, 2015, 12:49:32 PM
-
Hi everybody, This is my firs post :)
My question is..It's possible to implement this lisp? Preface: I am just starting out with lisp. I tried this but I did not succeed :-(
I'll explain, I will select some dynamic blocks, then I insert a number "N" (es.1,2,3..) to increment an attribute called "PO", then the lisp add the value that I've inserted "N" at the value contained in the attribute "PO" before...Example: Block1(attribute"PO":34 -->N=2 -->attribute"PO":36), Block2(attribute"PO":25 -->N=1 -->attribute"PO":26)
thank you!
This is the lisp that I would like to modify:
;; Room Number Update by CAB 03/21/2005
;; Update selected blocks with attribute "ROOM#"
;; with user entered room number
;; NOTE: Very little error checking
;;
;; Modified a subroutine by Jeff Mishler 1/11/05
;;
(defun c:rm#update (/ rm# attname ss count blk atts2 att2 att1 bc)
(vl-load-com)
(setq rm# (getstring t "\nEnter new room number: ")
attname "ROOM#" ; uppercase only
bc 0) ; block counter
(prompt "\n*** Select blocks to change room number. ***")
;; get only blocks with attributes
(if (and rm#
(not (eq rm# ""))
(setq ss (ssget (list '(0 . "INSERT") '(66 . 1))))
)
(progn
(setq count -1)
(while (< (setq count (1+ count)) (sslength ss))
(setq blk (vlax-ename->vla-object (ssname ss count))
atts2 (vlax-invoke blk "getattributes")
)
(foreach att2 atts2
(if (= attname (vla-get-tagstring att2))
(progn
(vla-put-textstring att2 rm#)
(vla-update att2)
(vla-update blk)
(setq bc (1+ bc))
)
)
)
)
(prompt (strcat "\n-=< " (itoa bc) " blocked updated >=-"))
) ; progn
(prompt "\n--- No blocks Updated ---")
) ; endif
(princ)
) ; defun
(prompt "\nRoom Number Update Loaded, Enter Rm#Update to run.")
(princ)
-
Here's a quick routine to increment attribute values. Welcome to the swamp :)
(defun c:inc
(/ _ss2list i str
) (defun _ss2list
(ss
/ n out
) )
)
)
)
)
)
)
)
-
Wow thank you! It works :-) :-)
-
:-)
-
Hi ronjonp,
I have a problem whit your lisp :cry:...I have a dynamic block, and when I remumerate th attriute "PO" whit your lisp, it renumerate all the attribure, and so will increment all the attribute, and not only the attribute "PO"
See the problem...
(http://s8.postimg.org/eqmti5h8l/image.png)
I start the lisp, and I apply the increment by 3:
(http://s8.postimg.org/prhyn69hh/2_problem.png)
In the correct mode...:
(http://s2.postimg.org/blrcl6pex/2_with_the_increment_correct.png)
Could you help me another time? Sorry...
Thank you in advance
-
Try this:
(defun c:IncPO
(/ _ss2list i str
) (defun _ss2list
(ss
/ n out
) )
)
)
)
)
)
)
)
)
-
Thank you! Now It works exactly :)