How to get custom property from drawing to use in filename?

I have a macro that generates a PDF file for a drawing, and saves it to a specific folder on our network. What I want to do is get the custom
property "Revision" from the drawing, and put it at the end of the PDF filename.
EX. part TOP4332.sldrw current revision is 1
When saved, it will be TOP4332_01.pdf
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
SW Monkey wrote:

You can do that with SWup(BB): http://markkulehtola.net/swxx.html
--

regards

Markku Lehtola
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Markku Lehtola wrote:

Thanks Markku. I tried SWup(BB) a couple of months ago, and I had some trouble with it.
Could you possibly tell me what code I could use to get the Revision custom prop from the drawing and add it to the end of the filename? Like I said, I have a macro that saves the file as a PDF, and it removes the "-Sheet" from the filename.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
SW Monkey wrote:

Was it the latest version 1.4? What kind of problem did you have?

You can read the property values with:
retval = ModelDoc2.GetCustomInfoValue ( configuration, FieldName )
replace configuration name with "" when working with drawings. Then just add it to the name you already have, like:
FinalPDFSaveName = NameWithoutSheetName & retval & ".pdf"
--

regards

Markku Lehtola
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Markku Lehtola wrote:

Yep, I tried the latest version. Its Saves as a PDF, but it wont add the property to the end of the file.
Can you take a look at this code please. I cant get the retval = to work correctly.
*******START CODE********* Dim swApp As Object Dim Drawing As Object Dim boolstatus As Boolean Dim longstatus As Long Dim Annotation As Object Dim Gtol As Object Dim DatumTag As Object Dim FeatureData As Object Dim Feature As Object Dim Component As Object
Sub main() Dim FileName As String Dim dotpos As Integer Dim slashpos As Integer Dim dashpos As Integer Dim retval As String
Set swApp = CreateObject("SldWorks.Application") Set Drawing = swApp.ActiveDoc
If Drawing Is Nothing Then MsgBox ("No document loaded") Exit Sub End If
If Drawing.GetType <> swDocDRAWING Then MsgBox ("This macro only works with drawings.") Exit Sub End If
retval = ModelDoc2.GetCustomInfoValue("", Revision)
FileName = Drawing.GetPathName If FileName = "" Then 'model is not saved yet FileName = Drawing.GetTitle dashpos = InStrRev(FileName, "-") 'find dash to remove sheet name from title i.e. " - sheet1" FileName = Mid(FileName, 1, dashpos - 2) Else dotpos = InStrRev(FileName, ".") slashpos = InStrRev(FileName, "\")
If dotpos <> 0 Then ' if contains a dot (extension exists) then chop off extension FileName = Mid(FileName, slashpos + 1, dotpos - slashpos - 1) Else 'does not contain a dot FileName = Right(FileName, Len(FileName) - slashpos) End If End If
Load UserForm1
'set the filter UserForm1.CommonDialog1.Filter = "All Files (*.*)|*.*|PDF Files (*.pdf)|*.pdf "
' Specify default filter. UserForm1.CommonDialog1.FilterIndex = 2
'Set the default file name UserForm1.CommonDialog1.FileName = "V:\Machinery\engineering\Temp\PDF\" + FileName + "_" + retval 'FileName = "C:\xxx.DXF"
' Set CancelError is True UserForm1.CommonDialog1.CancelError = True
' CancelError is True. On Error GoTo ErrHandler
UserForm1.CommonDialog1.ShowSave
FileName = UserForm1.CommonDialog1.FileName Drawing.SaveAs3 FileName, swSaveAsCurrentVersion, swSaveAsOptions ErrHandler: ' User pressed Cancel button.
Unload UserForm1 Exit Sub
End Sub
********END CODE**********
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Change retval = ModelDoc2.GetCustomInfoValue("", Revision) -to- retval = Drawing.GetCustomInfoValue("", "Revision")
Ken
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
SW Monkey wrote:

No problem here, works ok with SW05sp3.1...SWupBB is not working with SW06sp2.1 because there's a problem in SW API, but I guess that is not the version you are running?
(Tin Man got the code right)
--

regards

Markku Lehtola
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Im running SW 2005, SP 3.1
My macro works correctly now after adding the
retval = Drawing.GetCustomInfoValue("", "Revision")
Thanks :)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.