Save as using part of old title

Save as using part of old title

Anonymous
Not applicable
783 Views
3 Replies
Message 1 of 4

Save as using part of old title

Anonymous
Not applicable

I've been trying to make a function do a save as, and rename the drawing to something that contains part of the old drawing name. The code I have been using to save as is this.

(defun saveas ()
  (setq acadObj (vlax-get-acad-object))
  (setq doc (vla-get-ActiveDocument acadObj))
  (vla-SaveAs doc "abcde.dwg")
)

The drawing was previously called "12345 - fghij", and I want to rename it to be "12345 - abcde". I have been trying to use vl-string-translate, but I can't seem to get the syntax right. Any help would be greatly appreciated.

Thanks!

0 Likes
Accepted solutions (1)
784 Views
3 Replies
Replies (3)
Message 2 of 4

Moshe-A
Mentor
Mentor
Accepted solution

@Anonymous  hi,

 

check this:

 

(setq fname (strcat (getvar "dwgprefix") (substr (getvar "dwgname") 1 8) "abcde"))
(vla-saveas doc fname)

enjoy

moshe

 

 

 

 


@Anonymous wrote:

I've been trying to make a function do a save as, and rename the drawing to something that contains part of the old drawing name. The code I have been using to save as is this.

(defun saveas ()
  (setq acadObj (vlax-get-acad-object))
  (setq doc (vla-get-ActiveDocument acadObj))
  (vla-SaveAs doc "abcde.dwg")
)

The drawing was previously called "12345 - fghij", and I want to rename it to be "12345 - abcde". I have been trying to use vl-string-translate, but I can't seem to get the syntax right. Any help would be greatly appreciated.

Thanks!


 

Message 3 of 4

dlanorh
Advisor
Advisor

Try using

 

(vl-string-subst new-str pattern str [start-pos])

 

I am not one of the robots you're looking for

0 Likes
Message 4 of 4

Anonymous
Not applicable

Moshe: Your code works well. I just edited it a bit to fit my needs. Thanks so much for helping me.

0 Likes