Ament Posted January 20 Posted January 20 Hallo again, I'm back with an issue and my limited amount of experience is kicking in. I'd really appreciate if someone could hint me into the correct direction. I'm currently trying to get the center of area from a polyline using lisp. As far as to get it from a polyline if I directly select it is not an issue. I'm converting it to a region, write and read the output from massprop into/from a file and have them by hand to use them further down the road. But my real usecase is, that I need to loop through a selection set containing several blocks. Each of those has an attributes called "AREA" inside. That is filled with a field referencing the area of a closed polyline. (I use a slightly modified version of Lee Macs "Area field to attribute" macro to do so.) As the area indicated in the attribute is updating when I modify the polyline and regenerate, I'm pretty sure that they are linked. Therefore I'd like to use a piece of code to identify the referenced polyline and get the ObjectID/Ename of it for the use further down the road in my macro. I've tried to modify Lee Macs "Field Objects" lisp and get the clues out of there, but failed doing so. Anyone who can help me there? Thank you and best regards, Ament Quote
GLAVCVS Posted January 20 Posted January 20 It would be a great idea if you attached a dwg with some of those blocks Quote
Ament Posted January 20 Author Posted January 20 Hi GALVCVS, your wish is my command with that one. Please find a sample attached. The actual file is to big to be shared. Just imagine it to contain over 1k of those blocks. Therefore an automation instead of doing it manually. BR, Ament DWG-Sample_ObjID_from_Attributefield.dwg Quote
Lee Mac Posted January 20 Posted January 20 You should be above to use my Field Objects function to obtain the referenced entity directly - no modification should be required. Quote
Ament Posted January 20 Author Posted January 20 Hi Lee Mac, thank you for your help, I've tried to use it without any modification, but when selecting the block that is containing the attribute I only get back "Selected object is not a field, or field doesn't reference any objects." I guess when selecting the block I'm missing the link to drill down to the attribute called "AREA" to pass that into the function from above. Unfortunately I've big difficulties to find that using my macro skill. Quote
LanloyLisp Posted January 20 Posted January 20 Hi Ament, Blockedit the block and update the Invisible property of the Attribute definition (Area) object to "No". close the block editor and save. Type ATTSYNC at the command line and select the block to be updated. The filed value to be selected should now be visible. Quote
Lee Mac Posted January 20 Posted January 20 8 hours ago, Ament said: Hi Lee Mac, thank you for your help, I've tried to use it without any modification, but when selecting the block that is containing the attribute I only get back "Selected object is not a field, or field doesn't reference any objects." I guess when selecting the block I'm missing the link to drill down to the attribute called "AREA" to pass that into the function from above. Unfortunately I've big difficulties to find that using my macro skill. You'll need to invoke the function with the attribute entity, or select the attribute reference using the test program (which uses an nentsel selection). Quote
GLAVCVS Posted January 21 Posted January 21 I think a test implementation of Lee's code for your blocks could be: Quote (LM:fieldobjects (vlax-vla-object->ename (nth 3 (safearray-value (variant-value (vla-getattributes (vlax-ename->vla-object (car (entsel "\nSelect an \'AREA ATTRIBUTE\' block to get entity name of linked polyline..." ) ) ) ) ) ) ) ) ) Quote
Lee Mac Posted January 21 Posted January 21 I wouldn't rely on the attribute order, but rather acquire the attribute reference entity using its tag identifier, e.g.: (cond ( (not (setq ent (car (entsel))))) ( (/= "INSERT" (cdr (assoc 0 (setq enx (entget ent))))) (princ "Selected object is not a block.") ) ( (/= 1 (cdr (assoc 66 enx))) (princ "\nSelected block is not attributed.") ) ( (progn (setq att (entnext ent) atx (entget att) ) (while (and (= "ATTRIB" (cdr (assoc 0 atx))) (/= "AREA" (cdr (assoc 2 atx)))) (setq att (entnext att) atx (entget att) ) ) (= "SEQEND" (cdr (assoc 0 atx))) ) (princ "\nAREA attribute not found in selected block.") ) ( (LM:fieldobjects att) ) ) 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.