TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ArgV on August 14, 2009, 10:00:13 PM
-
Hey all. Good weekend. :)
Is there a way to, rather than iterating through the block collection for each block I have in a blockNameList, just find it using the blocks name to go strait to it?
I think it can be done, but I can't remember how it's done or what the syntax is.
thanks!
-ArgV
-
(vl-catch-all-apply '(lambda ()
(vlax-ename->vla-object (tblobjname "block" name))
)
)
-
I do it using Library functions
Library stuff
(defun kdub:safeitem (collection item / returnvalue)
(if (not (vl-catch-all-error-p
(setq returnvalue (vl-catch-all-apply 'vla-item
(list collection item)
)
)
)
)
returnvalue
)
)
(defun kdub:block-p (name)
(kdub:safeitem (vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
name
)
)
The Code :
(setq BlockObject (kdub:block-p "TheBlockNameIWantToFind"))
-
I do it using Library functions
Library stuff
(defun kdub:safeitem (collection item / returnvalue)
(if (not (vl-catch-all-error-p
(setq returnvalue (vl-catch-all-apply 'vla-item
(list collection item)
)
)
)
)
returnvalue
)
)
(defun kdub:block-p (name)
(kdub:safeitem (vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
name
)
)
The Code :
(setq BlockObject (kdub:block-p "TheBlockNameIWantToFind"))
Ok, cool. Thank you. :)
-
(vl-catch-all-apply '(lambda ()
(vlax-ename->vla-object (tblobjname "block" name))
)
)
Thank you for replying. I was more looking for the object collection. Sorry I wasn't very clear on that. :|
-
Object collection? There's no such thing.
-
I think it depends upon what you are trying to achieve ArgV - could you explain a bit more.
-
Object collection? There's no such thing.
Sorry, was in a hurry. BLOCK collection. :-o
-
Is this matter resolved now ArgV?
-
I think it depends upon what you are trying to achieve ArgV - could you explain a bit more.
I got it. I was looking for:
(if (not (vl-catch-all-error-p
(setq returnvalue [color=red](vl-catch-all-apply 'vla-item
(list collection item)[/color]
)
)
)
)
returnvalue
)
-
Cool :-)