Jump to content

Recommended Posts

Posted

Can anyone help me edit the LISP for TCOUNT to include the text for Multileaders? I've added (0 . "MULTILEADER") to the LISP but it will not edit the text. I haven't done much with LISP's, so any help would be appreciated.

Thanks.

Posted
What code are you referring to? My program here?

Express Tool: TCount

Posted
Express Tool: TCount

 

Sorry, I should have mentioned that. Yes, it is the express tool TCount.

 

alanjt, while searching for an answer to this question, I came across a previous post of yours here: http://www.cadtutor.net/forum/showthread.php?40266-CopyText.lsp-Copy-Swap-Text-MText-Multileader-Attribute-Values

The reason this caught my eye is because you were able to modify the text in a multileader through a lisp, which is what I need to do. However, the code was not in that post, so I couldn't look at it to figure it out.

Posted
Sorry, I should have mentioned that. Yes, it is the express tool TCount.

 

No worries :)

Posted

(assoc 304 (entget )) or (vla-get-TextString )

Posted

Hmmm...I think I'm still missing something. In the file ACETXT.LSP provided with the Express Tools, there is this:

(setq flt '((-4 . "

(0 . "TEXT")

(0 . "MTEXT")

(0 . "ATTDEF")

(-4 . "OR>")

)

);setq

 

From my breif understanding of Lisp routines, that's setting up a query for text, mtext or an attribute definetion. If I add the line (assoc 304 (entget )) or (vla-get-TextString ), I get "bad SSGET list" when I try to run the routine. I'm not quite sure how that line of code is supposed to fit in.

 

As I mentioned, this is my first stab at modifying a lisp, so please bear with me and all your help is greatly appreciated.

  • 1 year later...
Posted

Hi!

Have you got any result in improving TCOUNT for mleaderds?

  • 12 years later...
Posted

This functionality is still not available in 2024? 

When I try to use the 'Auto Number' function from 'Express Tools' menu I cannot select any of my multileader objects.  Is there a workaround?

Posted

This seems to work for me. I had some old code I had started for something else and decided to see what I could do for MLeaders.

 

Weren't easy for me at all, but a little searching provided some hints. Only quickly tested on a couple of quick mleaders, text and mtext.

 

;;; Sequential Number added to MLeader, Mtext and Text as Prefix, Suffix.                             *|
;;;                                                                                                   *|
;;; Inspired By: https://www.cadtutor.net/forum/topic/26420-tcount-in-a-multileader/#comment-648519   *|
;;;                                                                                                   *|
;;; With help from: https://forums.augi.com/showthread.php?117315-Modify-text-in-multileader          *|
;;;                                                                                                   *|
;;; By SLW210 (Steve Wilson)                                                                          *|
;;;                                                                                                   *|
;;; No guarantees use at your own risk                                                                *|
;;;                                                                                                   *|
;;; Original 08/15/2024                                                                               *|
;;;                                                                                                   *|
;;;                                                                                                   *|
;;; Thanks most to AlanJT, lpseifert and irneb (Where have y'all gone?)                               *|
;;;                                                                                                   *|
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*|

(vl-load-com)

(defun c:MTMTMLT () (c:ModifyTextMTextMLeaderText)) ; shortcut

(defun c:ModifyTextMTextMLeaderText (/	       ss	 ent
				     en_obj    current_text
				     new_text  num	 prefix
				     suffix    numType	 i
				     entType
				    )

  ;; Prompt for prefix text
  (setq prefix (getstring "\nEnter prefix text (or leave blank): "))

  ;; Prompt for suffix text
  (setq suffix (getstring "\nEnter suffix text (or leave blank): "))

  ;; Prompt for type of numbering
  (setq	numType
	 (strcase
	   (getstring
	     "\nEnter 'P' for Prefix, 'S' for Suffix, or 'N' for No modification: "
	   )
	 )
  )

  ;; Check if the type entered is valid
  (if (not (member numType '("P" "S" "N")))
    (progn
      (princ "\nInvalid choice. Exiting.")
      (exit)
    )
  )

  ;; Select all TEXT, MTEXT, and MLEADER entities
  (setq ss (ssget '((0 . "TEXT,MTEXT,MULTILEADER"))))

  ;; Check if the selection set is valid
  (if (not ss)
    (progn
      (princ "\nNo TEXT, MTEXT, or MLEADER entities found.")
      (exit)
    )
  )

  (setq i 0)				; Initialize counter

  ;; Process
  (repeat (sslength ss)
    (setq ent (ssname ss i))
    (setq en_obj (vlax-ename->vla-object ent))
    (setq entType (cdr (assoc 0 (entget ent))))

    (cond
      ;; TEXT entities
      ((= entType "TEXT")
       (setq current_text (vla-get-TextString en_obj))
       (princ (strcat "\nCurrent TEXT: " current_text))
       (setq num (itoa (1+ i)))
       (setq new_text
	      (cond
		((= numType "P") (strcat prefix num " " current_text))
		((= numType "S") (strcat current_text " " suffix num))
		((= numType "N") (strcat current_text))
	      )
       )
       (vla-put-TextString en_obj new_text)
       (princ (strcat "\nNew TEXT: " (vla-get-TextString en_obj)))
      )

      ;; MTEXT entities
      ((= entType "MTEXT")
       (setq current_text (vla-get-TextString en_obj))
       (princ (strcat "\nCurrent MTEXT: " current_text))
       (setq num (itoa (1+ i)))
       (setq new_text
	      (cond
		((= numType "P") (strcat prefix num " " current_text))
		((= numType "S") (strcat current_text " " suffix num))
		((= numType "N") (strcat current_text))
	      )
       )
       (vla-put-TextString en_obj new_text)
       (princ (strcat "\nNew MTEXT: " (vla-get-TextString en_obj)))
      )

      ;; MLEADER entities
      ((= entType "MULTILEADER")
       (progn
	 ;; Retrieve the text of the MLEADER and apply modifications
	 (setq current_text (vla-get-TextString en_obj))
	 (princ (strcat "\nCurrent MLEADER Text: " current_text))
	 (setq num (itoa (1+ i)))
	 (setq new_text
		(cond
		  ((= numType "P") (strcat prefix num " " current_text))
		  ((= numType "S") (strcat current_text " " suffix num))
		  ((= numType "N") (strcat current_text))
		)
	 )
	 (vla-put-TextString en_obj new_text)
	 (princ
	   (strcat "\nNew MLEADER Text: " (vla-get-TextString en_obj))
	 )
       )
      )

      (t
       (princ "\nUnsupported entity type.")
      )
    )

    ;; Increment counter
    (setq i (1+ i))
  )

  (princ "\nModifications completed.")
  (princ)
)

 

Now back to my "get paid for job". I am sure any number of LISPers can greatly improve this.

 

TCOUNT does more I think.

 

I have several related versions of this, hence the long name so I don't get confused, you could rename the function or change the shortcut to something easier IMO.

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