I tried to keep this simple, but it looks like I need to fully explain what I'm doing and where I want to be.
I am creating a library of standard parts for a new product line. Some of those parts have are left/right-handed, so I am treating the right-handed part as the parent, then making a separate left-handed part that is a mirror of the right-handed part. All of the parts in this library need to have three custom iProperties ("Part_Number", "Part_Description", and "Part_Reference") that will be called up in the material lists on our drawings.

There are quite a few different permutations of each part because their final shape/size depends on several variables, so I have created a rule that goes through each possible combination of those variables, and saves a file for each one. This allows me to quickly make changes to all of the instances within an entire family of parts as I build up the library. It will also allow for quick wholesale changes if we need to do so for all instances in the family. In this rule, I am iterating through each valid combination of variables, entering values for the three custom iProperties, updating the model, saving the right-handed version to a new filename, then creating the left-handed version.
Below is the entirety of the rule that goes through this process.
Imports System
Imports System.Diagnostics
Imports System.Threading
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
' total number of permutations for this part
Dim Iterations As Integer = 136
oQuestion = MessageBox.Show("Do you want to iterate through all " & Iterations & " permutations and save new files now?", "iLogic", MessageBoxButtons.YesNo)
If oQuestion = vbNo Then
Return
Else
' add revision string
RevString = InputBox("Do you want to add a revision suffix to the end of the part file? (example: -Rev1). If none is required, hit Cancel", "Revision Suffix", "")
' create list of all values for each variable
Dim oType As New ArrayList
Dim oTypeString As New ArrayList
Dim oLength As New ArrayList
Dim oPulleyDia As New ArrayList
Dim oSidewallHeight As New ArrayList
oType.Add("S")
oType.Add("I")
oTypeString.Add("Slider")
oTypeString.Add("Idler")
oLength.Add(5)
oLength.Add(6)
oLength.Add(7)
oLength.Add(8)
oLength.Add(9)
oLength.Add(10)
oLength.Add(11)
oLength.Add(12)
oPulleyDia.Add(10)
oPulleyDia.Add(12)
oPulleyDia.Add(14)
oPulleyDia.Add(16)
oSidewallHeight.Add(3)
oSidewallHeight.Add(6)
oSidewallHeight.Add(8)
oSidewallHeight.Add(10)
Dim oBaseFilePath As String = ThisDoc.Path & "\"
Dim oPNstring As String
Dim oNewFileName As String
For a As Integer = 0 To oType.Count() - 1
Parameter("Type") = oTypeString(a)
If Parameter("Type") = "Slider"
cMIN = 0
cMAX = 3
dMIN = 0
dMAX = 1
Else If Parameter("Type") = "Idler"
cMIN = 1
cMAX = 3
dMIN = 1
dMAX = 3
End If
For b As Integer = 0 To oLength.Count() - 1
Parameter("Length") = oLength(b) * 12
For c As Integer = cMIN To cMAX
Parameter("Pulley_Diameter") = oPulleyDia(c)
For d As Integer = dMIN To dMAX
Parameter("Sidewall_Height") = oSidewallHeight(d)
Dim StartTime As DateTime
Dim ElapsedTime As TimeSpan
Dim ProjectedTime As TimeSpan
' start timer for one iteration
If a = 0 And b = 0 And c = 0 And d = 0
StartTime = Now
End If
' create part_number string
oPNstring = "HP-" & oType(a) & "-" & oLength(b) & "-" & oPulleyDia(c) & "-" & oSidewallHeight(d)
' create part_description string
Width = Parameter("Length")
Wfeet = Floor(Width / 12)
Winches = Floor(Width - (Wfeet * 12))
Wremainder = Width - Floor(Width)
Height = Parameter("Pulley_Diameter") + Parameter("Sidewall_Height") + 6.5 + 5.2297842
Hfeet = Floor(Height / 12)
Hinches = Floor(Height - (Hfeet * 12))
Hremainder = Height - Floor(Height)
' write to custom properties
iProperties.Value("Custom", "Part_Number") = oPNstring
If Width < Height Then
WidthDesc = RoundToFraction(Width, 1 / 16, RoundingMethod.Round)
If Hremainder = 0
HeightDesc = String.Format("{0}'", Hfeet) & "-" & String.Format("{0}", Hinches)
Else
HeightDesc = String.Format("{0}'", Hfeet) & "-" & String.Format("{0}", Hinches) & " " & RoundToFraction(Hremainder, 1 / 16, RoundingMethod.Round)
End If
iProperties.Value("Custom", "Part_Description") = "3/16 X " & WidthDesc & " X " & HeightDesc
Else
HeightDesc = RoundToFraction(Height, 1 / 16, RoundingMethod.Round)
If Wremainder = 0
WidthDesc = String.Format("{0}'", Wfeet) & "-" & String.Format("{0}", Winches)
Else
WidthDesc = String.Format("{0}'", Wfeet) & "-" & String.Format("{0}", Winches) & " " & RoundToFraction(Wremainder, 1 / 16, RoundingMethod.Round)
End If
iProperties.Value("Custom", "Part_Description") = "3/16 X " & HeightDesc & " X " & WidthDesc
End If
iProperties.Value("Custom", "Part_Reference") = "HEAD PANEL"
' create new filename
oNewFileName = oBaseFilePath & oPNstring
' update model before save as
iLogicVb.RunRule("Dim_Rule")
InventorVb.DocumentUpdate()
' save as new file
ThisDoc.Document.SaveAs(oNewFileName & "-R" & RevString & ".ipt", True)
' create a new part file to derive the selected part into
' note: kPartDocumentObject is the default template
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
' create a derived definition for the selected part
Dim oDerivedPartDef As DerivedPartUniformScaleDef
oDerivedPartDef = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.CreateUniformScaleDef(oNewFileName & "-R" & RevString & ".ipt")
' set the scale to use
oDerivedPartDef.ScaleFactor = 1
' define the mirror plane
'XY plane = 27393
'YZ plane = 27394
'XZ plane = 27395
oDerivedPartDef.MirrorPlane = 27394
' create the derived part
oPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Add(oDerivedPartDef)
' save the new derived part
oPartDoc.SaveAs(oNewFileName & "-L" & RevString & ".ipt", False)
oPartDoc.Close
'MessageBox.Show("New file created at:" & vbLf & oNewFileName & "-L.ipt", "iLogic")
If a = 0 And b = 0 And c = 0 And d = 0
' get the elapsed time for one iteration
ElapsedTime = Now().Subtract(StartTime)
' calculate total time to do all iterations
For i As Integer = 1 To Iterations
ProjectedTime = ProjectedTime.Add(ElapsedTime)
Next
' format and display the TimeSpan value.
Dim TimeString As String = String.Format("{0:00}m:{1:00}s", ProjectedTime.Minutes, ProjectedTime.Seconds)
' calculate total time this will take based on oNumPermutations
oQuestion = MessageBox.Show("This operation will take about " & TimeString & " Do you want to continue?", "iLogic",MessageBoxButtons.YesNo)
If oQuestion = vbNo Then
Return
Else
End If
End If
Next
Next
Next
Next
End If
My goal is to have the left-handed part have the same three custom iProperties with only one change - the '-R' at the end of the "Part_Number" will be '-L' in the mirrored part. The other two iProperties will be identical for both right and left-handed instances.