+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Junior Member
    Using
    AutoCAD 2016
    Join Date
    Aug 2016
    Posts
    20

    Default Code Lisp entget Hatch

    Registered forum members do not see this ad.

    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
    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))
     		(setq td (cdr (assoc 10 laynd)))
    		;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

  2. #2
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,720

    Default

    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.
    A man who never made mistakes never made anything

  3. #3
    Super Member
    Using
    not applicable
    Join Date
    Jun 2016
    Posts
    519

    Default

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

  4. #4
    Junior Member
    Using
    AutoCAD 2016
    Join Date
    Aug 2016
    Posts
    20

    Default Thank you very much

    Registered forum members do not see this ad.

    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

Similar Threads

  1. Replies: 14
    Last Post: 21st Jan 2015, 06:23 am
  2. Hatch pattern error, making a "Hatch Code" .pat
    By SDSinc in forum AutoCAD General
    Replies: 4
    Last Post: 18th Jan 2011, 03:25 pm
  3. Help with Sample code to Entmake a Hatch
    By TuFoFi in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 15th Dec 2009, 03:45 am
  4. entget problems!!!!
    By acatalin2003 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 27th Oct 2005, 07:05 pm
  5. Problem with entget
    By carmenaz in forum AutoLISP, Visual LISP & DCL
    Replies: 24
    Last Post: 26th May 2005, 09:39 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts