Hi all,
I have been using this iLogic rule for almost two years now, but i have recently migrated to Inventor 2024, and all of a sudden i get an error on line 14 of this code:
'For several parts in drawing environment 'update mass to avoid the "N/A" in title block Dim oApp As Application: oApp = ThisApplication Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument Dim oSheets As Sheets Dim oSheet As Sheet Dim oViews As DrawingViews Dim oView As DrawingView oSheets = oDoc.Sheets For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews modelName = oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName iProperties.Mass(modelName) 'force to read the property Next Next InventorVb.DocumentUpdate() 'update drawing
And this in line 14:
iProperties.Mass(modelName) 'force to read the property.
This is the error i'm getting:
Rule Compile Errors in JSTS_Autoupdate Mass, in L40x40x4 x 160 1688561496858.idw
Error on Line 14 : Access to a property must be done by assigning the property a value or by using the property's value.
And i dont know how to fix it 😛
Sorry for being new at this, but if my rule will be as following:
'For several parts in drawing environment 'update mass to avoid the "N/A" in title block Dim oApp As Application: oApp = ThisApplication Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument Dim oSheets As Sheets Dim oSheet As Sheet Dim oViews As DrawingViews Dim oView As DrawingView oSheets = oDoc.Sheets For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews Dim UpdateMass As Double UpdateMass = iProperties.Mass(modelName) Next Next InventorVb.DocumentUpdate() 'update drawing
Then nothing is happening. No errors though 🙂
You still need this:
modelName = oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
'For several parts in drawing environment 'update mass to avoid the "N/A" in title block Dim oApp As Application: oApp = ThisApplication Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument Dim oSheets As Sheets Dim oSheet As Sheet Dim oViews As DrawingViews Dim oView As DrawingView oSheets = oDoc.Sheets For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews Dim UpdateMass As Double modelName = oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName UpdateMass = iProperties.Mass(modelName) Next Next InventorVb.DocumentUpdate() 'update drawing
Now i get this errorcode:
Error on line 15 in rule: JSTS_Autoupdate Mass - Kopi, in document: RG-4-SS002.idw
iProperties: The component named "RG-4-SS002" was not found.
You could try this:
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim names = oDoc.Sheets.Cast(Of Sheet).
SelectMany(Of DrawingView)(Function(v) v.DrawingViews.Cast(Of DrawingView)).
Select(Of String)(Function(v) v.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName).
Distinct().ToList()
For Each name As String In names
Dim pos As Integer = InStr(name, " (")
If (pos = 0) Then pos = name.Length + 1
Dim nameWithoutModelstateName = name.Substring(0, pos - 1)
Dim UpdateMass As Double = iProperties.Mass(nameWithoutModelstateName)
Logger.Info(String.Format("{0}: {1}", nameWithoutModelstateName, UpdateMass))
Next
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
Hi @JSTS_JHS,
Hi, I'm not sure I understand what you are trying to do. Can you explain a bit the workflow you are trying to achieve?
Is it about reading an iPorperty and puting it in a title block?
Kind regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"Hi Finet,
Sorry if im not being clear enough about the worfklow.
I'm trying to make Inventor update the mass of the given assembly/part/sheetmetal etc. in the active drawing window/drawing sheet.
And then i want the iLogic to trigger on Drawings 'After Save Document'.
The reason for this is so that when i'm done creating/modifying or anything to else to the assembly/part/sheetmetal the mass will always be up to date, and not showing N/A.
Does this makes sense? 🙂
I use external rule on BeforeSave trigger on part and assembly to update mass.
Hi @JSTS_JHS,
What about updating the document ?
Dim oApp As Application : oApp = ThisApplication
Dim oDoc As DrawingDocument : oDoc = oApp.ActiveDocument
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
oSheets = oDoc.Sheets
For Each oSheet In oSheets
oViews = oSheet.DrawingViews
For Each oView In oViews
Dim ViewDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
ViewDoc.Update
Dim ViewDocName As String = ViewDoc.DisplayName
Dim UpdateMass As Double = iProperties.Mass(ViewDocName)
MsgBox(UpdateMass)
Next
Next
InventorVb.DocumentUpdate() 'update drawing
Kind regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"Can't find what you're looking for? Ask the community or share your knowledge.