Jump to content

Recommended Posts

Posted

Thanks Bigal in advance!

Hope you can help me on this.

Posted (edited)

Working on it had some interstate visitors, maybe later today testing code for attribute in block.

 

Thisoption 1 a simple just put layer name into the mleader.

; https://www.cadtutor.net/forum/topic/60494-hatch-name-to-multileader-lisp/

; Label a hatch layer using a leader and block
; By AlanH Nov 2026


(defun AHMakpl ( / pt)
  (setq oldsnap (getvar 'osmode))
  (setvar 'osmode 512)
  (setq pt (getpoint "\nStarting point of leader "))
  (command "_pline" pt)
  (while (= (getvar "cmdactive") 1 )
    (command (getpoint (getvar 'lastpoint)))
  )
  (setvar 'osmode oldsnap)
  (princ)
)

(defun AHMl1 (lst lay1 / x)
  (setvar 'orthomode 0)
  (setq x -1)
  (command "_Mleader")
  (while (= (getvar "cmdactive") 1 )
    (repeat (length lst)
      (command (nth (setq x (1+ x)) lst))
    )
    (command "" lay1)
  )
)

(defun AHMl2 (lst lay2 / x)
  (setvar 'orthomode 0)
  (setq x -1)
  (command "_Mleader")
  (while (= (getvar "cmdactive") 1 )
    (repeat (length lst)
      (command (nth (setq x (1+ x)) lst))
    )
  (command "" lay2)
  )
)

(defun SetMLStyle ( sty / )
  (if (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE" sty)
    (progn
      (setvar "CMLEADERSTYLE" sty)
      (princ (strcat "\nCurrent MLeader style set to: " sty))
    )
	(progn
      (Alert (strcat "\nMLeader style " sty " not found. \nWill now exit"))(exit)
	)
  )
  (princ)
)

(defun c:hatlab1 ( / pt1 ss lay co-ord)
  (AHmakpl)
  (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
  (command "erase" (entlast) "")
  (setq pt1 (car co-ord))
  (setq ss (ssget pt1 (list (cons 0 "HATCH"))))
  (setq lay (cdr (assoc 8 (entget (ssname ss 0)))))
  (command "erase" (entlast) "")
  (SetMLStyle "MLEADER STYLE (HARDSCAPE) LEFT SIDE")
  (ahml1 co-ord lay)
  (princ)
)

(defun c:hatlab2 ( / pt1 ss lay co-ord obj objid)
  (AHmakpl)
  (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
  (command "erase" (entlast) "")
  (setq pt1 (car co-ord))
  (setq ss (ssget pt1 (list (cons 0 "HATCH"))))
  (setq obj (vlax-ename->vla-object (ssname ss 0)))
  (setq objID (rtos (vla-get-objectid obj) 2 0))
  (setq lay (strcat "%<\\AcObjProp Object(%<\\_ObjId " objid  ">%).Layer>%"))
  (SetMLStyle "MLEADER STYLE (HARDSCAPE) LEFT SIDE")
  (ahml2 co-ord lay)
  (princ)
)

 

Option 2 the field is not updating and not sure why not, anybody have an idea.

Checked like Fieldval its 31.

Edited by BIGAL
  • 2 weeks later...
Posted
On 11/26/2026 at 8:47 AM, BIGAL said:

Working on it had some interstate visitors, maybe later today testing code for attribute in block.

 

Thisoption 1 a simple just put layer name into the mleader.

; https://www.cadtutor.net/forum/topic/60494-hatch-name-to-multileader-lisp/

; Label a hatch layer using a leader and block
; By AlanH Nov 2026


(defun AHMakpl ( / pt)
  (setq oldsnap (getvar 'osmode))
  (setvar 'osmode 512)
  (setq pt (getpoint "\nStarting point of leader "))
  (command "_pline" pt)
  (while (= (getvar "cmdactive") 1 )
    (command (getpoint (getvar 'lastpoint)))
  )
  (setvar 'osmode oldsnap)
  (princ)
)

(defun AHMl1 (lst lay1 / x)
  (setvar 'orthomode 0)
  (setq x -1)
  (command "_Mleader")
  (while (= (getvar "cmdactive") 1 )
    (repeat (length lst)
      (command (nth (setq x (1+ x)) lst))
    )
    (command "" lay1)
  )
)

(defun AHMl2 (lst lay2 / x)
  (setvar 'orthomode 0)
  (setq x -1)
  (command "_Mleader")
  (while (= (getvar "cmdactive") 1 )
    (repeat (length lst)
      (command (nth (setq x (1+ x)) lst))
    )
  (command "" lay2)
  )
)

(defun SetMLStyle ( sty / )
  (if (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE" sty)
    (progn
      (setvar "CMLEADERSTYLE" sty)
      (princ (strcat "\nCurrent MLeader style set to: " sty))
    )
	(progn
      (Alert (strcat "\nMLeader style " sty " not found. \nWill now exit"))(exit)
	)
  )
  (princ)
)

(defun c:hatlab1 ( / pt1 ss lay co-ord)
  (AHmakpl)
  (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
  (command "erase" (entlast) "")
  (setq pt1 (car co-ord))
  (setq ss (ssget pt1 (list (cons 0 "HATCH"))))
  (setq lay (cdr (assoc 8 (entget (ssname ss 0)))))
  (command "erase" (entlast) "")
  (SetMLStyle "MLEADER STYLE (HARDSCAPE) LEFT SIDE")
  (ahml1 co-ord lay)
  (princ)
)

(defun c:hatlab2 ( / pt1 ss lay co-ord obj objid)
  (AHmakpl)
  (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
  (command "erase" (entlast) "")
  (setq pt1 (car co-ord))
  (setq ss (ssget pt1 (list (cons 0 "HATCH"))))
  (setq obj (vlax-ename->vla-object (ssname ss 0)))
  (setq objID (rtos (vla-get-objectid obj) 2 0))
  (setq lay (strcat "%<\\AcObjProp Object(%<\\_ObjId " objid  ">%).Layer>%"))
  (SetMLStyle "MLEADER STYLE (HARDSCAPE) LEFT SIDE")
  (ahml2 co-ord lay)
  (princ)
)

 

Option 2 the field is not updating and not sure why not, anybody have an idea.

Checked like Fieldval its 31.

Thanks Bigal.

Hope someone can help us on this.

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.

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