- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When I run my rule in the drawing document, I get the above error message. Request help.
Inventor Professional 2019
Vault Professional 2019
Solved! Go to Solution.
When I run my rule in the drawing document, I get the above error message. Request help.
Inventor Professional 2019
Vault Professional 2019
Solved! Go to Solution.
Could you upload the code by text?
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
His code is in the .idw file.
The code attempts to USE a property, then catches the error then creates the property. The Catch then creates the property, but you then used the variable prop in the message box. However you forgot to add "prop = "on the previous add line. (hi2 runs, hi2.1 runs, then error) .
Catch
MsgBox("hi2")
customPropertySet.Add("TEST", oCustiProperties_Array.Item(i))
MsgBox("hi2.1")
MessageBox.Show(prop.Name & ": ADDED" & vbLf & prop.Name & " (VALUE): " & prop.Value, "CUST PROP")
MsgBox("hi2.2")
oPrompt = "ASSIGN DATA"
MsgBox("hi2.3")
End Try
Thanks for the reply. My badness: after struggling few hours, I rushed to post for help.
Files are attached here to and code is shown below;
Sub main()
oCust_Prop_Sub()
End Sub
Sub oCust_Prop_Sub()
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'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("NOT OK, This drawing has no model reference", "iLogic")
Return
End If
'oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
'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")
oName_Prop1 = "TOTAL QTY"
oName_Prop2 = "ROLLING_ALLOWANCE"
Dim oCustiProperties_Array As New ArrayList
oCustiProperties_Array.Add(oName_Prop1)
oCustiProperties_Array.Add(oName_Prop2)
For i = 0 To oCustiProperties_Array.Count-1
'look for the custom propety and add it if not found
Try
prop = customPropertySet.Item(oCustiProperties_Array.Item(i))
MessageBox.Show(prop.Name & ": EXISTS" _
& vbLf & prop.Name & " (VALUE): " & prop.Value, "CUST PROP")
oPrompt = "EDIT/ASSIGN DATA"
Catch
customPropertySet.Add("TEST", oCustiProperties_Array.Item(i))
MessageBox.Show(prop.Name & ": ADDED" _
& vbLf & prop.Name & " (VALUE): " & prop.Value, "CUST PROP")
oPrompt = "ASSIGN DATA"
End Try
prop.Value = InputBox(oPrompt, prop.Name, prop.Value)
Next i
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate()
End Sub
Roy Wickrama
Sub main()
oCust_Prop_Sub()
End Sub
Sub oCust_Prop_Sub()
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'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("NOT OK, This drawing has no model reference", "iLogic")
Return
End If
'oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
'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")
oName_Prop1 = "TOTAL QTY"
oName_Prop2 = "ROLLING_ALLOWANCE"
Dim oCustiProperties_Array As New ArrayList
oCustiProperties_Array.Add(oName_Prop1)
oCustiProperties_Array.Add(oName_Prop2)
For i = 0 To oCustiProperties_Array.Count-1
'look for the custom propety and add it if not found
Try
prop = customPropertySet.Item(oCustiProperties_Array.Item(i))
MessageBox.Show(prop.Name & ": EXISTS" _
& vbLf & prop.Name & " (VALUE): " & prop.Value, "CUST PROP")
oPrompt = "EDIT/ASSIGN DATA"
Catch
customPropertySet.Add("TEST", oCustiProperties_Array.Item(i))
prop = customPropertySet.Item(oCustiProperties_Array.Item(i))
MessageBox.Show(prop.Name & ": ADDED" _
& vbLf & prop.Name & " (VALUE): " & prop.Value, "CUST PROP")
oPrompt = "ASSIGN DATA"
End Try
prop.Value = InputBox(oPrompt, prop.Name, prop.Value)
Next i
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate()
End Sub
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
@bradeneuropeArthur, the .Add command returns the object. So his modification works fine as a one liner, and doesn't require the second line to get the item.
prop = customPropertySet.Add("TEST", oCustiProperties_Array.Item(i))
Thanks,
That is correct!
Regards,
Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Dear Bradedeurope;
Thanks a lot.
It runs too smooth.
I will build up the rest of my rule.Your code is a great help.
Roy Wickrama