<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is it possible to use &amp;quot;AddVBFile&amp;quot; in Straight VB Code File? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11884821#M151140</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13752638"&gt;@ColdWatermelonJuice&lt;/a&gt;.&amp;nbsp; Those AddVbFile &amp;amp; AddVbRule tools will only work properly from an iLogic rule that is not set to 'Straight VB Code'.&amp;nbsp; So, you can not chain several of them together end to end like that.&amp;nbsp; You can have one iLogic rule that uses multiple of those tools though.&amp;nbsp; And the iLogic rule using one (or more) of those tools may not need to be set to Straight VB Code to use those reference tools.&amp;nbsp; When more than one layer of references may be needed, you may need to look into creating your own external DLL file that you can reference from an iLogic rule with an AddReference and/or Imports tool, within the 'Header' of the rule.&amp;nbsp; To do that you will likely have to have something like Microsoft Visual Studio installed and a decent understanding of vb.net.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Apr 2023 11:07:58 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2023-04-10T11:07:58Z</dc:date>
    <item>
      <title>Is it possible to use "AddVBFile" in Straight VB Code File?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11884562#M151139</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to call a sub, which is declared in a class from a separate VB file, and this sub also calls another sub from a module declared in another separate VB file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To summarise, I have a total of three VB files, and all of them are stored under the iLogic external rule directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is shown below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File: Code.vb&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;AddVbFile "ExternalClass.vb"

Sub Main()

    ClassA.MSGC()

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File: ExternalClass.vb&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;AddVbFile "ExternalModule.VB"

Public Class ClassA

    Public Shared Sub MSGC()
        System.Windows.Forms.MessageBox.Show("Call from ClassA")
        ModuleB.MSGM()
    End Sub

End Class&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File: ExternalModule.vb&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Public Module ModuleB

    Public Sub MSGM()
        System.Windows.Forms.MessageBox.Show("Call from ModuleB")
    End Sub

End Module&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After I ran the Code.vb file. I got the following error message.&lt;/P&gt;&lt;P&gt;Rule Compile Errors in Code, in Part1&lt;/P&gt;&lt;P&gt;Error on Line 1 : Declaration expected.&lt;BR /&gt;Error on Line 7 : 'ModuleB' is not declared. It may be inaccessible due to its protection level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think Line 1 and Line 7 &lt;SPAN&gt;refer to lines in ExternalClass.vb.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My induction is that straight vb code does not support AddVBFile as it's for ilogic only.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My programming knowledge is very limited, and I do not know how to set up a code that is equivalent to AddVBFile.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 07:32:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11884562#M151139</guid>
      <dc:creator>ColdWatermelonJuice</dc:creator>
      <dc:date>2023-04-10T07:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use "AddVBFile" in Straight VB Code File?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11884821#M151140</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13752638"&gt;@ColdWatermelonJuice&lt;/a&gt;.&amp;nbsp; Those AddVbFile &amp;amp; AddVbRule tools will only work properly from an iLogic rule that is not set to 'Straight VB Code'.&amp;nbsp; So, you can not chain several of them together end to end like that.&amp;nbsp; You can have one iLogic rule that uses multiple of those tools though.&amp;nbsp; And the iLogic rule using one (or more) of those tools may not need to be set to Straight VB Code to use those reference tools.&amp;nbsp; When more than one layer of references may be needed, you may need to look into creating your own external DLL file that you can reference from an iLogic rule with an AddReference and/or Imports tool, within the 'Header' of the rule.&amp;nbsp; To do that you will likely have to have something like Microsoft Visual Studio installed and a decent understanding of vb.net.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 11:07:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11884821#M151140</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-04-10T11:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use "AddVBFile" in Straight VB Code File?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11886892#M151165</link>
      <description>&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;If you need this complex references, create your own DLL file with all of them.&lt;/P&gt;&lt;P&gt;But because AddVbFile directive is solved at compile time, you can combine this two files from "main" rule.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code.iLogicVb&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;'AddVbFile "C:\Full\Path\To\ModuleB.vb"
'AddVbFile "C:\Full\Path\To\ClassA.vb"
AddVbFile "IC_11884562\ClassA.vb"
AddVbFile "IC_11884562\ModuleB.vb"

Sub Main()
    ClassA.MSGC()
End Sub&lt;/LI-CODE&gt;&lt;P&gt;ClassA.vb&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Public Class ClassA
    Public Shared Sub MSGC()
        System.Windows.Forms.MessageBox.Show("Call from ClassA")
        ModuleB.MSGM()
    End Sub
End Class&lt;/LI-CODE&gt;&lt;P&gt;ModuleB.vb&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Public Module ModuleB
    Public Sub MSGM()
        System.Windows.Forms.MessageBox.Show("Call from ModuleB")
    End Sub
End Module&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Screenshot from iLogic external rules settings&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelNavara_0-1681195811815.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1200751iEADC380A77C82176/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichaelNavara_0-1681195811815.png" alt="MichaelNavara_0-1681195811815.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 06:54:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11886892#M151165</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2023-04-11T06:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use "AddVBFile" in Straight VB Code File?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11887169#M151172</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;, Thank you very much for your reply. I have read a few of your posts about API and iLogic, and they have been extremely helpful as I am just starting to learn programming. I have discovered that there are many things that can be accomplished using APIs. I am trying to set up things in a "universal" way so that other people can easily add features on top of my code in the future (at least, I hope so&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@1A5BF4DFF76C3208F100BEEBB3221CE2/emoticons/1f605.png" alt=":grinning_face_with_sweat:" title=":grinning_face_with_sweat:" /&gt;).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 09:09:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11887169#M151172</guid>
      <dc:creator>ColdWatermelonJuice</dc:creator>
      <dc:date>2023-04-11T09:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use "AddVBFile" in Straight VB Code File?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11887177#M151173</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt;, &lt;SPAN&gt;Thank you for your guidance. I can confirm that the code is now working as expected.&lt;/SPAN&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@F982DDE76110C67DBDB6AF220B48480A/emoticons/1f604.png" alt=":grinning_face_with_smiling_eyes:" title=":grinning_face_with_smiling_eyes:" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 09:12:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/11887177#M151173</guid>
      <dc:creator>ColdWatermelonJuice</dc:creator>
      <dc:date>2023-04-11T09:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use "AddVBFile" in Straight VB Code File?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/12363039#M160095</link>
      <description>&lt;P&gt;Hi everyone, I'm compiling a program with a structure very similar to the one indicated in this topic where I have several classes called within the main rule and some modules that contain "universal" functions that must be called both in the main rule and in the classes.&lt;BR /&gt;My main problem is that from the modules I don't know how to recall and use the ilogic logger.&lt;BR /&gt;In classes I don't have this problem as I pass the logger itself through the class constructor, but for modules I haven't found a valid method.&lt;BR /&gt;Any ideas on how this could be done?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 15:22:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/12363039#M160095</guid>
      <dc:creator>Marco_PeronXTBPH</dc:creator>
      <dc:date>2023-11-08T15:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use "AddVBFile" in Straight VB Code File?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/12363215#M160100</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13253608"&gt;@Marco_PeronXTBPH&lt;/a&gt;.&amp;nbsp; When I want to use the iLogic rule logger in a referenced Class in an external file that I am referencing into an iLogic rule, I just declare the 'Logger' variable again within that Class.&amp;nbsp; Then you do not even need to set a value to that variable, because of how it works.&amp;nbsp; The following lines of code are an example of how to access and use those types of things, as long as your references are set up properly.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Private iLogicAuto As Autodesk.iLogic.Interfaces.IiLogicAutomation
Private Logger As Autodesk.iLogic.Interfaces.IRuleLogger&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 16:09:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/12363215#M160100</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-11-08T16:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use "AddVBFile" in Straight VB Code File?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/12363424#M160103</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Main Rule&lt;/P&gt;&lt;LI-CODE lang="general"&gt;AddReference "System.Data"
AddReference "System.Xml"
AddReference "Microsoft.Office.Interop.Excel.dll"
AddVbFile "...\mLog.vb"
AddVbFile "...\cMagnum.vb"

Class ThisRule
   '...
   Private oMagnum As cMagnum
   '...
   Sub Main

      StartLog
      oMagnum = New cMagnum(Logger, arrayRiga, transcodifica)
      '...
      '...

   End Sub
End Class&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;mLog.vb&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Imports Autodesk.iLogic.Core
Imports Autodesk.iLogic.Interfaces
Imports Autodesk.Inventor
Imports System

Public Module mLog

    Private iLogicAuto As Autodesk.iLogic.Interfaces.IiLogicAutomation
    Private Logger As Autodesk.iLogic.Interfaces.IRuleLogger
    'Public logCtrl As LogControl
    'Public Log As IRuleLogger

    Public Sub StartLog()'(startMarker As String)
		Logger.Debug("TEST MODULO")
        'Log.Debug(startMarker)
		'Log.Trace("**Class cLog - StartLog")
        'Log.Info(" Log regola lanciata alle " &amp;amp; DateTime.Now)
    End Sub

    Public Sub EndLog(startMarker As String, nomeRegola As String, Optional percorsoLogCompleto As String = "...\Log", _
                            Optional percorsoLogPuntuale As String = "...\Log", Optional fullLog As Boolean = True, _
                            Optional puntualLog As Boolean = True)
       '...
       '...
       logCtrl.SaveLogAs(tempfile)
       '...
       '...
   End Sub
End Module&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cMagnum.vb&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Imports System.IO
Imports System.Data
Imports System.Xml

Public Class cMagnum
   Dim Log As IRuleLogger
   '...
   '...

	Public Sub New(log As IRuleLogger, datiConfigurazione(,) As Object,configPath As String )
		Me.Log = log
                '...
                '...
	End Sub

    '...
    '...

	Private ReadOnly Property calcolo_LT As Integer
		Get
			value = L - 2 * AMT
			Log.Trace("Valore di LT: " &amp;amp; value)
			Return value
		End Get
	End Property

    '...
    '...

End Class&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The logger works perfectly on the class cMagnum, but not in the module mLog.&lt;/P&gt;&lt;P&gt;I get the error: "Object reference not set to an object instance."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is only an example but the main concepet is that i need to create some "module" that can be recalled inside other classes as isn't possible to call a class inside another class as far as i know, and obviously i need to use the logger inside them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope I have been as clear as possible.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 17:13:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/is-it-possible-to-use-quot-addvbfile-quot-in-straight-vb-code/m-p/12363424#M160103</guid>
      <dc:creator>Marco_PeronXTBPH</dc:creator>
      <dc:date>2023-11-08T17:13:40Z</dc:date>
    </item>
  </channel>
</rss>

