Jump to content
thanhdattdk

Code Lisp entget Hatch

Recommended Posts

thanhdattdk

Hello everbody. Thank all for read my thread

I want to determine the blue dot coordinates but fail. i hope everybody help me code lisp

My code

;;------------------------------=={  2017  }==-------------------------------;;
(prompt "\n=={Created by PHÒNG TKCD - CIENCO625******************************}==")
(prompt "\n=={Thanhdattdk@gmail.com******************************}==")
;;---------------------------------------------------------------------------;;
(defun c:mm ()
(princ "\nCh\U+1ECDn c\U+00E1c Hatch c\U+1EA7n t\U+1EA1o l\U+1EA1i Boundary : ")
(command "-style" "DIENTICH" "arialbd_0.ttf" "0" "0.9" "0" "n" "n")
(setq tnct (ssget (list (cons 0 "HATCH"))))
(setq i 0)
(setq lmt (sslength tnct))
(while (< i lmt)
		(setq e (ssname tnct i))
		(setq laynd (entget e))
		[b][color="blue"](setq td (cdr (assoc 10 laynd)))[/color][/b]
	;tao tap rong de tinh dien tinh cho Hatch tao nhieu PL
	(setq S 0)
	(setq Q (entlast) AA (ssadd))
	(command "-hatchedit" e "B" "P" "")
	(while 
	(setq Q (entnext Q))
	(setq AA (ssadd Q AA))
	)
;tinh dien tich cac phan tu cua group vua tao
(setq j 0)
(setq dat (sslength AA))
(while (< j dat)
(setq doituong (ssname AA j))
(command "area" "o" doituong)
(setq Si (getvar "area"))
(setq S (+ S Si))
(setq j (+ j 1))
)
(princ S)
(princ td)
(command ".ERASE" AA "")
;viet text len vi tri hatch
(command "text" "ml" td "2.5" "0" S "")
(setq i (+ i 1))
);END WHILE
(princ))

Untitled.jpg

Share this post


Link to post
Share on other sites
BIGAL

A quicker way maybe is use BPOLY it makes a pline of your hatch boundary, you can then get simply the co-ordinates of the new pline and theer are some centroid routines out there as well.

Share this post


Link to post
Share on other sites
Roy_043

Since you are using the point to position text, why not calculate the center of the boundingbox instead of the centroid?

Share this post


Link to post
Share on other sites
thanhdattdk

thank you very much.

(setq Rec (acet-ent-geomextents e)

pt1 (nth 0 Rec);lay dinh

pt2 (nth 1 Rec);lay dinh

mid (acet-geom-midpoint pt1 pt2)

);setq

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×