Rename filename using Part Number property

Rename filename using Part Number property

eucci
Advocate Advocate
4,344 Views
21 Replies
Message 1 of 22

Rename filename using Part Number property

eucci
Advocate
Advocate

Hello All,

My usual workflow is to use INV Pro 2023  & Vault Professional 2023 using a sequential serial numbering scheme.

As I work on a project, I develop a sensible numbering scheme (part number) which is different from the sequential filename. 

I have encountered an issue where I need to output to a file (preferrably a stp file) for another team member to import into fusion 360 and they need the parts to import with their part numbers (not filename)

 

Any ideas on workflow would be greatly appreciated

 

0 Likes
Accepted solutions (2)
4,345 Views
21 Replies
Replies (21)
Message 2 of 22

dimamazutaMMJ32
Advocate
Advocate

Hello

I didn't quite understand the order of saving, so for now I wrote the iLogic code, which converts the file into step format, gives it a name that will is equal to the part number, and saves it to the folder where the original file is located.

Please specify what you need))

 

Sub Main
    ' Get the STEP translator Add-In.
    Dim oSTEPTranslator As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")

    If oSTEPTranslator Is Nothing Then
	    Exit Sub
    End If

    Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
    Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
    If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
        ' Set application protocol.
        ' 2 = AP 203 - Configuration Controlled Design
        ' 3 = AP 214 - Automotive Design
        oOptions.Value("ApplicationProtocolType") = 3
        oContext.Type = kFileBrowseIOMechanism
		
		Dim Path As String = ThisDoc.Path
		Dim Name As String = iProperties.Value("Project", "Part Number")

        Dim oData As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
		
        oData.FileName = Path & "\" & Name & ".stp"

        Call oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
    End If
End Sub
0 Likes
Message 3 of 22

b.mccarthy
Collaborator
Collaborator

I use the part number as the filename, as well. I created individual schemas tied to my various clients' needs. Some want a simple scheme. while others prefer a more complex version. Have you looked into that? Vault Data Standard may be worth a look...

0 Likes
Message 4 of 22

eucci
Advocate
Advocate
dimamazutaMMJ32

Thank you very much for the quick reply!
If it can work as you describe in the beginning that would be just fine:

*"converts the file into step format, gives it a name that will is equal to
the part number, and saves it to the folder where the original file is
located."*

I'm not familiar with using ilogic code.
I created a new rule from the ilogic tab in the context of my assembly.
I inserted the code that you provided:

*Sub Main ' Get the STEP translator Add-In. Dim oSTEPTranslator As
TranslatorAddIn =
ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
If oSTEPTranslator Is Nothing Then Exit Sub End If Dim oContext As
TranslationContext =
ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As
NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap If
oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument,
oContext, oOptions) Then ' Set application protocol. ' 2 = AP 203 -
Configuration Controlled Design ' 3 = AP 214 - Automotive Design
oOptions.Value("ApplicationProtocolType") = 3 oContext.Type =
kFileBrowseIOMechanism Dim Path As String = ThisDoc.Path Dim Name As String
= iProperties.Value("Project", "Part Number") Dim oData As DataMedium =
ThisApplication.TransientObjects.CreateDataMedium oData.FileName = Path &
"\" & Name & ".stp" Call
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext,
oOptions, oData) End If End Sub*

When I attempted to save and run it returned the following error
[image: image.png]
0 Likes
Message 5 of 22

dimamazutaMMJ32
Advocate
Advocate

Ok

I have attached the .ipt file in which this rule is written.
Note that the file must be saved in any folder.

Checked in 2022 version

0 Likes
Message 6 of 22

b.mccarthy
Collaborator
Collaborator

This is the code I use, and it works as you describe. I set it to fire before save. You might have to rename it.

Message 7 of 22

eucci
Advocate
Advocate

Thank you!

Ideally, I'm looking to export the step from the context of an assembly file so that all the parts in tha assembly are saved out to a step file such that the individual bodies maintain the part number property. Will this code do that?

0 Likes
Message 8 of 22

dimamazutaMMJ32
Advocate
Advocate
This code translates into a step only the file in which it was run (part or assembly).
In general, it is possible to develop a rule that would export to step all the details contained in the assembly
0 Likes
Message 9 of 22

b.mccarthy
Collaborator
Collaborator

The rule I posted will do this. I tested it on an assembly, opened the step file (Convert Model option), and all of the part numbers came through:

 

2023-04-24 663.jpg

 

The caveat here is that I have been unable to get it to export component lengths, such as FG assemblies. Anyone have ideas on how to accomplish that?

0 Likes
Message 10 of 22

eucci
Advocate
Advocate
dimamazutaMMJ32
I ran this rule from both a part file and an assembly file.
It does save out a step file. However, the step file maintains the former
filenames. It does not appear to create new filenames using the part number
property.
Am I doing something wrong?
0 Likes
Message 11 of 22

dimamazutaMMJ32
Advocate
Advocate
Accepted solution

I provide the file Assembly1 in which there are two rules
The SaveAs(OnePart) rule converts a part or an entire assembly into 1 step file with a file name that is taken from the part number
The SaveAs(PartsFromAssembly) rule converts parts in an assembly into separate step files with names taken from part numbers in that assembly

Inventor 2022

 

0 Likes
Message 12 of 22

eucci
Advocate
Advocate

Perhaps I'm not running it incorrectly.

I've created a new rule in the assembly file.

Pasted in the code that you posted. 

Then I ran the rule and it did export out a step.

When I import the subsequent stp file back into Inventor it does show the part number for the all the filenames in the browser panel nodes. However, when I look at the properties of each part they actually maintain the former filenames and not the updated part number.

This also happens when I import the step into Autocad. It maintains the former filenames for all the undividual bodies.

 

Maybe I didnt set up the code to run properly?

0 Likes
Message 13 of 22

eucci
Advocate
Advocate
THis was sent before seeing your latest. Please disregard. I'll run your latest now
0 Likes
Message 14 of 22

eucci
Advocate
Advocate

 THis is getting very close.

Is it possible to export out to one file such that the individual bodies are named based on the part number property?

0 Likes
Message 15 of 22

dimamazutaMMJ32
Advocate
Advocate
All the parts were exported as bodies in the assembly.step file, and at the same time, these bodies in the multibody had names corresponding to the part numbers of the original parts?
Sorry, I have to translate into Ukrainian, so there may be a misunderstanding))
Please provide some picture if possible
0 Likes
Message 16 of 22

eucci
Advocate
Advocate
Accepted solution

SaveAs(PartsFromAssembly)

Saves all parts of the assembly out to individual files that have the filename updated to the part number property

 

SaveAs(OnePart)

Saves out to a multibody stp file with the stp filename updated to the part number property

However, the individual parts in the assembly do not have the filename updated to the part number property.

they still have the former filenames

 

See link below for the files Im using:

https://www.dropbox.com/sh/wjn3rec86m5jd87/AAA3iDH07h7PYdMOOO2pQG5ta?dl=0

0 Likes
Message 17 of 22

dimamazutaMMJ32
Advocate
Advocate
Do you want to rename the original .ipt files and have an assembly with these new_named .ipt files? (file name was 182951 and now it must be DER 336CS11)
Is convertation into .stp format Ok for now?
0 Likes
Message 18 of 22

b.mccarthy
Collaborator
Collaborator

Your assembly is missing the CP PARAMETERS 230406.xlsx file.

0 Likes
Message 19 of 22

eucci
Advocate
Advocate

I do not need to rename any of the iam or ipt files. I need the bodies in the exported stp file to be named according to the part number property.

0 Likes
Message 20 of 22

eucci
Advocate
Advocate
0 Likes