Hello,
I have a lisp (OPP-OM see attachment) that works fine; when I first select a polyline and in second place a block, in which specified attributes are included, the area of the polyline is added to the attribute "VLOEROPP" and the length of the polyline is added to the attribute "OMTREK".
What I would like to achieve is that also the Handle of the selected polyline will be added to the attribute "VLRHANDLE_AUTOCAD".
I have the code below to get the Handle of an entity but I don't know how to combine this within the existing lisp OPP-OM.
(setq en (car (entsel "\nPick an entity: "))) ; pick your line at the prompt
(entget en) ; this will get the data list
(cdr (assoc 5 (entget en))) ; gives the handle
Thanks in advance!
Solved! Go to Solution.
Solved by hak_vz. Go to Solution.
(defun c:OPP-OM (/ atts i obj pl blk) (while (and (setq pl (car (entsel "\nSelect polyline <exit>: "))) (or (wcmatch (cdr (assoc 0 (entget pl))) "ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE") (prompt "\nWrong selection, need ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE.")) (setq blk (car (entsel "\nSelect block: "))) (or (= "INSERT" (cdr (assoc 0 (entget blk)))) (prompt "\nWrong select, need block.")) (setq obj (vlax-ename->vla-object blk)) (setq atts (vlax-invoke obj "GetAttributes")) ) (foreach att atts (cond ((= (vla-get-tagstring att) "VLOEROPP") (vla-put-textstring att (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object pl)) ">%).Area \\f \"" "%lu2%pr1%ct8[1.000000000000000E-006]" "\">%" )) (vl-cmdf "_.updatefield" (vlax-vla-object->ename att) "")) ((= (vla-get-tagstring att) "OMTREK") (vla-put-textstring att (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object pl)) ">%).Length \\f \"" "%lu2%pr1%ct8[1.000000000000000E-003]" "\">%" )) (vl-cmdf "_.updatefield" (vlax-vla-object->ename att) "")) ((= (vla-get-tagstring att) "VLRHANDLE_AUTOCAD") (vla-put-textstring att (cdr (assoc 5 (entget pl)))) (vl-cmdf "_.updatefield" (vlax-vla-object->ename att) "")) ))) (princ) )
This section colored red adds polyline handle to selected block. I didn't check it in Acad, but since object handle is a string, it should work.
Miljenko Hatlak
Can't find what you're looking for? Ask the community or share your knowledge.