How to find objects that have been given a hatch?

How to find objects that have been given a hatch?

iBlachu
Advocate Advocate
267 Views
3 Replies
Message 1 of 4

How to find objects that have been given a hatch?

iBlachu
Advocate
Advocate

Hi,

 

How to find hatching envelope for drawing objects?

 

Or vice versa.

 

How to search for drawing objects to which a particular hatch?

0 Likes
268 Views
3 Replies
Replies (3)
Message 2 of 4

komondormrex
Mentor
Mentor

(find_hatch_bearer '()) - find objects having any hatch

(find_hatch_bearer '("ANGLE" "ANSI31")) - find objects having "ANGLE", "ANSI31" hatches

 

 

 

 

 

(defun find_hatch_bearer (hatch_name_list / object_dxf hatch_dxf hatch_bearer_sset)
  	(setq hatch_bearer_sset (ssadd)) 
	(vlax-map-collection
		(vla-get-modelspace (vla-get-database (vla-get-activedocument (vlax-get-acad-object))))
	   '(lambda (object)
				(cond
					(
						(and
							(member '(102 . "{ACAD_REACTORS") (setq object_dxf (entget (vlax-vla-object->ename object))))
							(= "HATCH" (cdr (assoc 0 (setq hatch_dxf (entget (cdadr (member '(102 . "{ACAD_REACTORS") object_dxf)))))))
							(if (zerop (length hatch_name_list)) t (member (cdr (assoc 2 hatch_dxf)) hatch_name_list)) 
						)
							(ssadd (vlax-vla-object->ename object) hatch_bearer_sset)					)
					(
						t
					)
				)
		)
	)
  	(sssetfirst nil hatch_bearer_sset)
	(princ)
)

 

 

Message 3 of 4

Moshe-A
Mentor
Mentor

@iBlachu  hi,

 

The quick way to get the hatch loops (boundaries) is through the hatch object.

try this HHLO command  😀

 

enjoy

Moshe

 

 

; Highlight Hatch Loops
(vl-load-com)

(defun c:hhlo (/ ss i j LoopObjs)
 (if (ssget '((0 . "hatch"))) ; pause for hatches
  (progn
   (setq ss (ssadd)) 
   (vlax-for AcDbHatch (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
    (setq i -1) 
    (repeat (vla-get-NumberOfLoops AcDbHatch)
     (vla-getLoopAt AcDbHatch (setq i (1+ i)) 'LoopObjs) ; get loop objects

     (setq j 0)
     (while (>= (vlax-safearray-get-u-bound LoopObjs 1) j)
      (ssadd (vlax-vla-object->ename (vlax-safearray-get-element LoopObjs j)) ss)
      (setq j (1+ j)) 
     ); while

     (foreach o (vlax-safearray->list LoopObjs)
      (vlax-release-object o); dispose memory
     )
      
    ); repeat
     
    (vlax-release-object AcDbHatch) ; dispose memory
   ); vlax-for

   (if (> (sslength ss) 0)
    (sssetfirst ss ss) ; highlight loops
   )
  ); progn
 ); if

 (princ)
); c:hhlo

 

Message 4 of 4

Kent1Cooper
Consultant
Consultant

@iBlachu wrote:

.... How to find hatching envelope for drawing objects?....


For that part, you don't need any code.  Select a Hatch object, and if it's Associative, its envelope object(s) will be selected along with it.  If it's not, right-click and choose Generate Boundary.

Kent Cooper, AIA
0 Likes