Jump to content

Code Lisp entget Hatch


Recommended Posts

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" "")
	(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))


Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)


Link to comment
Share on other sites

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.

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...