Jump to content

Lisp changing Prefix in dimension


sbarszczewski

Recommended Posts

Hi this is my first post on forum so please be tolerant.

 

I have many multiple dimension lines with different prefixes . the dimension text looks like that : W1/+1 (220),

 

Prefix is diffrent for each dimension line :

W1/+1

W2/+1

W3/+1 ect.....

 

the prefix data is stored in Xdata entity. Autocad Find command doesn't work on this text , also few lisp routines I found on this forum fail.

 

Could anybody point me to a lisp which will manage to change selected text for +1 to +2 ( or another fiven value ) for multiple dimension lines

 

Regards

Sebastian

Link to comment
Share on other sites

Can you post sample file? What type of text are you using? I just ran the Find and Replace command in autocad on standard DIMLIN and DIMALI dimensions and it worked fine.

 

I searched for "/+1" and it found all results, I replaced with "/+2".

Link to comment
Share on other sites

Try the following basic code:

(defun c:dimpre ( / a b e i s p x )
   (if (and (setq s (ssget "_:L" '((0 . "*DIMENSION") (-3 ("ACAD")))))
            (/= "" (setq a (getstring "\nPrefix to find: ")))
            (/= "" (setq b (getstring (strcat "\nReplace " a " with: "))))
       )
       (repeat (setq i (sslength s))
           (and(setq e (ssname s (setq i (1- i))))
               (setq x (cadr (assoc -3 (entget e '("acad")))))
               (setq p (member '(1070 . 3) x))
               (entmod
                   (append (entget e)
                       (list
                           (list -3
                               (append (reverse (member '(1070 . 3) (reverse x)))
                                   (cons
                                       (cons 1000 (vl-string-subst b a (cdadr p)))
                                       (cddr p)
                                   )
                               )
                           )
                       )
                   )
               )
               (entupd e)
           )
       )
   )
   (princ)
)

Link to comment
Share on other sites

I don't know about the types of dimensions he is using, nor when he will have time to test but I have just tested on a few dimensions with his W1/+1, W2/+1. W3/+1 examples and the code you provided did not work lee. Of course things could be different on his end I am not sure.

 

I entered W1/+1 as my prefix to be changed then W1/+2 as my target change. Nothing. I also entered /+1 as my prefix on the second run and /+2 as my target, again nothing.

Link to comment
Share on other sites

I have just tested on a few dimensions with his W1/+1, W2/+1. W3/+1 examples and the code you provided did not work lee.

 

Do you have the dimension prefix applied as a dimension style override as indicated by the OP?:

 

...the prefix data is stored in Xdata entity.
Link to comment
Share on other sites

Hey may even like the option to incorporate a list of Prefixes within the code and all dimensions on a specific layer, that way he runs the code and it evaluates and changes all the prefixes automatically without user selected objects and manually entered prefix(s). Just a thought.

Link to comment
Share on other sites

(defun c:dimpre ( / a b e i s p x )
   (if (and (setq s (ssget [color=red]"X"[/color] '((0 . "*DIMENSION")[color=red](8 . "DIM")[/color](-3 ("ACAD")))))
            (/= "" (setq a [color=red]"W1/+1"[/color]))
            (/= "" (setq b [color=red]"W1/+2"[/color]))
       )
       (repeat (setq i (sslength s))
           (and(setq e (ssname s (setq i (1- i))))
               (setq x (cadr (assoc -3 (entget e '("acad")))))
               (setq p (member '(1070 . 3) x))
               (entmod
                   (append (entget e)
                       (list
                           (list -3
                               (append (reverse (member '(1070 . 3) (reverse x)))
                                   (cons
                                       (cons 1000 (vl-string-subst b a (cdadr p)))
                                       (cddr p)
                                   )
                               )
                           )
                       )
                   )
               )
               (entupd e)
           )
       )
   )
   (princ)
)

Link to comment
Share on other sites

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