Save imported STEP files with folder structure and without duplicates

Save imported STEP files with folder structure and without duplicates

Lars_A1
Contributor Contributor
281 Views
4 Replies
Message 1 of 5

Save imported STEP files with folder structure and without duplicates

Lars_A1
Contributor
Contributor

Hi everybody,

we have regularly the case that we have to import STEP files from our vendors. Usually we do this to have a proper base to work with in the future (creating missing drawings, adding new components, modifications, ...). Therefore, converting the model is better than referencing. Importing and converting itself is no big deal and works fine for the most parts. Sometimes there are issues with faces or solids, but that's another problem...

 

Nevertheless, two issues remain, that make the workflow very time consuming:

1. Saving large assemblies with all its subassemblies and parts in a single folder makes it annoying to sort afterwards.

2. Parts that are used multiple times in the original assembly are saved as duplicates after the conversion.

 

I assume both issues can be solved with macros, but I don't know where to start. If you can provide some ideas or code how to implement this, that would be fantastic.

 

Best regards,
Lars

0 Likes
282 Views
4 Replies
Replies (4)
Message 2 of 5

Michael.Navara
Advisor
Advisor

Hi @Lars_A1 

When you import the STEP file, you can set the FullFileName property of each document until you save the file. At this time you can set subfolder to this path or something else.

This minimalistic sample change the root path to the C:\Temp\

Dim asm As AssemblyDocument = ThisDoc.Document
For Each doc As Document In asm.AllReferencedDocuments
	Dim fn As String = System.IO.Path.GetFileName(doc.FullFileName)
	doc.FullFileName = "C:\Temp\" & fn
Next

 

If there are some duplicate components, there is no direct way how to handle them if they are not recognized automatically.

0 Likes
Message 3 of 5

Lars_A1
Contributor
Contributor

That looks good for the saving part. Thank you!

Do you have an idea, how I can get the relationships to generate the folder structure?

0 Likes
Message 4 of 5

Michael.Navara
Advisor
Advisor

Create folder structure is no problem. You just need to replace "C:\Temp\" with your own path for each document. But I don't know what do you expect. Can you describe how the folder structure should look?

0 Likes
Message 5 of 5

Lars_A1
Contributor
Contributor

Ah, I'm so sorry. The classic beginner's mistake. I knew what I wanted to achieve, but I didn't even explain it here, and instead I'm asking for complete solutions...

 

Basically, I would like the folder structure to mimic the assembly structure. So for example, if I have imported the following assembly:

MainAssembly.iam
├── SubAssembly1.iam
|       ├── Part3.ipt
|       ├── Part4.ipt
|       └── Part7.ipt
├── Part1.ipt
├── Part2.ipt
└── SubAssembly2.iam
        ├── Part5.ipt
        ├── Part6.ipt
        └── Part7.ipt

 

I want it to be saved in a folder structure like this:

project folder

├── MainAssembly.iam
├── SubAssembly1.iam
├── SubAssembly2.iam
├── Part1.ipt
├── Part2.ipt
├── SubAssembly1
|      ├── Part3.ipt
|      ├── Part4.ipt
|      └── Part7.ipt
└── SubAssembly2
        ├── Part5.ipt
        ├── Part6.ipt
        └── link to Part7.ipt

 

I'm aware that it becomes more difficult when parts are used multiple times in different (sub-)assemblies (like Part7). Ideally this would be solved with links in Vault, but for now it would be fine if the link is missing.

 

I hope that this makes it a little bit clearer what it is I want to achieve.

0 Likes