I have a set of Microstation files to plot to pdf for delivery. The files have a unique Internal Company name. Our client has indicated that they neeed a different file name displayed in the title block. At this time we do not want to rename all our files. So ...
My solution was to create a Macro that will read a CSV file with 2 columns (Internalfilename, clientfilename) , I would like via text substitution display the client's name in the border by reading the CSV file and replacing Drawing name with client's name.
In my case the CSV file look like this:
internalfilename,clientsfilename
CHSPT-MOD-22-32-SEC11, AAPART-0001
CHSPT-MOD-22-32-SECT12, AAPART-002
Here the code I wrote so far it does not make the text substitution,
Function PlotSheetNum(Elm as MbeElement) As Long Dim inString as String Dim status as Integer Dim searchforString as String Dim elemString as String Dim tempString as String Dim checkString as String Dim sheetnumber as String Dim lineRead As String Dim dgnFileName as String Dim csvfilename As String Dim commaPos as Integer Dim tmpString as String On error resume next If Elm.type = MBE_Text Or Elm.type = MBE_TextNode Then searchforString = "$SN$" status = elm.getString(elemString) If elemString = searchforString then tempString = " " dgnFileName = MbeDgnInfo.dgnFileName checkString = fileparse$(MbeDgnInfo.dgnFileName,4) MbeWriteMessage "CheckString is: " + checkstring csvfilename = "D:\SHEETS.CSV" Open fileName For Input As #1 While Not EOF(1) Line Input #1, lineRead commaPos = Instr (inString, ",", 0) If commaPos <> 0 Then tempString = Left$ (inString, commaPos - 1) sheetnumber = Mid$ (inString, commaPos + 1) End If if tempString = checkString Then tempString = sheetnumber status = Elm.setString(tempstring) End if Wend End if End if Close #1 PlotSheetNum = Mbe_ElemNormalEnd FunctionSub Main End Sub
Any Help would be appreciated
Serge
I think it would be easier to create a tag in your title block ref file then use / borrow / create a vba macro that will import the tag value and real file name into an excel spreadsheet .. then you use excel to put what you want into the tag value and use VBA to update the tag value in to each drawing then run batch print to batch print to pdf with the new tag values then rerun the vba to return the tag values to their original values.. there has been much discussion on how to do this vba and several examples are available...
If you don't wan to do it your self you can buy this title block macro from Adam Lambert its out of his CaddPro suite of tools but he will sell the individual macro,..... if I remember correctly its under $200AUD... it would cost you more to develop your pentable macro above and or a vba to do what he has already done... We bought the whole package it has many tools for civil but its worth it just for the title block manager......
A free alternative is to download bulk rename utility it will rename 100's of files in seconds and has a terrific gui so you can see before and after affect before you actually rename it will append prepend rename renumber just about anything you want as you create the changes for the first one then drag like excel and watch the formula change the file names..... then you could then leave the $File$ in the standard pentable text substitution..
batch print all your dgns to pdf as per client requirement with the clients file names.. even if you don't use the free utlity for this problem its still very handy and you'll use it else where ... I use it to append the clients drg numbers to my file names as the client numbers are never available during the for proposal or for construction phase so renumber/ renameing just takes seconds to do and as I use the standard pen text substitution $file$ it fixes itself in my title blocks... very cool
Lorys
Started msnt work 1990 - Retired Nov 2022 ( oh boy am I old )
But was long time user V8iss10 (8.11.09.919) dabbler CE update 16 (10.16.00.80)
MicroStation user since 1990 Melbourne Australia.click link to PM me