<?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: Create a User parameter using VB.net in a API in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/create-a-user-parameter-using-vb-net-in-a-api/m-p/11356849#M141327</link>
    <description>&lt;P&gt;Your part document object has no document reference. It should be ThisApplication.ActiveDocument or you can use the ilogic version ThisDoc.Document if your running it in event triggers.&lt;/P&gt;&lt;P&gt;Your oParam object&amp;nbsp; is referenced to the parameters collection "Parameters" . Either rewrite it like Inventor.Parameter or [Parameter]&lt;/P&gt;</description>
    <pubDate>Sat, 13 Aug 2022 00:46:35 GMT</pubDate>
    <dc:creator>A.Acheson</dc:creator>
    <dc:date>2022-08-13T00:46:35Z</dc:date>
    <item>
      <title>Create a User parameter using VB.net in a API</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/create-a-user-parameter-using-vb-net-in-a-api/m-p/11356844#M141326</link>
      <description>&lt;P&gt;Hello Guys Im finally moving from Ilogic to VB.net and I have a problem that I cant find a sloution.&lt;/P&gt;&lt;P&gt;Im trying to use this code but keep getting the Null error. can you guys help me undertand the problem?&lt;/P&gt;&lt;LI-CODE lang="general"&gt; Public Sub SampleCommandFunction2()
        Dim oPartDoc As PartDocument = ThisApplication
        Dim userParams As UserParameters = oPartDoc.ComponentDefinition.Parameters.UserParameters
        Dim newParam As UserParameter ' Placeholder
        Dim oFormat As CustomPropertyFormat
        Dim oParam As Parameters

        'LENGTH
        Try
            oParam = oPartDoc.ComponentDefinition.Parameters("LENGTH")
        Catch   'If the parameter was not found, then create a new one.
            newParam = userParams.AddByExpression("LENGTH", 0, "mm") ' Create the Parameter as per above
            newParam.ExposedAsProperty = True 'Flag for Export
            oFormat = newParam.CustomPropertyFormat 'For some reason or other this line is needed to enable the following formatting
            oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType
            oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision 'Set one decimal place
            'oFormat.Units="mm" 'Units
            oFormat.ShowUnitsString = False
            oFormat.ShowLeadingZeros = False
            oFormat.ShowTrailingZeros = False
        End Try
End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 13 Aug 2022 00:27:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/create-a-user-parameter-using-vb-net-in-a-api/m-p/11356844#M141326</guid>
      <dc:creator>j.romo</dc:creator>
      <dc:date>2022-08-13T00:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create a User parameter using VB.net in a API</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/create-a-user-parameter-using-vb-net-in-a-api/m-p/11356849#M141327</link>
      <description>&lt;P&gt;Your part document object has no document reference. It should be ThisApplication.ActiveDocument or you can use the ilogic version ThisDoc.Document if your running it in event triggers.&lt;/P&gt;&lt;P&gt;Your oParam object&amp;nbsp; is referenced to the parameters collection "Parameters" . Either rewrite it like Inventor.Parameter or [Parameter]&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 00:46:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/create-a-user-parameter-using-vb-net-in-a-api/m-p/11356849#M141327</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2022-08-13T00:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create a User parameter using VB.net in a API</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/create-a-user-parameter-using-vb-net-in-a-api/m-p/11356855#M141328</link>
      <description>&lt;P&gt;Thank you, I have used this as a Ilogic rule and it works, but now im trying to make my first AddIn in Visual studio. and I really have a hard time passing from VBA to .Net. I have solved it by using the Inventor Application Object, you were right...&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Public Sub SampleCommandFunction2()
        Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
        Dim userParams As UserParameters = oPartDoc.ComponentDefinition.Parameters.UserParameters
        Dim newParam As UserParameter ' Placeholder
        Dim oFormat As CustomPropertyFormat
        Dim oParam As Parameters

        'LENGTH
        Try
            oParam = oPartDoc.ComponentDefinition.Parameters("LENGTH")
        Catch   'If the parameter was not found, then create a new one.
            newParam = userParams.AddByExpression("LENGTH", 0, "mm") ' Create the Parameter as per above
            newParam.ExposedAsProperty = True 'Flag for Export
            oFormat = newParam.CustomPropertyFormat 'For some reason or other this line is needed to enable the following formatting
            oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType
            oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision 'Set one decimal place
            'oFormat.Units="mm" 'Units
            oFormat.ShowUnitsString = False
            oFormat.ShowLeadingZeros = False
            oFormat.ShowTrailingZeros = False
        End Try&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 00:52:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/create-a-user-parameter-using-vb-net-in-a-api/m-p/11356855#M141328</guid>
      <dc:creator>j.romo</dc:creator>
      <dc:date>2022-08-13T00:52:23Z</dc:date>
    </item>
  </channel>
</rss>

