Get Hatch's Layer Name on model

Get Hatch's Layer Name on model

Anonymous
Not applicable
357 Views
1 Reply
Message 1 of 2

Get Hatch's Layer Name on model

Anonymous
Not applicable

Hello,

I am looking for a lisp that can get the Mtext of the selected hatch's layer name and place (Mtext) user-defined on the screen.

Can anybody help me with this?

Thank you

0 Likes
358 Views
1 Reply
Reply (1)
Message 2 of 2

paullimapa
Mentor
Mentor

try this:

; get_hatch_layer 
; function selects a hatch, gets layer it's on and places as MText on a given point location
(defun c:get_hatch_layer (/ ss lyr pt)
; OP:
; https://forums.autodesk.com/t5/forums/replypage/board-id/130/message-id/462561
; M-Text uses entmake to make MText
; Arguments:
; pt = x,y,z
; val = text string
; Lee Mac
; https://www.cadtutor.net/forum/topic/17870-entmake-and-mtext/?do=findComment&comment=146599
 (defun M-Text (pt val)
  (entmakex
   (list
     (cons 0   "MTEXT")         
     (cons 100 "AcDbEntity")          
     (cons 100 "AcDbMText")    
     (cons 10 pt)        
     (cons 1 val)
   )
  )
 )
  (while(not ss)
    (princ"\nPick Hatch")
    (setq ss (ssget "_+.:E:S"'((0 . "Hatch"))))
  )
  (setq lyr (cdr(assoc 8 (entget(ssname ss 0))))
         pt (getpoint"\nPick MText Location")
  )
  (M-Text pt lyr)
  (princ)
) ; defun

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes