Ilogic to save as and rename an assembly and all components

Ilogic to save as and rename an assembly and all components

Anonymous
Not applicable
3,065 Views
2 Replies
Message 1 of 3

Ilogic to save as and rename an assembly and all components

Anonymous
Not applicable

This is something I have not been able to figure out. Where I am getting stuck is performing a save as of the components and the renaming of all filenames.

 

I'd would like to run a rule in an assembly that would perform a save as of the assembly file and all components as well as prompt the user to enter the file names.

 

The assembly would consist of the following.

 

Assembly1

Part1

Part2

Part3

 

When the rule is run the user will be prompted to enter files names for each file. In this case 4 filenames will need to be entered.

 

The rule will then save the assembly and components to a file path specified in the rule. Any help is appreciated, thanks!

0 Likes
Accepted solutions (1)
3,066 Views
2 Replies
Replies (2)
Message 2 of 3

marcin_otręba
Advisor
Advisor
Accepted solution

in vba make new project , in module1 place code, then add userform1 with textbox1 and button1.

when code will be executed it will fire form for each component to write number/ name, in button1.execute write me.hide

if you want to use it in ilogic you need to make some chnges...

 

dim path as string

Public Sub saveandreplace()
On Error Resume Next
Dim oAsmDoc As AssemblyDocument
   UserForm1.Show
     path= UserForm1.TextBox1

    Set oAsmDoc = ThisApplication.ActiveDocument
    Dim oAsmCompDef As ComponentDefinition
    Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
    Dim oLODRep As LevelOfDetailRepresentation
    Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences)
    UserForm1.Show
     name = UserForm1.TextBox1
     oAsmDoc.SaveAs path & name & ext
End Sub

Private Sub TraverseAssembly(Occurrences As ComponentOccurrences)
 On Error Resume Next
    Dim oOcc As ComponentOccurrence
    Dim doc As Document
    For Each oOcc In Occurrences
        If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
            Call TraverseAssembly(oOcc.SubOccurrences)
        End If
     Set doc = oOcc.Definition.Document

ext=rigth(oOcc.Definition.Document.fullfilename, 4)
     UserForm1.Show
     name = UserForm1.TextBox1
        doc.SaveAs path & name & ext, False
    Next 
End Sub

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 3

bradeneuropeArthur
Mentor
Mentor
Use the out of the box inventor "I logic copy design" found in the ribbon when no models are active.

So no coding required...
Regards.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes