All Activity
- Today
-
Field update issues in dynamic block
SLW210 replied to jamami's topic in AutoCAD Drawing Management & Output
Why do you need to mirror? It works fine for me, even mirrored, you just have to RegenALL to get the new value. You could add a flip to the block. -
You got lucky, stopped at work waiting on more information. I lightly tested this on your drawings. ;;; Sequential Numbering added to MLeader, Mtext and Text as Prefix, Suffix or Find and Replace. *| ;;; *| ;;; https://www.cadtutor.net/forum/topic/98622-tcount-for-multileaders/#findComment-675446 *| ;;; *| ;;; 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 07/28/2025 *| ;;; *| ;;; *| ;;; Thanks most to AlanJT, lpseifert and irneb (Where have y'all gone?) *| ;;; *| ;**************************************************************************************************| ;**************************************************************************************************| ;;; When asked for FIND/REPLACE, leave blank to skip. *| ;;; *| ;;; For MTEXT/MLEADER, enter All to apply the change to all lines, or specify a line number. *| ;;; *| ;**************************************************************************************************| ;**************************************************************************************************| (vl-load-com) (defun c:TMTMS () (c:TxtMTxtMldrSeq)) ; shortcut (defun c:TxtMTxtMldrSeq (/ ss ent en_obj current_text new_text num prefix suffix numType i entType findStr replaceStr lineNum lineNumStr lineList newLines ) ;; Prompt for prefix and suffix (setq prefix (getstring "\nEnter prefix text (or leave blank): ")) (setq suffix (getstring "\nEnter suffix text (or leave blank): ")) ;; Prompt for numbering type (setq numType (strcase (getstring "\nEnter 'P' for Prefix, 'S' for Suffix, or 'N' for No modification: " ) ) ) (if (not (member numType '("P" "S" "N"))) (progn (princ "\nInvalid choice. Exiting.") (exit)) ) ;; Find and Replace (setq findStr (getstring T "\nEnter FIND text (or press Enter to skip): ") ) (setq replaceStr (if (/= findStr "") (getstring T "\nEnter REPLACE text: ") "" ) ) ;; Line number (initget 1 "All") (setq lineNumStr (getstring "\nEnter line number for MTEXT/Multileader (or type 'All'): " ) ) (setq lineNum (if (wcmatch (strcase lineNumStr) "ALL") nil (atoi lineNumStr) ) ) ;; Get selection set (setq ss (ssget '((0 . "TEXT,MTEXT,MULTILEADER")))) (if (not ss) (progn (princ "\nNo valid text entities found.") (exit)) ) ;; Loop through entities (setq i 0) (repeat (sslength ss) (setq ent (ssname ss i)) (setq en_obj (vlax-ename->vla-object ent)) (setq entType (cdr (assoc 0 (entget ent)))) (setq current_text (vla-get-TextString en_obj)) (setq num (itoa (1+ i))) ;; Find & replace (if (and (/= findStr "") (/= replaceStr "")) (setq current_text (vl-string-subst replaceStr findStr current_text) ) ) (cond ;; TEXT ((= entType "TEXT") (setq new_text (cond ((= numType "P") (strcat prefix num " " current_text)) ((= numType "S") (strcat current_text " " suffix num)) ((= numType "N") current_text) ) ) (vla-put-TextString en_obj new_text) ) ;; MTEXT or MULTILEADER ((or (= entType "MTEXT") (= entType "MULTILEADER")) (setq lineList (split-text-lines current_text)) (setq newLines (if (and lineNum (> lineNum 0) (<= lineNum (length lineList))) ;; Modify specific line (mapcar '(lambda (line idx) (if (= idx (1- lineNum)) (cond ((= numType "P") (strcat prefix num " " line)) ((= numType "S") (strcat line " " suffix num)) ((= numType "N") line) ) line ) ) lineList (number-seq 0 (1- (length lineList))) ) ;; Modify all lines (mapcar '(lambda (line) (cond ((= numType "P") (strcat prefix num " " line)) ((= numType "S") (strcat line " " suffix num)) ((= numType "N") line) ) ) lineList ) ) ) ;; Combine lines (setq new_text (apply 'strcat (mapcar '(lambda (l) (strcat l "\\P")) newLines) ) ) (vla-put-TextString en_obj new_text) ) ) (setq i (1+ i)) ) (princ "\nModifications completed.") (princ) ) ;; Split text into lines (MTEXT line delimiter = \P) (defun split-text-lines (txt) (vl-remove-if 'null (parse txt "\\P")) ) ;; Parse string by delimiter (defun parse (str delim / result pos start) (setq start 1) (while (setq pos (vl-string-search delim str (1- start))) (setq result (cons (substr str start (- pos start)) result)) (setq start (+ pos (strlen delim) 1)) ) (reverse (cons (substr str start) result)) ) ;; Create list of numbers from start to end (defun number-seq (start end) (if (> start end) nil (cons start (number-seq (1+ start) end)) ) ) I left the options from the other LISP, due to time, if you want or I get more time, I might remove the other options.
-
There was a link to a LISP at Autodesk forums as well. I have a few versions of my LISP as mentioned in that thread, I'll think about updating and altering one if I get time. I need a clearly explained before and after .dwg, just go through what you do in TCOUNT, better yet show it with TCOUNT on MText as well, even with your drawings as MText, I followed the steps you gave in your first post and do not get the results you ask for.
-
jamami started following Field update issues in dynamic block
-
Hi I developed a simple plan view of a decking unit with a custom dimstyle, lines/arrows suppressed so to show only the dim text, when the block was stretched the dim updated therefore indicting the length of panel required. We had big issues with this when mirroring as the text also mirrors, to overcome this I deleted the dimension and added a field with a formula, this overcame the mirroring problem. The problem is that the block always bugs out and shows #### instead of the result, it is not usable in any other drawings, also I have dragged this block onto my tool palette but when i try and insert into another blank drawing I get an error message:- Warning: An error occurred during save. We recommend that you run RECOVER on the drawing. I found a link on the Autocad support site that suggested changing UTC8 settings in windows regional settings, I have done this but the problem still persists. I am wondering is it because the field is in an Mtext box (so i can aply a backround) ? I have attached the drawing below that contains the troublesome block. _d-spans.dwg
-
I tried CopyText and MTMTMLT. I found CopyText great as it is something that I will end up using quite a bit since I have to copy text to multiple mleaders sometimes, but neither of the ones I tried did what I was looking for unfortunately. MTMTMLT only adds the sequential numbering at the end and doesn't let me replace what I have in the text as a place holder. What I need replaced is always at the end of the first line and since I have multiple lines of text sometimes it doesn't work with the numbering being added at the end of all the text
-
Visual Style Locked in Paper Space
SLW210 replied to Beeftimer's topic in AutoCAD Drawing Management & Output
Not that I know of, you'll need to CHSPACE them back to do that. For dimensioned details like that I use the SOL commands (solview+soldraw and solprof) or if you have it VIEWBASE. -
I linked several LISPs in that thread, which ones did you try?
- Yesterday
-
I guess look for newline then work backwards two characters. Try this. (defun c:wow ( / num str str1 str2 newstr obj len ) (setq num (getint "\nEnetr start number ")) (while (setq ent (entsel "\nPick Mleader - Enter to stop. ")) (setq obj (vlax-ename->vla-object (car ent))) (setq str (vlax-get obj 'textstring)) (setq pos (vl-string-position 92 str)) (if (= pos nil) (progn (setq len (strlen str)) (if (< num 10) (setq newstr (strcat (substr str 1 (- len 2)) "0" (rtos num 2 0))) (setq newstr (strcat (substr str 1 (- len 2)) (rtos num 2 0))) ) ) (progn (if (< num 10) (setq newstr (strcat "0" (rtos num 2 0))) (setq newstr (rtos num 2 0)) ) (setq str1 (strcat (substr str 1 (- pos 2)) newstr)) (setq str2 (substr str (+ pos 1))) (setq newstr (strcat str1 str2)) ) ) (vlax-put obj 'textstring newstr) (setq num (1+ num)) ) (princ) )
-
Visual Style Locked in Paper Space
Beeftimer replied to Beeftimer's topic in AutoCAD Drawing Management & Output
I just realized something that I forgot. There's a huge difference between Layout 1 and the rest of the layouts, and that is that I've used the CHSPACE command to pull the objects through to the paper space on those subsequent layouts. So that would be why they're showing correctly on the first layout, but not on the subsequent ones (because they are no longer INSIDE the viewport). But still, is there a way to show those as hidden after I've done that? -
Visual Style Locked in Paper Space
Beeftimer replied to Beeftimer's topic in AutoCAD Drawing Management & Output
Interesting article, and it seems to be directed at my problem, but it doesn't work. It did point me to an observation, though... the subsequent layouts (Layout 1 (2), Layout 1 (3)...) are all copies of Layout 1. However, Layout 1 is the only layout that is showing properly as hidden. The rest show as 2D wireframe and you cannot change the visual style on any of them and even Layout 1 shows 2D Wireframe under the properties pane, though the model looks like it's in Hidden style on that layout. Also, in the article, they say to change the Shaded Plot setting, but in the image, they're changing the Visual Style setting, so that's a little confusing; mine doesn't even show a shaded plot setting (EDIT: the shaded plot setting appears when clicking on the viewport... disregard). It's making it difficult to build this thing from the plans, that's for sure, but it's just something that I designed to put together and sell if it looks nice enough. It's not a HUGE deal, but if you can figure it out, that would be cool. I used to be the CAD guy at my job years ago, but this one has me stumped. -
Ok thanks tomorrow when i have time i Will test .thanks very much
-
I did. I had found it before and it is great just doesn't do exactly what i need. I can use it to add the numbering at the end but if I need to renumber then it won't work the way I need it to. Thank you for this.
-
This is great. Is there a way to have it still do this if there are multiple lines of text in the mleader? I still have the wire name at the top line always but sometimes add 1 or 2 additional lines with other info about that wire. Thanks for your help. SAMPLE.dwg
-
I forgot to post the fix. (setq *block_name_list*) I don't recall the second error.
-
Did you try the codes in the thread I posted?
-
Visual Style Locked in Paper Space
SLW210 replied to Beeftimer's topic in AutoCAD Drawing Management & Output
AFAIK, to plot a Layout with Hidden Visual Style, you need the viewport setup. I couldn't find the article, but I did find THIS POST. If that doesn't work, I'll have a look when I get back to work. - Last week
-
Give this a try, also it replaces what ever is the last 2 characters. Call it version 1. ; https://www.cadtutor.net/forum/topic/98622-tcount-for-multileaders/ ; change mleader text add number on end. ; By alanH jultu 2025 (defun c:wow1 ( / num str newstr obj len) (setq num (getint "\nEnter start number ")) (while (setq ent (entsel "\nPick Mleader - Enter to stop. ")) (setq obj (vlax-ename->vla-object (car ent))) (setq str (vlax-get obj 'textstring)) (setq len (strlen str)) (if (< num 10) (setq newstr (strcat (substr str 1 (- len 2)) "0" (rtos num 2 0))) (setq newstr (strcat (substr str 1 (- len 2)) (rtos num 2 0))) ) (vlax-put obj 'textstring newstr) (setq num (1+ num)) ) (princ) )
-
Visual Style Locked in Paper Space
Beeftimer replied to Beeftimer's topic in AutoCAD Drawing Management & Output
-
Sure, here is a sample of what I'll have in my drawings. In my drawings I'll have maybe 50 mleaders like these and I'm looking for a way to be able to pick them in order and then have it replace the -00 at the end with the sequential numbering. In TCOUNT I can pick what number I want it to start from and what the increment will be and then whether I want to overwrite, find and replace (which is what I need it to do), and also a prefix and a suffix option to place the text. Thanks for your help SAMPLE.dwg
-
@rsdonna Ok , please upload your sample.dwg where you need to apply.
-
Visual Style Locked in Paper Space
SLW210 replied to Beeftimer's topic in AutoCAD Drawing Management & Output
Maybe upload the .dwg and some images of your plot settings. -
Try something in this thread.
-
It has more issues than Time magazine. Probably better rewriting something from scratch. I fixed the first 2 issues that came up, then there were more after that and I ran out of spare time to work on it. ;; This global list will store the clean names for selection (defun-q *block_name_list*) Was the error you mentioned. Once fixed more came up.
-
Copy blocks to curve according to another curve
BIGAL replied to HypnoS's topic in AutoLISP, Visual LISP & DCL
(setq plent (entsel "\nPick pline near end "))) (setq pt (cadr plent)) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))) (setq obj (vlax-ename->vla-object plent)) (setq pt1 (vlax-curve-getstartPoint obj)) (setq pt2 (vlax-curve-getendPoint obj)) (setq d1 (distance pt pt1)) (setq d2 (distance pt pt2)) (if (> d1 d2)d (setq co-ord (reverse co-ord)) ) To reverse direction of a line or pline, "It is a task that takes 5 seconds." No its instant.- 21 replies
-
- autolisp
- block position
-
(and 3 more)
Tagged with:
-
Yes - replace the following section of your code with my replacement. REPLACE THIS (action_tile "highlight" "(progn (setq selected_index (atoi (get_tile \"block_tree\"))) (setq selected_block (nth selected_index *block_name_list*)) (princ (strcat \"\nHighlighting all instances of: \" selected_block)) (sssetfirst nil nil) ; Clear any previous selection grips (setq ss (ssget \"_X\" (list (cons 0 \"INSERT\") (cons 2 selected_block) (cons 410 (getvar 'ctab))))) (if ss (sssetfirst nil ss)) ; Highlight all found instances in current space )" ) WITH THIS (action_tile "highlight" (strcat "(progn" " (setq selected_index (atoi (get_tile \"block_tree\")))" " (setq selected_block (nth selected_index *block_name_list*))" " (princ (strcat \"\nHighlighting all instances of: \" selected_block))" " (sssetfirst nil nil) ; Clear any previous selection grips" " (setq ss (ssget \"_X\" (list (cons 0 \"INSERT\") (cons 2 selected_block) (cons 410 (getvar 'ctab)))))" " (if ss (sssetfirst nil ss)) ; Highlight all found instances in current space" ")" ) ) The DCL and the LISP file must both be in an AutoCAD support path.