Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am attempting to write some code to create multiple iProperties in my model from the idw. The parameters are in an arraylist and I would like to use a loop to run through the arraylist but I keep getting an error. I would like to use a loop so I don't have to write out a try catch for each iProperty as the list is continually growing.
my code is a little confusing as the list is called oParameterList I should have named it oPropertyList. I intend to fix this
SyntaxEditor Code Snippet
iLogicVb.UpdateWhenDone = True Dim odrawdoc As DrawingDocument odrawdoc = ThisApplication.ActiveDocument Dim userParams As UserParameters = odrawdoc.Parameters.UserParameters customIDWPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties") 'Look at the model file referenced in the open document Dim docFile As Document If ThisDoc.ModelDocument IsNot Nothing Then docFile = ThisDoc.ModelDocument Else MessageBox.Show("This drawing has no model reference", "iLogic") Return End If 'format model file name Dim FNamePos As Long FNamePos = InStrRev(docFile.FullFileName, "\", -1) Dim docFName As String docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 'define the property set customPropertySet = docFile.PropertySets.Item("Inventor User Defined Properties") customIDWPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties") 'look for the custom propety and add it if not found Dim oCode, oColor, oDesignPSI, oDIA, oEdition, oExBlast, oExCoat, oHydroChart,oInBlast, oInCoat, oLength, oLocation, oNPRO, oPWHT, oTestPSI As String Dim oString As Object Dim i As Integer = 0 Dim oParameterList As New ArrayList oParameterList.Add("Code") oParameterList.Add("Color") oParameterList.Add("Design_Pressure") oParameterList.Add("Design_Temp") oParameterList.Add("Min_Design_Temp") oParameterList.Add("DiameterIN") oParameterList.Add("Edition") oParameterList.Add("External_Blast") oParameterList.Add("External_Coat") oParameterList.Add("HYDRO CHART") oParameterList.Add("Internal_Blast") oParameterList.Add("Internal_Coat") oParameterList.Add("Length_UL") oParameterList.Add("Location") oParameterList.Add("NAME PLATE RUB OFF") oParameterList.Add("PWHT") oParameterList.Add("Test_Pressure") For Each oString In oParameterList Try prop = customPropertySet.Item(oParameterList(i)) 'return Catch customPropertySet.Add("", oParameterList(i)) End Try Try prop = customIDWPropertySet.Item(oParameterList(i)) Catch customIDWPropertySet.Add("", oParameterList(i)) End Try i = i + 1 Next
Solved! Go to Solution.