Jump to content

Modify Lisp HatchProperty into Mutileader to Block Attribute?


Recommended Posts

Posted

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

Posted (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 by BIGAL
Posted

With this lisp it work with multileader, However I find way to insert block with property of selection hatch.

 

image.thumb.png.7e559019c9d7bfa813a7b432f592426b.png

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...