The previous example I posted whilst it creates the members from the factory it does not allow iProperties to be added to each member. I had worked on this issue before you posted over the holidays I was using this to import MRP/inventory information in to the iParts. The iPart table is difficult to arrange all columns in the correct order for a mass copy and paste so this was a solution for that.
There seems to be two methods to update the iProperties through ILogic and if you read the instructions you should see the difference when you run the code using either Method A or Method B.
I like Method A as it is the method that you would use for any parameters changing so iProperties should also follow this method.
If you want to test this follow Method B first then add the iProperties columns and follow method A
Test on a sample part first to ensure results are accurate enough before running in production.
Below is code for for your situation, either run as internal or external rule, event triggers should be easy enough to set up. .
'https://forums.autodesk.com/t5/inventor-customization/automate-idw-drawing-file-creation-for-all-ipart-members/td-p/9420094
'http://inventortrenches.blogspot.com/2013/03/determine-file-type-for-ilogic-rule.html
'Instructions***************************************************
'Method A:Rule run when iProperties columns are added to the iPart factory table:
'Add iProperties columns to the iPart factory table before running this rule.
'1.This rule will loop through each member applying the iProperties then activate each member.
'2.This activation will force the System generated message box to appear reading
'"The values in the Active Row of the table do not match the document's current values.
'Do you wish To update the table before continuing?"
'3. Manually accept this change and select yes.
'4. Cycle repeats.
'Method B:Rule run without iProperties columns added to the iPart factory table:
'1.This rule will loop through each member applying the iProperties then activate each member.
'2.iPart members are created/updated and receive the iProperties but the factory iProperties will show only the last member the iProperties were added Too.
'3.Cycle repeats.
'
'This method can be confusing as you cannot check the results of the rules, Solution add any column that changes to the Table.
'Instructions End ***************************************************
'start of iLogic rule - - - - - - - - - - - - - - - - - -
Check = MessageBox.Show("Add required iProperties to first member then add columns to iPart factory table" _
& vbNewLine & "" _
& vbNewLine & "If iProperty columns are not present only one member will have iProperties updated correctly" _
& vbNewLine & "in the factory file, member properties will be updated" _
& vbNewLine & "" _
& vbNewLine & "This rule will work on all iPart members,if there are many it will take a long time!" _
& vbNewLine , "Ilogic Instructions", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If Check = vbYes Then
Dim oDoc As Document
oDoc = ThisDoc.Document
'Check if ODoc is a Part Document
If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then
'MessageBox.Show("This is a part file.", "iLogic")
' Set a reference to the component definition
oDef = ThisApplication.ActiveEditDocument.ComponentDefinition
' Make sure we have an iPart factory.
If oDef.IsiPartFactory = False Then
MsgBox ("Chosen document is not a factory.", vbExclamation)
Exit Sub
End If
' Set a reference to the factory.
Dim oFactory As iPartFactory
oFactory = oDef.iPartFactory
'iPartF = oDef.iPartMember.ParentFactory
' Get the number of rows in the factory.
Dim iNumRows As Integer
iNumRows = oFactory.TableRows.Count
Dim iRow As Integer
'Set iRow = First Member
Try
For iRow = 1 To iNumRows
'Change ipart Row
iPart.ChangeRow("", iRow)
'Use if memberfile name needed
'MemberFileName = oFactory.FileNameColumn(iRow).Value
'MessageBox.Show(MemberFileName, "Title")
'[---Call external "function" or rule or do something---
Dim Length As Decimal = 0.0
Dim Height As Decimal = 0.0
Dim Width As Decimal = 0.0
Length = Measure.ExtentsLength
Height = Measure.ExtentsHeight
Width = Measure.ExtentsWidth
Dim SLength As String = Length.ToString()
Dim SHeight As String = Width.ToString()
Dim SWidth As String = Height.ToString()
iProperties.Value("Custom", "LUNGHEZZA_EXT") = SLength
iProperties.Value("Custom", "LARGHEZZA_EXT") = SWidth
iProperties.Value("Custom", "ALTEZZA_EXT") = SHeight
'
'[Select by UI the node of current member in order to bring up the message ipart has change contents,
'If this is not used iproperties will only apply to last member active
'https://forums.autodesk.com/t5/inventor-customization/possible-to-check-all-members-of-factory-for-errors-using-ilogic/td-p/3863094
Dim oErrorManager As ErrorManager
oErrorManager = ThisApplication.ErrorManager
Dim oTop As BrowserNode
oTop = oDoc.BrowserPanes("Model").TopNode
Dim bHasErrorOrWarning As Boolean
'ThisApplication.SilentOperation = True
' Highlight the iPart table row
oTop.BrowserNodes("Table").BrowserNodes.Item(iRow).DoSelect
' Activate the iPart table row this will trigger the do you want to change table contents accept yes to allow iproperties to stick to the member row.
Dim oCommand As ControlDefinition
oCommand = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd")
oCommand.Execute
'ThisApplication.SilentOperation = False
If oErrorManager.HasErrors Or oErrorManager.HasWarnings Then
MsgBox (oErrorManager.LastMessage, vbOKCancel)
End If
']
'Rebuild as create member can sometimes fail
ThisDoc.Document.Rebuild()
Try
'Create each member
Call oFactory.CreateMember
Catch
MessageBox.Show("Error creating Member", "iLogic")
End Try
Next
Catch
MessageBox.Show("Error Exiting", "iLogic")
End Try
iLogicVb.UpdateWhenDone = True
'open folder
oFolder = ThisDoc.Path &"\" & ThisDoc.FileName(False)
Call Shell("explorer.exe" & " " & oFolder, vbNormalFocus)
End If
Else
MessageBox.Show("Rule Canceled Exiting", "iLogic")
End If
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan