Troubles with (inconsistent lose of) IntelliSense functionallity in the iLogic editor

Troubles with (inconsistent lose of) IntelliSense functionallity in the iLogic editor

PolemEngineering
Advocate Advocate
485 Views
8 Replies
Message 1 of 9

Troubles with (inconsistent lose of) IntelliSense functionallity in the iLogic editor

PolemEngineering
Advocate
Advocate

The IntelliSense functionallity in the iLogic editor keeps losing reference to the iLogic objects.

 

Whenever I use some more extensive iLogic code I lose insight into the iLogic specific objects.

Sometimes it comes back when I close and reopen the editor. It's just a visual thing, because the code still works. But it does make coding more difficult.

 

So basic code just works fine.

 

Dim oDoc as Document = ThisDoc.FactoryDocument

 

But when I make it slightly more advanced by adding multiple subs and adding references to other StraightVB files etc (like shown below), then the problem reveals itself (sometimes).

Objects like ThisApplication, ThisDoc, Logger, SharedVariables, etc losing their (purple, probably due to darm mode setting) color and tooltip information. The rule itself keeps working like expected.

 

Option Explicit On
Option Strict On
AddVbFile "General\CheckWritability.txt"
Class ThisRule
Sub Main()
Dim oDoc As Document = ThisDoc.Document
'etc.
End Sub
Sub OtherRoutine(ByRef oDoc As Document)
End Sub
End Class

 

 

It's just hard to reproduce. Do others have this problem and is there a setting or piece of code that can prevent this? Perhaps by explicitly naming or referring to something.

From the documentation I think I understand that Inventor does a lot of things implicitly.

 

Currently using Inventor Professional 2023.5.1

René van der Starre

0 Likes
Accepted solutions (3)
486 Views
8 Replies
Replies (8)
Message 2 of 9

Michael.Navara
Advisor
Advisor

I don't have this experience, but I believe it can happens. I use iLogic for VisualStudio for creating the iLogic code and later on just copy+paste the code text to iLogic.

There are no issues in VS with intellisense. 

0 Likes
Message 3 of 9

ryan.rittenhouse
Advocate
Advocate

I've run in to this same behavior (Inventor 2024.3 and Inventor 2021), but I haven't been able to nail down a consistent trigger for it. I do notice that it happens more often if I have the Visual Studio Debugger attached to the Inventor instance.

If this solved your problem, or answered your question, please click Accept Solution.
0 Likes
Message 4 of 9

Curtis_Waguespack
Consultant
Consultant

@PolemEngineering , I've seen this pretty consistently anytime I add the rule class, such as Class ThisRule

 

Maybe @MjDeck can tell us more about this.

EESignature

0 Likes
Message 5 of 9

MjDeck
Autodesk
Autodesk
Accepted solution

@PolemEngineering , the problem can most likely be fixed by removing the parentheses after Sub Main. That is, change:

Sub Main()

to

Sub Main

This is internal issue number INVGEN-81977.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 9

MjDeck
Autodesk
Autodesk
Accepted solution

The above problem only happens if you have a Class declaration.

If intellisense fails in other cases, and the rule has a header, try editing the header (e.g. just add a character and then delete it) and then go back to the main editing area of the rule.
Or close the rule and reopen it.
Please provide details of other failures.


Mike Deck
Software Developer
Autodesk, Inc.

Message 7 of 9

WCrihfield
Mentor
Mentor
Accepted solution

I definitely know what you are talking about.  Most of the time when Intellisense is not offering any suggestions about some of my code, I understand why, but not 100% of the time.  But explaining all the possible reasons why it could happen (possibly with examples) would require typing up a novel here in a forum reply, and would most likely still be incomplete or contain some bad information.  It's just to broad of a subject.  One of the most common situations is when a property returns an 'Object' (or Variant in VBA) type value, instead of a more specific Type.  When that happens, it stops helping, because a plain Object does not have any properties or methods (besides ToString method).

 

If you have ever inspected the 'temp' text file that gets automatically created for your 'regular' iLogic rule (usually located at C:\Users\%user%\AppData\Local\Temp\iLogic Rules\), you will get a 'hint' about some of the 'extra' stuff that actually gets added into our rules 'behind the scenes' that we never see, but not all of it.  When our 'internal' iLogic rules get stored in the Document, some (if not all) of that data gets stored within document level Attributes, one way or another, either as a String, or as a Byte Array.  And there are usually two different versions of each internal rule...the 'Exec' version, and the version that looks like what you see in the 'temp' file, with the extra hints in it.  The Exec version includes the whole rule, with all the additional stuff, such as the other half of the 'Public Partial Class' block of code.  (See examples below)

 

The main Class that automatically encloses all of our 'normal' iLogic rules is called 'ThisRule', and that Class block of code is created for us automatically behind the scenes, as a 'Public Partial Class', and it will even add the 'Class ThisRule...End Class' part into our rule, if we do not include it ourselves (but we never see that).  So, there is a whole other section to this Class in which they create variables, and assign values to them, and create pointers to entire large blocks of other codes that we never see.  The iLogic add-in will also create/add the 'Sub Main...End Sub' for us behind the scenes, if we do not include them ourselves, but we usually never see that either.  These things are required in normal 'VB.NET' coding environments, but iLogic makes it easier for those who are not used to that, and do not know about all those vb.net coding expectations/requirements, to write code that will work for us, to automate Inventor.

 

The following online help page touches on some of this stuff, but does not really go deep into the details of it.

Advanced iLogic Techniques Reference 

 

Example of normal, internal rule, with only 3 lines of code:

 

Dim oInvApp As Inventor.Application = ThisApplication
Dim oDoc As Document = ThisDoc.Document
MessageBox.Show("DisplayName = " & oDoc.DisplayName, "DisplayName", MessageBoxButtons.OK, MessageBoxIcon.Information)

 

And here is an example of the 'Temp' file contents for that rule above:

 

Imports System.Windows.Forms ''**iLogic system**

''**iLogic system code start**
Imports Inventor
''**iLogic system code end**

Public Partial Class ThisRule ''**iLogic system**
Public Sub Main() Implements IRuleInterface.Main ''**iLogic system**
Dim oInvApp As Inventor.Application = ThisApplication
Dim oDoc As Document = ThisDoc.Document
MessageBox.Show("DisplayName = " & oDoc.DisplayName, "DisplayName", MessageBoxButtons.OK, MessageBoxIcon.Information)

End Sub ''**iLogic system**
End Class ''**iLogic system**

 

And below is the 'Exec' version of that same rule:

 

'''' concatenated string lengths:	538	1155

Imports System.Windows.Forms ''**iLogic system**

''**iLogic system code start**
Imports Inventor
''**iLogic system code end**

Public Partial Class ThisRule ''**iLogic system**
Public Sub Main() Implements IRuleInterface.Main ''**iLogic system**
Dim oInvApp As Inventor.Application = ThisApplication
Dim oDoc As Document = ThisDoc.Document
MessageBox.Show("DisplayName = " & oDoc.DisplayName, "DisplayName", MessageBoxButtons.OK, MessageBoxIcon.Information)

End Sub ''**iLogic system**
End Class ''**iLogic system**
Public Partial Class ThisRule
  Implements IRuleInterface

  Public m_iLogicVersionDate as Integer = 20170212
  Private m_iLogicHost As IRulesHost
  Private m_pc39483c As IParamChanger
  Private iLogicVb As ILowLevelSupport
  Private InventorVb As ILowLevelSupport
  Private ThisApplication As Inventor.Application
  Private ThisDoc As ICadDoc
  Private Const KeysOnly As XmlSaveOption = XmlSaveOption.KeysOnly
  <System.Diagnostics.DebuggerNonUserCode()> _
  Public Sub SetHost(ByVal host As IRulesHost) Implements IRuleInterface.SetHost
    m_iLogicHost = host
    m_pc39483c = host.GetParamChanger()

    Me.iLogicVb = host.GetLowLevelSupport()
    Me.InventorVb = Me.iLogicVb
   ThisApplication = InventorVb.Application
   ThisDoc = New CadDoc(iLogicVb.RuleDocument, InventorVb.InventorServer)
  End Sub

<System.Diagnostics.DebuggerNonUserCode()> _
 Public Sub RuleParametersInit() Implements IRuleInterface.RuleParametersInit
 End Sub

<System.Diagnostics.DebuggerNonUserCode()> _
 Public Sub RuleParametersOutput() Implements IRuleInterface.RuleParametersOutput
  m_pc39483c.OutputToCadModel()
 End Sub
End Class

 

I believe this Exec version of the rule may get 'generated' based on the iLogic system's inspection of our regular rule's contents, then it is what actually gets ran/used.  I believe this because it actually tells us that if we use certain terms (such as ThisApplication, ThisDoc, MessageBox.Show, and others) within our rules, it will automatically include specific 'Imports' statements (such as for 'Inventor' and 'System.Windows.Forms') in the 'Header' of our rule for us (as you can see in 'Exec' the code above).

 

So as you can see, there is a whole lot of other stuff going on in the background to enable our 'simpler' experience within our iLogic rules.  And this is just the tip of the iceberg so to speak.  Ended up typing a whole lot after all. 🙄

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 9

PolemEngineering
Advocate
Advocate

Thanks for the responses!

Where can this Exec version be found? Perhaps this file can provide a piece of the puzzle for another problem I'm running into...

René van der Starre

0 Likes
Message 9 of 9

WCrihfield
Mentor
Mentor

Hi @PolemEngineering.  It is not really a 'file', it is just some String type data that seems to automatically get generated and saved within the value of a Document level Attribute whenever we create any internal iLogic rules within a Document.  There are several Document level attributes that get created and/or updated when we create or edit any internal iLogic objects, such as internal iLogic rules and internal iLogic forms.  Some seem to keep track of rule names, data versions, rule flags, rule text, rule params, rule exec text, rule reference assemblies, document rule options, rule running order, document language settings, the layout of the 'Forms' tab (because it is a Form of its own), and buttons for launching the individual internal forms, if there are any, the form specifications of those internal forms, if there are any, so on.  There are several different Types of data involved among all those different attributes, with some being Byte arrays that may need to be interpreted.  I just assume that the 'exec' terminology just means that this is the version of the rule that actually gets 'executed', while the other versions are more for making the iLogic rule code creation simpler and easier for folks who have little or no previous coding experience, and are not aware of all the various vb.net coding standards/requirements/formatting.

 

These were discovered incrementally, using some relatively simple code to iterate the document level attributes at first.  Then that 'inspection' code kept getting further developed for handling the different data types differently, and to help improve the visual output formatting.  Now I have different versions of it, for different purposes.  The idea to look in this area was inspired by a forum reply by Curtis Waguespack in the following forum discussion:

https://forums.autodesk.com/t5/inventor-programming-ilogic/delete-forms-with-rule/m-p/11186850 

I did recall seeing some data like this before at some point, like maybe while using something like AttributeHelper or Nifty Attributes add-in, but it never really registered.  Then I kept digging deeper (as time permitted) until I found a lot more.  And eventually figure out how to find and delete an individual internal iLogic form, by its name, which was far more complex than I had imagined, and posted that first at the following link.

https://forums.autodesk.com/t5/inventor-programming-ilogic/remove-ilogicform-by-ilogic-rules/m-p/125... 

I have attached a text file containing one version of that type of code.  This version is a bit simplified, focusing mainly on specifically named attributes with String type values, which contain the two main versions of the code.  If I am remembering correctly, then I think there may be another version of the iLogic rule code (like what we see in the temp file) in one of the byte arrays also, but I left that part out for now.  When dealing with the Byte arrays, there is 'encoding' involved, and it is not clear which type of encoding was used, and the results may even need some interpretation at times, so it is not 100% yet.

 

I am not sure where you would be able to find similar information (exec versions) for the external iLogic rules.  Since they are not document dependent, there is likely an external file for that, maybe in a 'temp' folder, not sure.  I am aware of the external XML file which records our global forms specifications, too, but don't really do much with that myself.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes