First of all, I want to thank each of the users that with their great help I have been able to learn a little about Lisp.
I hope and some of you can help me with this code to add the total length of dynamic blocks that have a stretch parameter.
Basically the code works well; asks the user to enter the name of the parameter and then performs its function.
There is a problem: if I select other dynamic blocks that have another parameter by name, it does not work; I would like to be able to solve that problem. Any ideas?
I would also like it to be repeated multiple times and that the previous user's entry be saved for the name of the parameter.
I hope it's not too much to ask. From Mexico I thank you very much, and I apologize for my English, which is not very good. I will be very grateful if someone can help me.
;Suma en bloques dinamicos: Indicando el nombre del parametro
;Solo seleccionar bloques dynamicos que tengan ese parametro
(vl-load-com)
(defun c:SUMBD
(/ total selectionset count intger selectionsetname obj AR)
(setq AR (getstring t "\nNOMBRE PARAMETRO: "))
(defun LM:getdynpropvalue ( blk prp )
(setq prp (strcase prp))
(vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
(vlax-invoke blk 'getdynamicblockproperties)
)
)
(if (setq total 0
selectionset
(ssget '((0 . "INSERT")
(-4 . "<or")
(2 . "`*U*")
(2 . "_P1000")
(-4 . "or>")
)
)
)
(progn
(setq count (sslength selectionset))
(repeat (setq intger (sslength selectionset))
(setq selectionsetname
(ssname selectionset
(setq intger (1- intger))
)
obj (vlax-ename->vla-object selectionsetname)
total (+ total
(LM:getdynpropvalue obj AR)
)))
(alert (strcat " CANTIDAD TOTAL DE BLOQUES DYNAMICOS :"
"< "
(itoa count)
" >"
"\n"
" LONGITUD TOTAL EN BLOQUES DYNAMICOS :"
"< "
(rtos total 2)
" >"
)
)
)
(princ)
)
(princ)
)