I am modifying stuff in a dynamic block insert entitity. There is no "endblk" entity at the end of these definitions and I need to cycle through every entity within the block definition. When it gets to the last entity, I get an error because you cannot entnext passed the last entity. There are 2 things I could use help with:
1. How to retrieve the # of entities in a block without cycling through it.
Or
2. A quick lesson in the *error* function, I cannot figure out how to implement this. I basically want to to say:
(if (entnext myent)) returns a error, don't abort & continue on.
Is this possible ?
Thanks
Here is one way to get the number of entities in a dynamic block. You can easily add your code to this. "cnt" is your entity count. Note that there isn't any error code.
(defun c:entcount (/ doc ent cnt)
(vl-load-com)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq ent (vlax-ename->vla-object (car (entsel))))
(setq cnt (vla-get-count (vla-item (vla-get-blocks doc)(vla-get-EffectiveName ent))))
)
That is awsome, thanks. I have been inserting a "point" entitiy within my blocks as the last thing I do, trying to get it as the last item in the block, when the code entnexted through the definition if it hit a "point" entity it would stop the loop. Most of the time it worked well.
Its weird how autocad designed these dynamic blocks, seems that only the entities that have a dynamic parameter on them are put into an additional anonymous block, I guess when the program looks at the block, it gathers the info from the insert entity, then continues to the actual block definition for the rest of the block where the "endblk" listing is.
Thanks again
Can't find what you're looking for? Ask the community or share your knowledge.