First, Thank you for posting this code. I have been searching for it a long time.
Second, I need further help! I have messed around with foreach, mapcar, etc and I have not been able to figure it out.
How do I change the line (setq obj (car (entsel) ) );*** to something like: (setq obj (ssget))?
So that I can enter a length and have it change the specific property in all objects selected.
(defun ChangePropertyLength()
(vl-load-com)
(setq acadObject (vlax-get-acad-object) )
(setq acadDocument (vlax-get-property acadObject 'ActiveDocument) )
(setq mSpace (vlax-get-property acadDocument 'Modelspace) )
(setq TheLength (getreal "\nWhat length? ") )
(setq obj (car (entsel) ) );***
(setq ename (vlax-ename->vla-object obj) )
(setq props (vlax-invoke ename 'getdynamicblockproperties) )
(foreach prop props
(setq name (vla-get-propertyname prop) )
(if
(eq name "TheLength")
(vla-put-value prop TheLength)
)
)
)
@Dewlevlak wrote:,,,,
How do I change the line (setq obj (car (entsel) ) );*** to something like: (setq obj (ssget))?
,,,,
(defun ChangePropertyLength (ent pnme len / props name)
(vl-load-com)
(setq props (vlax-invoke ent 'getdynamicblockproperties))
(foreach prop props
(if
(eq (strcase (vla-get-propertyname prop)) (strcase pnme))
(vla-put-value prop len)
)
)
)
(defun c:test ( / TheLength objs ename)
(if (and
(setq TheLength (getreal "\nWhat length? "))
(setq objs (ssget ":L" '((0 . "INSERT")))))
(repeat (setq i (sslength objs))
(setq ename (vlax-ename->vla-object
(ssname objs
(setq i (1- i)))))
(ChangePropertyLength
ename "TheLength" TheLength))
)
)
Thank you for your quick reply. I am trying it without success. Here is a sample file with a simple line block which has a length paramerter 'TheLength'. I would like to be able to change all of these lengths with LISP all at once. Then, I can train a Button to automatically change all these parameters in the drawing. I am able to change the lenth of one block selection at a time with (setq obj (car (entsel))).
Thanks again,
@Dewlevlak wrote:Thank you for your quick reply. I am trying it without success. Here is a sample file with a simple line block which has a length paramerter 'TheLength'. I would like to be able to change all of these lengths with LISP all at once. Then, I can train a Button to automatically change all these parameters in the drawing. I am able to change the lenth of one block selection at a time with (setq obj (car (entsel))).
Thanks again,
Guess i need to put it together for you then.
(defun c:chpname ( / ChangePropertyLength objs ename)
(vl-load-com)
;;; Generic sub for property name ;;;
(defun ChangePropertyLength (ent pnme len / props name)
(setq props (vlax-invoke ent 'getdynamicblockproperties))
(foreach prop props
(if
(eq (strcase (vla-get-propertyname prop)) (strcase pnme))
(vla-put-value prop len)
)
)
)
(if (and
(setq TheLength
(cond ((getdist
(strcat "\nEnter Length <"
(rtos (setq TheLength
(cond (TheLength) (1.00))
) 2 2 ) ">: " )))
(TheLength)))
(setq objs (ssget ":L" '((0 . "INSERT")))))
(repeat (setq i (sslength objs))
(setq ename (vlax-ename->vla-object
(ssname objs
(setq i (1- i)))))
(ChangePropertyLength
ename "TheLength" TheLength))
)
)
There are many ways to write this code, but i opted not to deviate from the orignal.
HTH
:smileyhappy Oh Sweet! That is so AWESOME! Thank you! Thank you! Thank you! That works great!
I will go through it to try to understand how it all works. But it does work in the drawings the way I needed it to!
Hello again
Thank you, your help has been very helpful. I have been able to modify and use your program to modify all parameters of blocks in the drawing for different purposes. I have come across another situation to which I need help.
I would like to change the "Visibility" of blocks nested in another block. I have a block in the drawing which has 3 blocks nested in it. How do I selet the nested blocks within a particular block to be changed?
Thanks again,
@Dewlevlak wrote:
I would like to change the "Visibility" of blocks nested in another block. I have a block in the drawing which has 3 blocks nested in it. How do I selet the nested blocks within a particular block to be changed?
Thanks again,
As it affect every instance of the block in the drawing might as well Bedit or Refedit the block then run the code there.
Thank you, that worked slick. Sometimes it is easy when programing to forget the simple used all the time AutoCAD commands.