Hi,
Here are the steps to keep the sub-assembly independent when creating a new occurrence.
1. Ensure that all the parts in the sub-assembly are saved using a different part file name.
2. Replace all the parts in the sub-assembly and ensure they refer to the new part files created in step-1.
In the Inventor UI, you would do this using Component->Replace
3. Save the modified sub-assembly as a different assembly file.
4. Create a sub-occurrence using the new modified sub-assembly.
This should ensure that the changes to the part files will not get propagated for all the sub-assemblies.
I haven't put them all together yet, but here are the individual parts to do the steps.
Hope this gives you some direction in the meantime.
For saving the sub-assembly :
Dim oAssyDoc As AssemblyDocument
oAssyDoc = doc
Dim oDef As AssemblyComponentDefinition
oDef = oAssyDoc.ComponentDefinition
Dim oSubAssy As ComponentOccurrence
oSubAssy = oDef.Occurrences.Item(2)
Dim oSubAssyDef As AssemblyComponentDefinition
oSubAssyDef = oSubAssy.Definition
Dim oSubAssyDoc As AssemblyDocument
oSubAssyDoc = oSubAssyDef.Document
oSubAssyDoc.SaveAs("D:\Temp\MyNewSubAssy.iam", True)
For saving the parts in a sub-assembly
Dim i As Integer
i = 1
' Save the parts in the sub-assembly with a different file name.
For Each oOcc In oSubAssyOcc.SubOccurrences
If (oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject) Then
Dim oPartPath As String
oPartPath = oOcc.Definition.Document.FullFileName
MessageBox.Show(UCase(oOcc.Name) & " : " & oPartPath)
oOcc.Definition.Document.SaveAs("D:\" & i & ".ipt", True)
End If
i = i + 1
Next
For replacing the parts in the sub-assembly :
' Replace the parts in the new sub-assembly with the newly created ones
i = 1
Dim oDef1 As AssemblyComponentDefinition
oDef1 = oSubAssyDoc1.ComponentDefinition
For Each oOcc In oDef1.Occurrences
If (oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject) Then
Dim oPartPath As String
oPartPath = oOcc.Definition.Document.FullFileName
MessageBox.Show(UCase(oOcc.Name) & " : " & oPartPath)
oOcc.Replace("D:\" & i & ".ipt", True)
End If
i = i + 1
Next
oSubAssyDoc1.SaveAs("D:\MyNewSubAssy.iam", False)
For creating a new occurrence using the sub-assembly
' Load the modified sub-assembly
oMatrix = ThisApplication.TransientGeometry.CreateMatrix()
oTG = ThisApplication.TransientGeometry
oMatrix.SetTranslation(oTG.CreateVector(0, (NELV-SF)/10, 0))
Call oAssyDoc.ComponentDefinition.Occurrences.Add("D:\MyNewSubAssy.iam", oMatrix)
oAssyDoc.Activate
Regards,
Balaji
Balaji
Developer Technical Services
Autodesk Developer Network