'insertion point' of a hatch

Discussion in 'AutoCAD' started by adw, Mar 3, 2005.

  1. adw

    adw Guest

    Hi,
    I would like to list the 'insertion point' of a hatch into a lisproutine. Where can I find the definition of this point, that lightens up when you click on a hatch. Any help is welcome.
    André
     
    adw, Mar 3, 2005
    #1
  2. adw

    BillZ Guest

    I was looking at this one.

    I thought it was but:

    The grip that appears when the hatch is selected is not the centroid of the hatch.

    I do have a way to get the centroid of the hatch (and the outline of it for that matter).

    Bill
     
    BillZ, Mar 3, 2005
    #2
  3. adw

    wkiernan Guest

    What is it? I'd sure appreciate it if you share it with us.
     
    wkiernan, Mar 3, 2005
    #3
  4. adw

    Jeff Mishler Guest

    In my very limited testing it appears that the 'insertion point' is the
    center of the hatch's bounding box which can be obtained via the ActiveX
    'getboundingbox' method.
     
    Jeff Mishler, Mar 3, 2005
    #4
  5. adw

    adw Guest

    Jeff, I am not familiar with ActiveX. Is there an easy way to list the coordinates of the grip, so I can use them as an insertion point for my text in a lisproutine?
    André
     
    adw, Mar 4, 2005
    #5
  6. adw

    Fatty Guest

    maybe like this....
    (prompt "\nType >>> hatchpoint <<< to load test prgm\n")
    (defun C:hatchpoint ()
    (setq oldosm (getvar "osmode"))
    (setvar "osmode" 512)
    (setq htch (car (entsel "Select hatch only:")))
    (setq alist (entget htch))
    (if (eq (cdr (assoc 0 alist)) "HATCH")
    (progn
    ;; vertexies for hatch only :
    (setq vexs (reverse (cdr
    (reverse (cdr
    (mapcar 'cdr (vl-remove-if-not
    (function (lambda (x)(= (car x) 10)))
    alist)))))))

    (setq int_point (list
    (/ (apply '+ (mapcar 'car vexs))(length vexs))
    (/ (apply '+ (mapcar 'cadr vexs))(length vexs))
    (/ (apply '+ (mapcar 'caddr vexs))(length vexs))))
    )
    )
    ;; TesT part :
    (setvar "osmode" 0)
    (command "_.line" int_point pause "")
    (setvar "osmode" oldosm)
    (princ)
    )

    thank you
     
    Fatty, Mar 4, 2005
    #6
  7. adw

    adw Guest

    Thanks for helping, Fatty, but this is what I already had. It doesn't give me the coordinates of the grip of a hatch.
    Any other suggestions?
     
    adw, Mar 4, 2005
    #7
  8. adw

    Dann Guest

    Copy the following into your lisp program then to find the point use (setq
    grppt(hatchgrip))


    (defun hatchgrip (/ obj pt1 pt2 ptg)
    (vl-load-com)
    (setq obj (objsel "Select Hatch Object: "))
    (vlax-invoke-method obj 'GetBoundingBox 'pt1 'pt2)
    (setq ptg (midpoint (vlax-safearray->list pt1)
    (vlax-safearray->list pt2)
    )
    )
    (setq ptg(trans ptg 0 1))
    ptg
    )

    (defun midpoint (p1 p2)
    ;;Usage (setq mid(midpoint pt1 pt2))
    (mapcar '* '(0.5 0.5 0.5) (mapcar '+ p1 p2))
    )

    (defun objsel ($prompt / ent obj)
    ;;usage = (setq obj(objsel "Select Object: "))
    (setq ent (car (entsel $prompt)))
    (if (/= ent nil)
    (setq obj (vlax-ename->vla-object ent))
    (princ "No Object Selected")
    )
    obj
    ;;returns result for use in calling program
    )
     
    Dann, Mar 4, 2005
    #8
  9. adw

    Joe Burke Guest

    Andre,

    Look at what Dann posted. It is essentially what Jeff suggested. The right idea, IMO.
    Though I haven't studied the details.

    Joe Burke
     
    Joe Burke, Mar 4, 2005
    #9
  10. adw

    adw Guest

    Dann,
    This is exactly what I'm looking for. Many thanks from the Netherlands.
    André
     
    adw, Mar 14, 2005
    #10
  11. adw

    adw Guest

    Joe, also thanks to you for replying, I found a perfect solution with Dann's idea. André
     
    adw, Mar 14, 2005
    #11
  12. adw

    Dann Guest

    No problem, Glad I could help.
     
    Dann, Mar 14, 2005
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.