Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have a folder with around 100 .ipt files, each file consisting of multiple solid bodies.
I would like iLogic to make a copy of each of these files in a new folder, where it merges the solid bodies of the original file into one solid.
I figured using the 'Derive' functionality would be suitable for this, but i can't fully figure out the code.
' Define source and destination folders
Dim sourceFolder As String = "D:\Source\"
Dim targetFolder As String = "D:\Target\"
' Get the list of .ipt files in the source folder
Dim filePaths() As String = System.IO.Directory.GetFiles(sourceFolder, "*.ipt")
' Loop through each file
For Each filePath As String In filePaths
' Create a new part document
Dim newPartDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject,, True)
Dim newCompDef As PartComponentDefinition = newPartDoc.ComponentDefinition
' Create Derived part definition
Dim derivedPartDef As DerivedPartUniformScaleDef
derivedPartDef = newCompDef.ReferenceComponents.DerivedPartComponents.CreateUniformScaleDef(filePath)
' Define Derive style
derivedPartDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyNoSeams
' Add the derived part to the new part
newCompDef.ReferenceComponents.DerivedPartComponents.Add(derivedPartDef)
' New file save location
Dim fileNameOnly As String = System.IO.Path.GetFileName(filePath)
Dim newFilePath As String = System.IO.Path.Combine(targetFolder, fileNameOnly)
newPartDoc.SaveAs(newFilePath, False)
' Close new part
newPartDoc.Close(True)
Next
So far it does create the new file in the target folder and i do see a reference to the original file in my modeltree (FMS_056...), but i don't see a physical 3D model:
(The model/derive link can be deleted in the final code)
Solved! Go to Solution.