Dien nguyen Posted December 7, 2023 Posted December 7, 2023 Currently I have written a lisp to get Hatch property information including Layer Name and Area into Mutileader, now it works. How it works is as follows: Load lisp => HJ command => Pick Hatch, Pick point, Pick point => Done Then I want to edit the lisp to be able to work with blocks, but when I insert the block I don't see a place to insert the properties taken from Hatch. Below is the lisp with Mutileader and attached is my final completed block. (vl-load-com) (defun Get-ObjectIDx64 (obj / utl) (setq utl (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) (if (= (type obj) 'VLA-OBJECT) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method utl "GetObjectIdString" obj :vlax-False) (rtos (vla-get-objectid obj) 2 0)))) (defun C:HJ (/ obj objID area hname content units) (while (setq sset (car (entsel))) (setq obj (vlax-ename->vla-object sset)) (setq objID (Get-ObjectIDx64 obj)) (setq hname (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Layer \>%" )) (if (getvar "INSUNITS") ; (setq units (getvar "INSUNITS")) (setq units 4) ; ) (setq area (cond ((= units 4) ; (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Area \\f \"%lu2%pr1%ct8[1.0E-006]\">%")) ((= units 6) ; (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Area \\f \"%lu2%pr1\">%")) ) ) (setq content (strcat hname "\n" area "m²")) (if (and (setq pnt (getpoint "\nPick Leader Base point: ")) ;(setq pnt (trans pnt 1 0)) ) (command "_.mleader" "_none" pnt PAUSE content) ) (princ) ) ) Tag Block.dwg Quote
BIGAL Posted December 7, 2023 Posted December 7, 2023 (edited) You dont need a defun for ID may have been needed for older Cad versions. I just re-arranged a bit. (defun C:HJ (/ obj objID area hname content units) (while (setq obj (vlax-ename->vla-object (car (entsel "\nSelect hatch Enter to exit ")))) (setq objID (rtos (vla-get-objectid obj) 2 0)) (setq hname (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Layer \>%" )) ; (if (getvar "INSUNITS") ; is this needed ? (setq units (getvar "INSUNITS")) ; (setq units 4) ; ) (cond ((= units 4)(setq area (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Area \\f \"%lu2%pr1%ct8[1.0E-006]\">%"))) ((= units 6)(setq area (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Area \\f \"%lu2%pr1\">%"))) (progn (Alert "Incorrect insunit value")(exit)) ) (setq content (strcat hname "\n" area "m²")) (setq pnt (getpoint "\nPick Leader Base point: ")) (command "_.mleader" "_none" pnt PAUSE content) ) (princ) ) Edited December 7, 2023 by BIGAL Quote
Dien nguyen Posted December 8, 2023 Author Posted December 8, 2023 With this lisp it work with multileader, However I find way to insert block with property of selection hatch. 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.