Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic error on updating mass on drawing

10 REPLIES 10
Reply
Message 1 of 11
JSTS_JHS
372 Views, 10 Replies

Ilogic error on updating mass on drawing

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 😛

 

10 REPLIES 10
Message 2 of 11
Frederick_Law
in reply to: JSTS_JHS

Try:

Dim UpdateMass As Double

UpdateMass = iProperties.Mass(modelName)

Message 3 of 11
JSTS_JHS
in reply to: Frederick_Law

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 🙂

Message 4 of 11
Frederick_Law
in reply to: JSTS_JHS

You still need this:

modelName =  oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
Message 5 of 11
JSTS_JHS
in reply to: Frederick_Law

'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.

Message 6 of 11
JelteDeJong
in reply to: JSTS_JHS

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.

EESignature


Blog: hjalte.nl - github.com

Message 7 of 11
JSTS_JHS
in reply to: JelteDeJong

JSTS_JHS_0-1688626554781.png

 

Nope. Still nothing 😞

Message 8 of 11
FINET_Laurent
in reply to: JSTS_JHS

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"

@LinkedIn     @JohnCockerill

Message 9 of 11
JSTS_JHS
in reply to: FINET_Laurent

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? 🙂 

Message 10 of 11
Frederick_Law
in reply to: JSTS_JHS

I use external rule on BeforeSave trigger on part and assembly to update mass.

Message 11 of 11

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"

@LinkedIn     @JohnCockerill

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report