- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I'm not all that up to speed with iLogic but I've cobbled together a rule to generate all members of an iPart/iAssembly factory. This is good but I really want it to also save as another format too like a .sat file or .step and I cant seem to get it to, it will only save the current member.
' Set reference to active document.
oDoc = ThisApplication.ActiveDocument
' Check the Document type is an assembly or part
If (oDoc.DocumentType <> kAssemblyDocumentObject And _
oDoc.DocumentType <> kPartDocumentObject) Then
MsgBox("Error:Document type is not assembly/part")
Exit Sub
End If
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim initRowIndex As Integer
Dim oFactory As iAssemblyFactory = oDef.iAssemblyFactory
Dim oRow As iAssemblyTableRow
For Each oRow In oFactory.TableRows
' Generate the member and file, (overwrites member file or creates new file)
oFactory.CreateMember(oRow)
' Get document's full file name
sFname = iProperties.Value("Project", "Part Number") & ".sat"
' Do a 'Save Copy As' to SAT format
oDoc.SaveAs(sFname, True)
Next
Anyone able to help get the save as for each member working?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hoping that below iLogic code may be helpful to save iAssemblymembers. Similarly, code can be modified for iPart.
' Set reference to active document.
oDoc = ThisApplication.ActiveDocument
' Check the Document type is an assembly or part
If (oDoc.DocumentType <> kAssemblyDocumentObject And _
oDoc.DocumentType <> kPartDocumentObject) Then
MsgBox("Error:Document type is not assembly/part")
Exit Sub
End If
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim initRowIndex As Integer
Dim oFactory As iAssemblyFactory = oDef.iAssemblyFactory
Dim oRow As iAssemblyTableRow
Dim oMember As iAssemblyMember
For Each oRow In oFactory.TableRows
' Generate the member and file, (overwrites member file or creates new file)
oMember = oFactory.CreateMember(oRow)
Dim oPath As String
oPath = oMember.ParentFactory.MemberCacheDir
Dim oReferDoc As AssemblyDocument
oReferDoc = ThisApplication.Documents.Open(oPath & "\" & oRow.MemberName & ".iam", True)
Dim oName As String
oName = oReferDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
Call oReferDoc.SaveAs(oPath & "\" & oName & ".iam", True)
Call oReferDoc.Close
Next
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there, thank you for your help. I've had a go with the code but I am getting an error with line 20
"Error on Line 20 : Expression does not produce a value."
Is there something i could be missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Actually, previous code is for iAssmeblyFactory. Is code is used for iAssembly or iPart?
If you provide non confidential iAssmebly file, I can simulate error and correct the same.
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you, attached is the assembly i am trying to export each memeber out as an obj in this case. I could generate all the members with my code but I couldnt figure out how to export each one as well, it just exported the current member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Try this iLogic code for iAssembly.
' Set reference to active document.
oDoc = ThisApplication.ActiveDocument
' Check the Document type is an assembly or part
If (oDoc.DocumentType <> kAssemblyDocumentObject And _
oDoc.DocumentType <> kPartDocumentObject) Then
MsgBox("Error:Document type is not assembly/part")
Exit Sub
End If
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim initRowIndex As Integer
Dim oFactory As iAssemblyFactory = oDef.iAssemblyFactory
Dim oRow As iAssemblyTableRow
Dim oMember As iAssemblyMember
For Each oRow In oFactory.TableRows
' Generate the member and file, (overwrites member file or creates new file)
Call oFactory.CreateMember(oRow)
Dim oPath As String
oPath = oFactory.MemberCacheDir
Dim oReferDoc As AssemblyDocument
oReferDoc = ThisApplication.Documents.Open(oPath & "\" & oRow.MemberName & ".iam", True)
Dim oName As String
oName = oReferDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
ThisApplication.SilentOperation = True
Call oReferDoc.SaveAs(oPath & "\" & oName & ".iam", True)
Call oReferDoc.Close
ThisApplication.SilentOperation = False
Next
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear colleagues,
Could you please help us with such question: we are using oFactory.CreateMember method
oMember = oFactory.CreateMember
for processing and saving Assemblymembers (we are using Inventor API to create our own add-in for Inventor), but we use C#. And we get an error, cause it doesn't work. Could you please tell us if this method (oFactory.CreateMember) also could be used for C# or maybe there are some other methods for C#?