Hellooo Jhoel
Thanks for the code, however it was works if i ran it on single ilogic, but when i combined it error msg with already declared object, tried to look up and delete the multiple string but did work, sorry.
Can you please review below code?
'define custom property collection
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
'look at each property in the collection
For Each oCustProp In oCustomPropertySet
'delete the custom iProperty
oCustProp.Delete
Next
Dim propertyName1 As String = "Rev Desc"
Dim propertyValue1 As String = ""
Dim customPropertySet As PropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
Try
prop = customPropertySet.Item(propertyName1)
Catch
customPropertySet.Add("", propertyName1)
End Try
Dim propertyName2 As String = "Rev Date"
Dim propertyValue2 As Nullable(Of Date) = Date.Now
Dim NullDate As Nullable(Of Date)
Try
prop = customPropertySet.Item(propertyName2)
Catch
customPropertySet.Add(propertyValue2, propertyName2)
iProperties.Value("Custom", propertyName2) = NullDate
End Try
Dim propertyName3 As String = "LaserProficient"
Dim propertyValue3 As String = InputBox ("Laser Proficient:","Set Property", "Yes")
Try
prop = customPropertySet.Item(propertyName3)
Catch
customPropertySet.Add(propertyValue3, propertyName3)
End Try
Dim propertyName4 As String = "ECN_DATE"
Dim propertyValue4 As Nullable(Of Date) = Date.Now
Try
prop = customPropertySet.Item(propertyName4)
Catch
customPropertySet.Add(propertyValue4, propertyName4)
iProperties.Value("Custom", propertyName4) = NullDate
End Try
Dim propertyName5 As String = "ECN_ENGINEER"
Dim propertyValue5 As String = ""
Try
prop = customPropertySet.Item(propertyName5)
Catch
customPropertySet.Add(propertyValue5, propertyName5)
End Try
Dim propertyName6 As String = "ECN_NUMBER"
Dim propertyValue6 As String = ""
Try
prop = customPropertySet.Item(propertyName6)
Catch
customPropertySet.Add(propertyValue6, propertyName6)
End Try
Dim oUM As UnitsOfMeasure = oDoc.UnitsOfMeasure
Dim oLengthUnits As String = InputBox("Length units:", "Set Length Units", oUM.GetStringFromType(oUM.LengthUnits))
Try
oUM.LengthUnits = oUM.GetTypeFromString(oLengthUnits)
Catch
MessageBox.Show("""" & oLengthUnits & """"& " is not a valid length units", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Dim oMassUnits As String = InputBox("Mass units:", "Set Mass Unit", oUM.GetStringFromType(oUM.MassUnits))
Try
oUM.MassUnits = oUM.GetTypeFromString(oMassUnits)
Catch
MessageBox.Show("""" & oMassUnits & """"& " is not a valid mass units", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Dim oDoc As PartDocument = ThisDoc.Document
Dim oMaterials As New List(Of String)
Try
For Each oMaterial As MaterialAsset In ThisApplication.ActiveMaterialLibrary.MaterialAssets
oMaterials.Add(oMaterial.DisplayName)
Next
Dim selectedMaterial As String = InputListBox("Select material", oMaterials, oDoc.ActiveMaterial.DisplayName)
oDoc.ActiveMaterial = ThisApplication.ActiveMaterialLibrary.MaterialAssets.Item(selectedMaterial)
End Try
iProperties.Value("Summary", "Author") = ThisApplication.UserName
iProperties.Value("Project", "Revision Number") = InputBox("Revision Number:", "Set Property", "-")
iProperties.Value("Project", "Designer") = ThisApplication.UserName
iProperties.Value("Project", "Engineer") = ThisApplication.UserName
iProperties.Value("Project", "Creation Date") = Today
ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute
myMass = iProperties.Mass
MessageBox.Show("Mass = " & myMass, "iLogic")