I am looking for a lisp to install dimension automatically on a hatch ?

I am looking for a lisp to install dimension automatically on a hatch ?

giscivil92
Advocate Advocate
561 Views
5 Replies
Message 1 of 6

I am looking for a lisp to install dimension automatically on a hatch ?

giscivil92
Advocate
Advocate

Hi Everyone

I am looking for a lisp to install dimension automatically on a hatch like this.

giscivil92_0-1709169483955.png

 

 

0 Likes
Accepted solutions (1)
562 Views
5 Replies
Replies (5)
Message 2 of 6

Sea-Haven
Mentor
Mentor

Look into HatchB.lsp this makes a pline representing the boundary of a hatch, then get all vertice points then can look for Min X point Max X point and do dim. Hint Vl-sort on list of X & Y,  1st is min last is max. ((134.45 678.99)(........

 

 

 

 

(setq plent (entsel "\nPick pline"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))
(princ co-ord)

 

 

 

0 Likes
Message 3 of 6

komondormrex
Mentor
Mentor
Accepted solution

hey there,

check the following

 

 

(defun c:dim_hatch (/ hatch_sset llc urc hatch_vertices left_most_dim_point right_most_dim_point dim_object)
	(if (setq hatch_sset (ssget '((0 . "hatch"))))
			(foreach hatch (vl-remove-if 'listp (mapcar 'cadr (ssnamex hatch_sset)))
				(vla-getboundingbox (vlax-ename->vla-object hatch) 'llc 'urc)
				(setq llc (vlax-safearray->list llc)
					  urc (vlax-safearray->list urc)
					  hatch_vertices (mapcar 'cdr (vl-remove-if-not '(lambda (group) (member (car group) '(10 11))) (entget hatch)))
				)
				(vl-some '(lambda (vertex) (equal (car llc) (car (setq left_most_dim_point vertex)) 1e-4)) hatch_vertices)
				(vl-some '(lambda (vertex) (equal (car urc) (car (setq right_most_dim_point vertex))1e-4)) hatch_vertices)
				(setq dim_object (vla-adddimrotated (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
													(vlax-3d-point left_most_dim_point)
													(vlax-3d-point right_most_dim_point)
													(vlax-3d-point (polar llc (* 1.5 pi) (* 2 (getvar 'dimtxt))))
													0
								 )
				)
			)
	)
    (princ)
)

 

 

Message 4 of 6

Sea-Haven
Mentor
Mentor

If you look at a thin hatch at 45 degs then Vla-getboundingbox may not be suitable as it is a Box lower Y is same left or right or but using a pline reflecting the hatch shape would mean the extension lines go to correct point.

 

SeaHaven_0-1709254383673.png

 

The image is a road cross section so the left and right edges hopefully are vertical.

 

 

 

0 Likes
Message 5 of 6

komondormrex
Mentor
Mentor

your right, but op showed not that kind of hatch as far as i can figure from his pic attached.

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

You are right so often we guess a bit as do not have a real dwg.

0 Likes