Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

rename xref in tool palette in multiple drawings

1 REPLY 1
SOLVED
Reply
Message 1 of 2
marlance
430 Views, 1 Reply

rename xref in tool palette in multiple drawings

Is there a lisp that will rename xrefs in tool palette (not the file name) in multiple drawings?

 

 

 

regards,

roldan

1 REPLY 1
Message 2 of 2
hmsilva
in reply to: marlance


@rulep21 wrote:

Is there a lisp that will rename xrefs in tool palette (not the file name) in multiple drawings?

 


 Hi Roldan,

this is not the program you're looking for, is just a 'demo' and a starting point.

 

If the xref names are like those in example 'Some-Name-Final Name' the code will remove part of the name until the last '-' at the xref name and will try to put the xref with that name if no other with the same name.
To process more than one dwg, do a search at 'Search This Board' for batch or process,  and you'll get many examples how to accomplish that.

 

(defun c:demo (/ name newn pos)
  (vlax-For blk (vla-Get-Blocks (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
    (if (and (= (vla-Get-IsXref blk) :vlax-True)
             (wcmatch (setq name (vla-get-Name blk)) "*-*")
        )
      (progn
        (setq pos  (vl-string-position (ascii "-") name nil T)
              newn (substr name (+ pos 2))
        )
        (if (not (vl-catch-all-error-p
                   (vl-catch-all-apply '(lambda () (vla-put-Name blk newn)))
                 )
            )
          (vla-reload blk)
        )
      )
    )
  )
  (princ)
)

 

Hope that helps
Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost