<?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: Shared Function in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12487722#M14907</link>
    <description>&lt;P&gt;Guys, thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have experience writing in vb.net and I was indeed hoping for an "easy solution", which I didn't found anywhere online.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/837416" target="_self"&gt;&lt;SPAN class=""&gt;cidhelp's&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&amp;nbsp;solution looks something I can use, finger crossed! &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/837416"&gt;@cidhelp&lt;/a&gt;&amp;nbsp;: can I class my function like it is or do I need to modify it in some way?&lt;/DIV&gt;</description>
    <pubDate>Wed, 10 Jan 2024 07:53:02 GMT</pubDate>
    <dc:creator>gabriele.tittonel</dc:creator>
    <dc:date>2024-01-10T07:53:02Z</dc:date>
    <item>
      <title>Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12485539#M14902</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have few functions that are used in several external rules. At the moment, I've copied the function code on each rule, therefore I have the structure:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main()
...
End Sub

Function MyFunc()
...
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to store these functions in one file and use them without having the code on the rule itself?&lt;BR /&gt;&lt;BR /&gt;Here an example of a function that I use in different rules:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Function ParameterCreate(Name As String, Optional Value As Object = "", Optional Unit As String = "ul")

'	This rule works on every kind of Inventor files: Part, Assembly and Drawing
'	If a parameter doens't exist, then it will be created.
'	If a parameter exists, then it won't be changed.
'
'	How to use:
'
'		ParameterCreate("txtPara", "Hello World!")
'		ParameterCreate("mmPara", 45, "mm")
'		ParameterCreate("booPara", True)
'		ParameterCreate("emptyPara")
'		ParameterCreate("ulPara", 15)

	Try 	' Check if parameter exists.
		
		Parameter(Name) = Parameter(Name)
		
	Catch 	' Parameter not found, so create it.
		
		If TypeName(Value) = "Boolean" 	Then Unit = "BOOLEAN"
		If TypeName(Value) = "String" 	Then Unit = "TEXT" 
			
		Dim oDoc As Document = ThisApplication.ActiveDocument
'		Dim oDoc As Document = ThisDoc.Document
		Dim oParam As UserParameters
		
		If oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
			oParam = oDoc.Parameters.UserParameters							' Drawing.
		Else
			oParam = oDoc.ComponentDefinition.Parameters.UserParameters		' Part/Assembly.
		End If

		Select Case Unit 
			Case "BOOLEAN", "TEXT" 	: oParam.AddByValue(Name, Value, Unit)
			Case Else 				: oParam.AddByExpression(Name, Value, Unit)
		End Select
		
	End Try

End Function&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 10:58:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12485539#M14902</guid>
      <dc:creator>gabriele.tittonel</dc:creator>
      <dc:date>2024-01-09T10:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12485806#M14903</link>
      <description>&lt;P&gt;The best method for this would be to create an external exe using something like visual studio or visual studio code.&lt;/P&gt;&lt;P&gt;the syntax is basically the same once you get the inventor App object, which can be difficult if you dont use the right framework.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;    Private Sub _TryAndOpenInventor()
        Try
            _App = Marshal.GetActiveObject(InventorAppName)
            NotifyDriverReport("Inventor Already Open")
        Catch
            Try
                Dim pInventorAppType = Type.GetTypeFromProgID(InventorAppName)
                _App = Activator.CreateInstance(pInventorAppType)
                NotifyDriverReport("Inventor opened new")
                _InventorWasOpenedFresh = True
            Catch
            End Try
        End Try

        If _App Is Nothing Then
            NotifyDriverReport("Open Inventor Failed")
            RaiseEvent OpenAppFailed()
        Else
            RaiseEvent OpenAppSuceeded()
            NotifyDriverReport("Open Inventor Succeeded")
        End If
    End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 Jan 2024 13:25:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12485806#M14903</guid>
      <dc:creator>davidt162003</dc:creator>
      <dc:date>2024-01-09T13:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12485857#M14904</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10811152"&gt;@gabriele.tittonel&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not aware of any easy way out. I've faced the same issue few years ago.&lt;/P&gt;&lt;P&gt;My point of view is that it is a bad idea to copy/paste 50 times since it takes 1 sec to do so, but you might have to update the same function 50 times in 50 different rules.. Thus praying you don't forget one...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would recommand using a custom add-in instead. You could then create function classes that you could reach from anywhere.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some interesting links :&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.autodesk.com/support/technical/article/caas/tsarticles/ts/29mPk2V7aweIo6eLckSF1k.html" target="_blank" rel="noopener"&gt;My First Inventor Plug-in Overview (autodesk.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-52422162-1784-4E8F-B495-CDB7BE9987AB" target="_blank" rel="noopener"&gt;Inventor 2022 Help | Creating an Add-In | Autodesk&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;FINET L.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 13:47:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12485857#M14904</guid>
      <dc:creator>FINET_Laurent</dc:creator>
      <dc:date>2024-01-09T13:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12486021#M14905</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10811152"&gt;@gabriele.tittonel&lt;/a&gt;.&amp;nbsp; Have you read through this online help page yet.&amp;nbsp; It mentions ways to reference other iLogic rules as a source for using the code resources in them to add to the functionality of your current iLogic rule.&amp;nbsp; If you do not have a history of programming using vb.net though, it can be complicated to adapt to writing the code necessary for those special types of external rules that you can reference that way though, because they need to be laid out differently, and much more strictly than your other normal external iLogic rules.&amp;nbsp; The iLogic add-in and its rule editor dialog do a lot more for you behind the scenes, to help make things simpler than most folks realize, which can actually be awkward for those who do have a history of writing code in vb.net.&amp;nbsp; Those external rule that you intent to use that way, must have their 'Straight VB Code' option turned on, which changes a lot of things.&amp;nbsp; Then they must specify the Class (or similar block), before you can add a Sub Main or other Methods or Properties inside that Class, which you normally do not need to do in iLogic.&amp;nbsp; You will also loose a lot of the externally referenced sources that would normally be included automatically in the background of other iLogic rules, so you will likely need to include several lines of code within the 'Header' them which use 'AddReference' and 'Imports' statements.&amp;nbsp; It can be a lot to learn and may take a lot of trial &amp;amp; error testing, if you are not experienced with how vb.net coding outside of Visual Studio works.&amp;nbsp; Even though I have Visual Studio Community 2019 installed, I rarely ever really need to use if for anything.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-32B66838-22E4-4A0A-B5BB-862350C76B36" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-32B66838-22E4-4A0A-B5BB-862350C76B36&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 14:29:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12486021#M14905</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-01-09T14:29:25Z</dc:date>
    </item>
    <item>
      <title>Betreff: Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12486137#M14906</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10811152"&gt;@gabriele.tittonel&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can share functions with iLogic.&lt;/P&gt;&lt;P&gt;First you have to create an external rule with the option "Straight VB-Code" on. In this rule, create a class and your functions. Keep in mind, that staight VB-Code needs arguments for the Inventor Application or Document-objects.&lt;/P&gt;&lt;P&gt;See my sample iLogicVB-File (stored as MyVBFunctions.iLogicVB in an external rule directory):&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Class&lt;/SPAN&gt; &lt;SPAN&gt;MyVBFunctions&lt;/SPAN&gt;

	&lt;SPAN&gt;Public&lt;/SPAN&gt; &lt;SPAN&gt;Function&lt;/SPAN&gt; &lt;SPAN&gt;GetUserName&lt;/SPAN&gt;(&lt;SPAN&gt;oApp&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Application&lt;/SPAN&gt;) &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;
		&lt;SPAN&gt;Return&lt;/SPAN&gt; &lt;SPAN&gt;oApp&lt;/SPAN&gt;.&lt;SPAN&gt;UserName&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Function&lt;/SPAN&gt;
	
	&lt;SPAN&gt;Public&lt;/SPAN&gt; &lt;SPAN&gt;Function&lt;/SPAN&gt; &lt;SPAN&gt;WriteUserProperty&lt;/SPAN&gt;(&lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;, &lt;SPAN&gt;PropName&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;, &lt;SPAN&gt;PropVal&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;) &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Property&lt;/SPAN&gt;
		&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oProp&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Property&lt;/SPAN&gt;
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;UserPropExist&lt;/SPAN&gt;(&lt;SPAN&gt;oDoc&lt;/SPAN&gt;, &lt;SPAN&gt;PropName&lt;/SPAN&gt;) &lt;SPAN&gt;Then&lt;/SPAN&gt;
			&lt;SPAN&gt;oProp&lt;/SPAN&gt; = &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;PropertySets&lt;/SPAN&gt;(&lt;SPAN&gt;"Inventor User Defined Properties"&lt;/SPAN&gt;).&lt;SPAN&gt;Item&lt;/SPAN&gt;(&lt;SPAN&gt;PropName&lt;/SPAN&gt;)
			&lt;SPAN&gt;oProp&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt; = &lt;SPAN&gt;PropVal&lt;/SPAN&gt;
		&lt;SPAN&gt;Else&lt;/SPAN&gt;
			&lt;SPAN&gt;oProp&lt;/SPAN&gt; = &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;PropertySets&lt;/SPAN&gt;(&lt;SPAN&gt;"Inventor User Defined Properties"&lt;/SPAN&gt;).&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;PropVal&lt;/SPAN&gt;,&lt;SPAN&gt;PropName&lt;/SPAN&gt;)
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
		&lt;SPAN&gt;Return&lt;/SPAN&gt; &lt;SPAN&gt;oProp&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Function&lt;/SPAN&gt;
	
	&lt;SPAN&gt;Private&lt;/SPAN&gt; &lt;SPAN&gt;Function&lt;/SPAN&gt; &lt;SPAN&gt;UserPropExist&lt;/SPAN&gt;(&lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;, &lt;SPAN&gt;PropName&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;) &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Boolean&lt;/SPAN&gt;
		&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oProp&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Property&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;PropertySets&lt;/SPAN&gt;(&lt;SPAN&gt;"Inventor User Defined Properties"&lt;/SPAN&gt;)
			&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oProp&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt;.&lt;SPAN&gt;ToUpper&lt;/SPAN&gt; = &lt;SPAN&gt;PropName&lt;/SPAN&gt;.&lt;SPAN&gt;ToUpper&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
				&lt;SPAN&gt;Return&lt;/SPAN&gt; &lt;SPAN&gt;True&lt;/SPAN&gt;
			&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
		&lt;SPAN&gt;Next&lt;/SPAN&gt;
		&lt;SPAN&gt;Return&lt;/SPAN&gt; &lt;SPAN&gt;False&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Function&lt;/SPAN&gt;

&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Class&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;To use these functions, create rules and add the iLogicVB file at the header using AddVBFile. Now you can create an object of the class and use the public functions.&lt;/P&gt;&lt;P&gt;See my sample rule header:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;AddVbFile&lt;/SPAN&gt; &lt;SPAN&gt;"MyVBFunctions.iLogicVb"&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;and the rule:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;MyFunc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;New&lt;/SPAN&gt; &lt;SPAN&gt;MyVBFunctions&lt;/SPAN&gt;
&lt;SPAN&gt;sUser&lt;/SPAN&gt; = &lt;SPAN&gt;MyFunc&lt;/SPAN&gt;.&lt;SPAN&gt;GetUserName&lt;/SPAN&gt;(&lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;)
&lt;SPAN&gt;oProp&lt;/SPAN&gt; = &lt;SPAN&gt;MyFunc&lt;/SPAN&gt;.&lt;SPAN&gt;WriteUserProperty&lt;/SPAN&gt;(&lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;, &lt;SPAN&gt;"Inv_UserName"&lt;/SPAN&gt;, &lt;SPAN&gt;sUser&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 15:08:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12486137#M14906</guid>
      <dc:creator>cidhelp</dc:creator>
      <dc:date>2024-01-09T15:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12487722#M14907</link>
      <description>&lt;P&gt;Guys, thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have experience writing in vb.net and I was indeed hoping for an "easy solution", which I didn't found anywhere online.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/837416" target="_self"&gt;&lt;SPAN class=""&gt;cidhelp's&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&amp;nbsp;solution looks something I can use, finger crossed! &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/837416"&gt;@cidhelp&lt;/a&gt;&amp;nbsp;: can I class my function like it is or do I need to modify it in some way?&lt;/DIV&gt;</description>
      <pubDate>Wed, 10 Jan 2024 07:53:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12487722#M14907</guid>
      <dc:creator>gabriele.tittonel</dc:creator>
      <dc:date>2024-01-10T07:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12487989#M14908</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10811152"&gt;@gabriele.tittonel&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;some modifications are necessary. The rule including the function can look like this (see oDoc as first parameter):&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Class&lt;/SPAN&gt; &lt;SPAN&gt;MyVBFunctions&lt;/SPAN&gt;

	&lt;SPAN&gt;Public&lt;/SPAN&gt; &lt;SPAN&gt;Function&lt;/SPAN&gt; &lt;SPAN&gt;CreateParameter&lt;/SPAN&gt;(&lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;, &lt;SPAN&gt;ParameterName&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;, &lt;SPAN&gt;Optional&lt;/SPAN&gt; &lt;SPAN&gt;Value&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Object&lt;/SPAN&gt; = &lt;SPAN&gt;""&lt;/SPAN&gt;, &lt;SPAN&gt;Optional&lt;/SPAN&gt; &lt;SPAN&gt;Unit&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;"ul"&lt;/SPAN&gt;) &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Parameter&lt;/SPAN&gt;
		&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oParams&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;UserParameters&lt;/SPAN&gt;
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;DocumentType&lt;/SPAN&gt; = &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;DocumentTypeEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kDrawingDocumentObject&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
			&lt;SPAN&gt;oParams&lt;/SPAN&gt; = &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Parameters&lt;/SPAN&gt;.&lt;SPAN&gt;UserParameters&lt;/SPAN&gt;
		&lt;SPAN&gt;Else&lt;/SPAN&gt;
			&lt;SPAN&gt;oParams&lt;/SPAN&gt; = &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;.&lt;SPAN&gt;Parameters&lt;/SPAN&gt;.&lt;SPAN&gt;UserParameters&lt;/SPAN&gt;
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
		&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oParam&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Parameter&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oParams&lt;/SPAN&gt;
			&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oParam&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; = &lt;SPAN&gt;ParameterName&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt; &lt;SPAN&gt;Return&lt;/SPAN&gt; &lt;SPAN&gt;Nothing&lt;/SPAN&gt;
		&lt;SPAN&gt;Next&lt;/SPAN&gt;

		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;TypeName&lt;/SPAN&gt;(&lt;SPAN&gt;Value&lt;/SPAN&gt;) = &lt;SPAN&gt;"Boolean"&lt;/SPAN&gt; 	&lt;SPAN&gt;Then&lt;/SPAN&gt; &lt;SPAN&gt;Unit&lt;/SPAN&gt; = &lt;SPAN&gt;"BOOLEAN"&lt;/SPAN&gt;
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;TypeName&lt;/SPAN&gt;(&lt;SPAN&gt;Value&lt;/SPAN&gt;) = &lt;SPAN&gt;"String"&lt;/SPAN&gt; 	&lt;SPAN&gt;Then&lt;/SPAN&gt; &lt;SPAN&gt;Unit&lt;/SPAN&gt; = &lt;SPAN&gt;"TEXT"&lt;/SPAN&gt; 
		
		&lt;SPAN&gt;Select&lt;/SPAN&gt; &lt;SPAN&gt;Case&lt;/SPAN&gt; &lt;SPAN&gt;Unit&lt;/SPAN&gt; 
			&lt;SPAN&gt;Case&lt;/SPAN&gt; &lt;SPAN&gt;"BOOLEAN"&lt;/SPAN&gt;, &lt;SPAN&gt;"TEXT"&lt;/SPAN&gt; 	: &lt;SPAN&gt;Return&lt;/SPAN&gt; &lt;SPAN&gt;oParams&lt;/SPAN&gt;.&lt;SPAN&gt;AddByValue&lt;/SPAN&gt;(&lt;SPAN&gt;ParameterName&lt;/SPAN&gt;, &lt;SPAN&gt;Value&lt;/SPAN&gt;, &lt;SPAN&gt;Unit&lt;/SPAN&gt;)
			&lt;SPAN&gt;Case&lt;/SPAN&gt; &lt;SPAN&gt;Else&lt;/SPAN&gt; 				: &lt;SPAN&gt;Return&lt;/SPAN&gt; &lt;SPAN&gt;oParams&lt;/SPAN&gt;.&lt;SPAN&gt;AddByExpression&lt;/SPAN&gt;(&lt;SPAN&gt;ParameterName&lt;/SPAN&gt;, &lt;SPAN&gt;Value&lt;/SPAN&gt;, &lt;SPAN&gt;Unit&lt;/SPAN&gt;)
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Select&lt;/SPAN&gt;

	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Function&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Class&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;The rule using the function can look like this:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;AddVbFile&lt;/SPAN&gt; &lt;SPAN&gt;"MyVBFunctions.iLogicVb"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;MyFunc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;New&lt;/SPAN&gt; &lt;SPAN&gt;MyVBFunctions&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oParam1&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Parameter&lt;/SPAN&gt;
&lt;SPAN&gt;oParam1&lt;/SPAN&gt; = &lt;SPAN&gt;MyFunc&lt;/SPAN&gt;.&lt;SPAN&gt;CreateParameter&lt;/SPAN&gt;(&lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;, &lt;SPAN&gt;"TestParam"&lt;/SPAN&gt;, 10, &lt;SPAN&gt;"mm"&lt;/SPAN&gt;)
&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oParam1&lt;/SPAN&gt; &lt;SPAN&gt;is&lt;/SPAN&gt; &lt;SPAN&gt;Nothing&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
	&lt;SPAN&gt;Logger&lt;/SPAN&gt;.&lt;SPAN&gt;Info&lt;/SPAN&gt;(&lt;SPAN&gt;"TestParam always exists"&lt;/SPAN&gt;)
&lt;SPAN&gt;Else&lt;/SPAN&gt;
	&lt;SPAN&gt;Logger&lt;/SPAN&gt;.&lt;SPAN&gt;Info&lt;/SPAN&gt;(&lt;SPAN&gt;"TestParam created"&lt;/SPAN&gt;)
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 10:33:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12487989#M14908</guid>
      <dc:creator>cidhelp</dc:creator>
      <dc:date>2024-01-10T10:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12505798#M14909</link>
      <description>It works, thanks!&lt;BR /&gt;&lt;BR /&gt;I guess we need to specify the "oDoc" otherwise the function doesn't know on which document the parameter must be created, correct?&lt;BR /&gt;&lt;BR /&gt;Is it something I should put on every public function?</description>
      <pubDate>Thu, 18 Jan 2024 13:43:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12505798#M14909</guid>
      <dc:creator>gabriele.tittonel</dc:creator>
      <dc:date>2024-01-18T13:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12719635#M14910</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Back again on this topic: I was trying to create a shared function that contains the "GoExcel" function, but it doesn't work...&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":frowning_face:"&gt;☹️&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the error: &lt;STRONG&gt;'GoExcel' is not declared. It may be inaccessible due its protection level.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I solve it?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 09:43:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12719635#M14910</guid>
      <dc:creator>gabriele.tittonel</dc:creator>
      <dc:date>2024-04-19T09:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12719992#M14911</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10811152"&gt;@gabriele.tittonel&lt;/a&gt;.&amp;nbsp; The 'GoExcel' term is known as an iLogic 'Rule Object', and is mentioned at this following online help web page:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=4ccb78b0-c35c-4d38-943a-854117da6ced" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=4ccb78b0-c35c-4d38-943a-854117da6ced&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 'GoExcel' term represents an instance of the&amp;nbsp;IGoExcel Interface (Link in next line).&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=af87c7b4-cf59-8cce-c207-cbd8a3b6632e" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=af87c7b4-cf59-8cce-c207-cbd8a3b6632e&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Those are similar to local variables which have already been declared, had their Type set, and had their Value set, behind the scenes in every iLogic rule, when we are using the iLogic Rule Editor dialog.&amp;nbsp; Those terms will not be recognized outside of normal/simple iLogic rules, so, if you want to use those iLogic tools elsewhere (such as within a custom Class block of code), then you must 'pass' that reference into your Class, one way or another.&amp;nbsp; You can have a Public Property for that term within your Class block of code, then set its value from the iLogic rule that creates an instance of that Class, by setting it as the value of that Public Property of that Class.&amp;nbsp; Or, you can include asking for this reference in one of the 'Methods' of the Class, then pass it in that way, and set it at the value of a Private internal variable of the Class.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 12:29:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/shared-function/m-p/12719992#M14911</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-04-19T12:29:42Z</dc:date>
    </item>
  </channel>
</rss>

