How about using a Prefix/Suffix in the Dimension Style? Much easier to globally change than using a Text Override.
Registered forum members do not see this ad.
I've looked around and have found Suffix/Prefix routines for Text, Mtext and Attributes. I thought it would be easy to modify one of those to work with dimensions but easier said than done. I cannot figure it out.
I was hoping one of these two routines would be easy to rework to work with dimensions.
For this first one, I thought adding DIMENSION to the associative list would work but my understanding is limited evidently...
My desire is to add a prefix/suffix to multiple dimensions.
As far as dimensions are concerned doescover them all?Code:(0 . "DIMENSION")
The other routine I thought would be easy was this one...Code:(defun c:ftxt(/ cMod cStr tSet) (vl-load-com) (initget 1 "Prefix Suffix") (setq cMod(getkword "\nAdd [Prefix/Suffix]: ")) (if(and (setq cStr(getstring T "\nSpecify string: ")) (setq tSet(ssget '((0 . "TEXT,MTEXT")))) ;Adding DIMENSION didn't work for me ); and (foreach tx(mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex tSet)))) (if(= "Prefix" cMod) (vla-put-TextString tx (strcat cStr(vla-get-TextString Tx))) (vla-put-TextString tx (strcat(vla-get-TextString Tx)cStr)) ); end if ); end foreach ); end if (princ) ); end of c:ftxt
Code:(defun c:test ( / as el en i ss str typ ) (initget "Prefix Suffix") (setq typ (cond ((getkword "\nAdd Prefix or Suffix? [Prefix/Suffix] <Prefix>: ")) ("Prefix"))) (setq str (getstring t (strcat typ " to Add: "))) (if (setq ss (ssget '((0 . "INSERT") (66 . 1)))) (repeat (setq i (sslength ss)) (setq en (ssname ss (setq i (1- i)))) (while (eq "ATTRIB" (cdr (assoc 0 (setq el (entget (setq en (entnext en))))))) (setq as (cdr (assoc 1 el))) (if (eq "Prefix" typ) (if (not (wcmatch as (strcat str "*"))) (entmod (subst (cons 1 (strcat str as)) (assoc 1 el) el)) ) (if (not (wcmatch as (strcat "*" str))) (entmod (subst (cons 1 (strcat as str)) (assoc 1 el) el)) ) ) ) ) ) (princ) )
Help please!!
Big thanks to the original code writers!
How about using a Prefix/Suffix in the Dimension Style? Much easier to globally change than using a Text Override.
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
What I very often encounter is the need to add a "2X," "3X," or "10X," before dimensions.
When it's just one here and there, I manually type it in.
I'm working on a drawing at the moment that has 40 or more that need various prefixes like that added.
A majority of drawings are laid out like this using this type of designator...
If it's too much of a hassle, I can keep doing what I've been doing.
Manual works every time.. I get paid either way.
I was hoping it would be an easy fix (just beyond my novice ability..)
A quick modification of my code that you posted:
Code:(defun c:test ( / typ str ss i en ds ) (initget "Prefix Suffix") (setq typ (cond ((getkword "\nAdd Prefix or Suffix? [Prefix/Suffix] <Prefix>: ")) ("Prefix"))) (setq str (getstring t (strcat "\n" typ " to Add: "))) (if (setq ss (ssget '((0 . "*DIMENSION")))) (repeat (setq i (sslength ss)) (setq en (entget (ssname ss (setq i (1- i)))) ds (cdr (assoc 1 en)) ) (if (eq "Prefix" typ) (if (not (wcmatch ds (strcat str "*"))) (entmod (subst (cons 1 (strcat str ds)) (assoc 1 en) en)) ) (if (not (wcmatch ds (strcat "*" str))) (entmod (subst (cons 1 (strcat ds str)) (assoc 1 en) en)) ) ) ) ) (princ) )
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
You don't need lisp for that, just the properties palette (Ctrl+1):
The <> means the value of the dimension.
- Select the dimensions which would have the same prefix/suffix.
- Press Ctrl+1 to open the properties pallette
- Type into the Text override field (bottom of the Text group): Prefix<>Suffix
Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!
Lee...
Won't I needin there somewhere?Code:(assoc 42 en)
!DS is returning an empty string...
I defer to the expert but don't you need the original dimension or am I totally confused??
I am trying to understand....
What it is doing is replacing the dimension with the text (suffix) that I enter...
I'm really close with this:
I have some more questions but it will have to wait until tomorrow...Code:(defun c:DP ( / typ str ss i en ds ) (initget "Prefix Suffix") (setq typ (cond ((getkword "\nAdd Prefix or Suffix? [Prefix/Suffix] <Prefix>: ")) ("Prefix"))) (setq str (getstring t (strcat "\n" typ " to Add: "))) (if (setq ss (ssget '((0 . "*DIMENSION")))) (repeat (setq i (sslength ss)) (setq en (entget (ssname ss (setq i (1- i)))) ds (rtos (cdr (assoc 42 en))) ) (if (eq "Prefix" typ) (if (not (wcmatch ds (strcat str "*"))) (entmod (subst (cons 1 (strcat str ds)) (assoc 42 en) en)) ) (if (not (wcmatch ds (strcat "*" str))) (entmod (subst (cons 1 (strcat ds str)) (assoc 42 en) en)) ) ) ) ) (princ) )
Here is one..
I can enter "9x" but I can't enter 9X, (9X comma space)
Last edited by ILoveMadoka; 16th Aug 2011 at 08:28 pm. Reason: edit
So you mean there's 30-40-50 different prefixes you want to apply? Are you sure? Sounds a bit worrying to me! You know that you can select 30-40-50-1000000000..... dimensions at once and apply the change in one instruction?
Sorry, I just can't understand this. If I had to code something where I'd have various prefixes to apply to various dimensions I'd not have the code ask me each time what that prefix was. I'd rather have different codes placing different prefixes onto the selected dimensions. Perhaps something like this?That way I can have a command for each of the most usual prefixes/suffixes - which I can place on a toolbar or so for quick selection. The last one is a general purpose one which remembers the previous prefix/suffix.Code:(defun AffixDim (en prefix suffix / ) (entmod (list (cons -1 en) (cons 1 (strcat prefix "<>" suffix)))) ) (defun SelectDimsAndAffix (prefix suffix / ss n) (if (setq ss (ssget '((0 . "*DIMENSION")))) (progn (setq n (sslength ss)) (while (>= (setq n (1- n)) 0) (AffixDim (ssname ss n) prefix suffix) ) ) ) ) (defun c:PrefixDim-2X (/) (SelectDimsAndAffix "2X" "") (princ)) (defun c:PrefixDim-9X (/) (SelectDimsAndAffix "9X" "") (princ)) (defun c:AffixDim (/ prefix suffix) (or *AffixDim-Prefix* (setq *AffixDim-Prefix* "")) (or *AffixDim-Suffix* (setq *AffixDim-Suffix* "")) (if (and (setq prefix (getstring t (strcat "Prefix (. for None) <" *AffixDim-Prefix* ">: "))) (not (eq prefix "")) ) (progn (if (eq prefix ".") (setq prefix "") ) (setq *AffixDim-Prefix* prefix) ) (setq prefix *AffixDim-Prefix*) ) (if (and (setq suffix (getstring t (strcat "Suffix (. for None) <" *AffixDim-Suffix* ">: "))) (not (eq prefix "")) ) (progn (if (eq suffix ".") (setq suffix "") ) (setq *AffixDim-Suffix* suffix) ) (setq suffix *AffixDim-Suffix*) ) (SelectDimsAndAffix prefix suffix) (princ) )
Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!
Registered forum members do not see this ad.
No, use "<>" to represent the dimension string otherwise your dimensions won't update and you'll screw up your drawings.
I reference the existing text override so that it is not overwritten.
When it prompts for a Prefix/Suffix, type "Prefix<>" or "<>Suffix" or, if you already have the dimension and prefix and want to add a suffix, just type "Suffix".
EDIT: Added GIF to demonstrate...
PrefSuffDim.gif
Last edited by Lee Mac; 17th Aug 2011 at 11:17 am.
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Bookmarks