Hello, can we get part of the filename in the SW properties?
Thank you in advance.
Hello, can we get part of the filename in the SW properties?
Thank you in advance.
Hello
Here's how the command to recover the file name:
$PRP:"SW-File Name
As for recovering a part; I don't think it's possible unless one of my colleagues knows
command and that the part of the name to be retrieved is constant.
Hello
It is possible to concatenate several properties but I doubt that it is possible to retrieve only a part of one of them, except by macro of course since in this case all the functions for manipulating strings are available in the macro.
Kind regards
Yes, I already use a macro to retrieve what I want but I would have liked it to be automatic.
Thank you for your answers!
See you soon.
Hello
Is it possible to share your macro? Indeed I would also like to do the same thing as you by retrieving on one side my plan number and on the other my description, my files being named "n°deplan - description.sldprt"
Thanks in advance
Hello
Sorry for the late reply, here is the first macro to retrieve the reference (the first 13 characters)
Dim swApp As Object
Dimfilename, foo, length, variable1, variable2, repname
Sun Way
Sun long, pos
Dim model As Object
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Set View = Part.ActiveDrawingView
'Retrieve path + file name of the view
filename = View.GetReferencedModelName
'MsgBox (filename)
'recup' filename
foo = dir(filename)
'MsgBox (foo)
'Retrieve the first 13 characters of the file name
variable2 = Left(foo, 13)
'MsgBox (variable2)
'calculation number of characters in filename
length = Len(foo) + 1
'MsgBox (length)
'Creating a string without a file name
long = Len(filename)
RORO = Long - Length
'MsgBox (roro)
path = Left(filename, roro)
'MsgBox (path)
'Search position of \ from the right
pos = InStrRev(path, "\")
'Variable creation 13 characters first parent folder
variable1 = Mid(path, pos + 1, 13)
'MsgBox (variable1)
'Concatenation of the 2 variables
fields = variable2
'MsgBox (fields)
'Creating PP 'field' in SW for cartridge filling
If fields <> "" Then
Value = Part.CustomInfo2("", "field")
If Value = "" Then
Part.AddCustomInfo3"", "field", 50, fields
Else
Part.CustomInfo2("", "field") = fields
End If
End If
Part.EditRebuild3
End Sub
And the second part to retrieve the name after the reference:
Dim swApp As Object
Dimfilename, foo, length, variable1, variable2, repname
Sun Way
Sun long, pos
Dim model As Object
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Set View = Part.ActiveDrawingView
'Retrieve path + file name of the view
filename = View.GetReferencedModelName
'MsgBox (filename)
'recup' filename
foo = dir(filename)
'MsgBox (foo)
'Calculation number of characters in foo
length = Len(foo)
'MsgBox (length)
'Creation of a chain without extension
variable = Left(foo, length - 7)
'MsgBox (variable)
'Variable length recovery
long = Len(variable)
'MsgBox (long)
'recup' file name without first 14 characters
fields = Right(variable, long - 14)
'MsgBox (fields)
'Creating PP 'field' in SW for cartridge filling
If fields <> "" Then
Value = Part.CustomInfo2("", "field2")
If Value = "" Then
Part.AddCustomInfo3"", "field2", 50 fields
Else
Part.CustomInfo2("", "field2") = fields
End If
End If
Part.EditRebuild3
End Sub
Hello, I'd also like to recover the first 6 characters but I can't get your macro to work.
Hi all
If you have Integration included in the My CADtools tools it is done very well, see the attached screenshot.
I have Mycadtools and I didn't know about this function
Thank you.