link custom prop to file name

Is there a way to have a custom property linked to the document file name so that the custom property automatically gets populated with the
document file name?
Thanks
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Sam wrote:

Sam, The property to use is "SW-File Name" Eddie
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
I think he is thinking about the custom properties in FILE/PROPERTIES in a part document.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Top is right, I am looking for a way to link the document file name into the custom properties in FILE/PROPERTIES... Initially we want this particular custom property to be the same as the document file name but there is a chance that it might change in the future so instead of linking the annotations directly to the file name we would like to link them to a custom property that is linked to the file name but if needed we can change the custom property value without changing the documents file name. Hope that makes sense. If the file name cannot be linked it will still be relatively easy to manually add the value to the custom property.
Sam
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Here is a macro that does what you want and a little more. It makes two assumptions initially, 1st there is a configuration named TEMPLATE and 2nd that the part has been saved. All my document templates have TEMPLATE in place of default to make it obvious that the configuration name needs to be the part name. You can strip out any parts you don't need to just get to the custom property being the filename. In my case I always use configuration specific custom props.
' ****************************************************************************** ' C:\DOCUME~1\kellnerp\LOCALS~1\Temp\swx3812\RenameConfig.swb - macro recorded on 07/08/05 by kellnerp ' Copyright 2005 by P. Kellner ' ****************************************************************************** Dim swApp As Object Dim Part As Object Dim ConfigurationMananger As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim FeatureData As Object Dim Feature As Object Dim Component As Object Dim PName, FName As String Dim Param(1), ParamVal(1) As String
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
PName = Part.GetPathName() If PName = "" Then PName = AskFile() Part.SaveAs2 PName, 0, False, False End If
ptrFname = InStrRev(PName, "\") + 1 FName = Mid(PName, ptrFname) ptrFname = InStr(FName, ".") - 1 FName = Left(FName, ptrFname)
'BAIL OUT IF NO FILENAME GIVEN If FName = "" Then longstatus = swApp.SendMsgToUser2("You must supply a filename" & Chr(13) & "Rerun and provide file name.", swMbInformation, swMbOk) Exit Sub End If
boolstatus = Part.Extension.SelectByID("TEMPLATE", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing) 'Bail if TEMPLATE not found If boolstatus = False Then longstatus = swApp.SendMsgToUser2("You must run this macro on a new file" & Chr(13) & "Edit configuration manually.", swMbInformation, swMbOk) Exit Sub End If
Part.EditConfiguration "TEMPLATE", FName, "", "", 1, 0, 0, 0, boolstatus
'Bail if configuration name not changed If boolstatus = False Then longstatus = swApp.SendMsgToUser2("Configuration Name was not changed" & Chr(13) & "Edit configuration manually.", swMbInformation, swMbOk) Exit Sub End If
'Get a description for the part Description = AskDescription()
'Set Stuff in Config Prop Mgr Set swConfig = Part.GetConfigurationByName(FName) swConfig.Description = Description swConfig.BOMPartNoSource = swBOMPartNumber_ConfigurationName
'Set Stuff in Config Cust Props Part.CustomInfo2(FName, "PartNo") = FName Part.CustomInfo2(FName, "DrawNo") = FName Part.CustomInfo2(FName, "Description") = Description
End Sub
Function AskFile()
Dim Message, Title, Default As String Message = "Enter a fully qualified path and filename" & Chr(13) & "the extension will be added." ' Set prompt. Title = "New Part Name" ' Set title. Default = swApp.GetCurrentWorkingDirectory()
' Display dialog box at position 100, 100. AskFile = InputBox(Message, Title, Default, 200, 200) longstatus = Part.GetType() Select Case longstatus Case 1 AskFile = AskFile & ".SLDPRT" Case 2 AskFile = AskFile & ".SLDASM" End Select
End Function
Function AskDescription()
Dim Message, Title, Default As String Message = "Enter a Description for the Part" ' Set prompt. Title = "New Part Description" ' Set title. Default = "-"
' Display dialog box at position 100, 100. AskDescription = InputBox(Message, Title, Default, 200, 200)
End Function
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.