Jump to content

Recommended Posts

Posted (edited)

Hi

 

I would like to control Leaders LandingDistance variable, for example set it to 0.1, because currently it appears as 8.0 .  (vla-put-LandingDistance ent_obj 0.1) seems not to work. What amendments would I need, please? Would it be possible for numbers to appear bigger than custom Text added and circle for outline?

 

https://ibb.co/Y8d1fg0

 

Idea:

https://ibb.co/F8rLDDK

 

 

 

(defun c:MLI ( / *error* cmde ldr doc ent ent_obj new_num custom_text arial_style )
  (defun *error* (msg)
    (if (and msg
             (not (wcmatch (strcase msg t) "*break*,*cancel*,*exit*"))
        )
        (princ (strcat "\nError: " msg))
    )
    (if cmde (setvar 'cmdecho cmde))
    (if ldr (setvar 'cmleaderstyle ldr))
    (if doc (vla-endundomark doc))
    (princ)
  ) ;_ end of defun

  (setvar 'cmdecho 0)
  (setq ldr (getvar 'cmleaderstyle))
  
  ;; Ensure Arial text style exists
  (setq arial_style (tblsearch "STYLE" "Arial"))
  (if (not arial_style) ; Create Arial style if it doesn't exist
    (progn
      (command "STYLE" "Arial" "Arial" 0 1 0) ; Set font to Arial
    )
  )
  
  ;; Check and set Leader style
  (if
    (and (setq dic (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"))
         (setq dat (dictsearch (setq dic (cdr (assoc -1 dic))) "NOTES")) ; check your Leader style here
    )
    (setvar 'cmleaderstyle "NOTES") ; set your Leader style here
  ) ;_ end of if
  
  ;; Start undo mark
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  
  ;; Prompt user for custom text and starting number
  (setq custom_text (getstring t "\nEnter custom text suffix: "))
  (inputnum)
  
  ;; Main loop to create numbered MLEADERs
  (while (initcommandversion)
    (command "MLEADER")
    (while (= 1 (logand 1 (getvar 'cmdactive)))
      (command pause)
    ) ;_ end of while
    (setq ent      (entlast)
          ent_obj  (vlax-ename->vla-object ent)
          new_num  (strcat (itoa *!num!*) " " custom_text)  ; Number followed by custom text as suffix
          *!num!*  (1+ *!num!*))
    
    ;; Set the MLEADER properties
    (vla-put-TextString ent_obj new_num)       ; Set text string
    (vla-put-TextStyleName ent_obj "Arial")    ; Set text style to Arial
    (vla-put-TextHeight ent_obj 0.3)           ; Set text height to 0.3 units
    (vla-put-ArrowheadSize ent_obj 0.3)        ; Set arrowhead size to 0.3
    (vla-put-LandingGap ent_obj 0.2)           ; Set landing distance (gap) to 0.2 units
  ) ;_ end of while
  
  ;; End undo mark and restore settings
  (vla-endundomark doc)
  (setvar 'cmleaderstyle ldr)
  (setvar 'cmdecho cmde)
) ;_ end of defun

;; Function to prompt for starting number
(defun inputnum ()
  (setq *!num!*
    (fix
      (cond
        ((getreal
           (strcat "\nStarting number? <"
                   (itoa (setq *!num!* (cond (*!num!*) (1))))
                   ">: "
           )
         )
        )
        (*!num!*)
      )
    )
  )
) ;_ end of defun

 

Edited by pyou
Posted
16 hours ago, pyou said:

Hi

 

I would like to control Leaders LandingDistance variable, for example set it to 0.1, because currently it appears as 8.0 .  (vla-put-LandingDistance ent_obj 0.1) seems not to work. What amendments would I need, please? Would it be possible for numbers to appear bigger than custom Text added and circle for outline?

@pyou try adding:

(vla-put-dogleglength ent_obj 0.1)

 

  • Thanks 1
Posted (edited)
22 hours ago, BIGAL said:

Maybe this as a start I am sure I have a version somewhere that does as per image. Will look for it.

image.png.6839a41bbca5f6972e1742409e5314f9.png

 

Pt num bubble.lsp 3.49 kB · 62 downloads

 Thanks , but not something i would be able to use as imagined.

Edited by pyou
Posted

When i draw a leader i can only type in suffix text at the beginning. I cant add text after, its just show as a number. For some reason it asks me to type in text again ,but it does not appear when i type it in.

 

(defun c:MLI ( / *error* cmde ldr doc ent ent_obj new_num custom_text arial_style )
  (defun *error* (msg)
    (if (and msg
             (not (wcmatch (strcase msg t) "*break*,*cancel*,*exit*"))
        )
        (princ (strcat "\nError: " msg))
    )
    (if cmde (setvar 'cmdecho cmde))
    (if ldr (setvar 'cmleaderstyle ldr))
    (if doc (vla-endundomark doc))
    (princ)
  ) ;_ end of defun

  (setvar 'cmdecho 0)
  (setq ldr (getvar 'cmleaderstyle))
  
  ;; Ensure Arial text style exists
  (setq arial_style (tblsearch "STYLE" "Arial"))
  (if (not arial_style) ; Create Arial style if it doesn't exist
    (progn
      (command "STYLE" "Arial" "Arial" 0 1 0) ; Set font to Arial
    )
  )
  
  ;; Check and set Leader style
  (if
    (and (setq dic (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"))
         (setq dat (dictsearch (setq dic (cdr (assoc -1 dic))) "NOTES")) ; check your Leader style here
    )
    (setvar 'cmleaderstyle "NOTES") ; set your Leader style here
  ) ;_ end of if
  
  ;; Start undo mark
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  
  ;; Prompt user for custom text and starting number
  (setq custom_text (getstring t "\nEnter custom text suffix: "))
  (inputnum)
  
  ;; Main loop to create numbered MLEADERs
  (while (initcommandversion)
    (command "MLEADER")
    (while (= 1 (logand 1 (getvar 'cmdactive)))
      (command pause)
    ) ;_ end of while
    (setq ent      (entlast)
          ent_obj  (vlax-ename->vla-object ent)
          new_num  (strcat (itoa *!num!*) " " custom_text)  ; Number followed by custom text as suffix
          *!num!*  (1+ *!num!*))
    
    ;; Set the MLEADER properties
    (vla-put-TextString ent_obj new_num)       ; Set text string
    (vla-put-TextStyleName ent_obj "Arial")    ; Set text style to Arial
    (vla-put-TextHeight ent_obj 0.3)           ; Set text height to 0.3 units
    (vla-put-ArrowheadSize ent_obj 0.3)        ; Set arrowhead size to 0.3
    (vla-put-LandingGap ent_obj 0.1)           ; Set landing distance (gap) to 0.1 units
    (vla-put-dogleglength ent_obj 0.1)         ; Set  arrow landing distance
  ) ;_ end of while
  
  ;; End undo mark and restore settings
  (vla-endundomark doc)
  (setvar 'cmleaderstyle ldr)
  (setvar 'cmdecho cmde)
) ;_ end of defun

;; Function to prompt for starting number
(defun inputnum ()
  (setq *!num!*
    (fix
      (cond
        ((getreal
           (strcat "\nStarting number? <"
                   (itoa (setq *!num!* (cond (*!num!*) (1))))
                   ">: "
           )
         )
        )
        (*!num!*)
      )
    )
  )
) ;_ end of defun

 

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