Help with DWF file naming

Help with DWF file naming

mjshaffer117
Enthusiast Enthusiast
786 Views
3 Replies
Message 1 of 4

Help with DWF file naming

mjshaffer117
Enthusiast
Enthusiast

Hello!
 I'm looking for a way to edit the name of a DWF file through LISP and I'm having trouble figuring out how to adjust the drawn date in the name of the file. Examples of the file names are as follows:

 

"410081 QC 20201214 (13355267_C6_04). MOD-R1-D.dwf"

"9902 QC 20200302 (13455921_C6_03). MOD-R1-D.dwf"

"206502 QC 20190528 (OAA153952_C6_03). MOD-R1-D.dwf"

"60 QC 20181104 (OAA251516_C6_08). MOD-R2-D.dwf"

"SiteNum QC DateInitiated (ProjectNum). MOD-ReviewNum-D.dwf"

 

The problem I'm running into is trying to figure out a way to return the date that the drawing was initiated. Our drawings are saved in a format such as;

 

"410081-MP-20201214-00.dwg"

"SiteNum-MP-DateInitiated-00.dwg"

 

(vl-load-com)

(setq si (vla-Get-SummaryInfo (vla-Get-ActiveDocument (vlax-Get-Acad-Object))))
(vla-GetCustomByKey si "Project Number" 'pval1)

(setq DWFOutFileName 
	(strcat (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 19)) " QC " (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 7)) " (" pval1 "). MOD-R1-D.dwf"))

 

What I have right now returns "410081 QC 410081-MP-20201214 (13355267_C6_04). MOD-R1-D.dwf"

but I need it to be re-named to "410081 QC 20201214 (13355267_C6_04). MOD-R1-D.dwf"

 

Is there an easy way to remove the "410081-MP-" from the line above, even if the SiteNum length varies?

 

Any help is appreciated as always!

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

SeeMSixty7
Advisor
Advisor
Accepted solution

If your file name always has the MP identifier in it then you can use that as your placement to remove the Sitenum info.

 

Before you prepend your prefix to it simply search for the position of the "MP" in the file name.

(vl-string-search "MP" dwfname)

Would return the position just in front of the "MP" then you simply add 4 to that number and you get the rest of the dwf name without the "sitenum-mp-" part.

 

Hope that helps,

0 Likes
Message 3 of 4

mjshaffer117
Enthusiast
Enthusiast

Thank you @SeeMSixty7  for helping me get on track!

I was able to update the code to work by doing the following

(setq si (vla-Get-SummaryInfo (vla-Get-ActiveDocument (vlax-Get-Acad-Object))))

(vla-GetCustomByKey si "Project Number" 'pval1)
(vla-GetCustomByKey si "Site Number" 'pval2)
(vla-GetCustomByKey si "Customer" 'pval3)

(setq datepos (+ (vl-string-search "MP" (getvar "dwgname")) 4))
(setq endtxt (+ 6 datepos))

(setq DWFOutFileName 
	(strcat (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 19)) " QC " (substr (getvar "dwgname") datepos (- (strlen (getvar "dwgname")) endtxt)) " (" pval1 "). MOD-"revnum"-D.dwf"))
Message 4 of 4

SeeMSixty7
Advisor
Advisor

Glad to hear that worked out for you!

0 Likes