<?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: Real vs ValueInput in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/real-vs-valueinput/m-p/9087672#M13423</link>
    <description>&lt;P&gt;The reason you see a difference in the input is because of a difference in what Fusion is creating.&amp;nbsp; In the case of creating an extrusion and defining the extrude length of the extrude, the value you enter becomes the value of a parameter.&amp;nbsp; That value can be a simple number but can also be more complex.&amp;nbsp; For example, you can enter "5", "3 + 2", "Length", "Length / 2", "Length * sin(45)" and many more.&amp;nbsp; Whatever you type in, as long as Fusion can use it to define a length, becomes the value of the newly created parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even entering a simple value like "5" isn't so simple.&amp;nbsp; When you enter a number, what are the unit?&amp;nbsp; 5 of what?&amp;nbsp; If you don't specify the units then Fusion assumes it's 5 of whatever the default units are for the document.&amp;nbsp; But even if the document is inches I can enter "5 cm" and override that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using the UI and entering values, you're essentially always entering a string, even when it's simple like "5" and then Fusion is interpreting that.&amp;nbsp; When using the API, that would be the equivalent of always using the createByString method of the ValueInput object.&amp;nbsp; However, that's not always the best when using the API because you're computing precise values using floating point numbers and would like to provide those directly rather than concoct an equivalent string.&amp;nbsp; That's why the API also supports createByReal method so you can pass in a precise number and use it directly.&amp;nbsp; In this case, it is always in centimeters.&amp;nbsp; Fusion will still create a parameter but its value will be the precise value you provided.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you sketch a circle, there isn't a parameter created and Fusion just needs the size of the circle.&amp;nbsp; Internally, Fusion uses centimeters for all lengths so that's also what the API uses.&amp;nbsp; So, specifying a floating point number for the size of a circle is defining the radius in centimeters, regardless of the document default units.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Oct 2019 15:10:14 GMT</pubDate>
    <dc:creator>BrianEkins</dc:creator>
    <dc:date>2019-10-15T15:10:14Z</dc:date>
    <item>
      <title>Real vs ValueInput</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/real-vs-valueinput/m-p/9087154#M13422</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When and why is a real used instead of a&amp;nbsp;ValueInput object?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To create a simple extrusion(&lt;A href="http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-0F875632-0DCB-4F18-9176-9617783AE794" target="_blank"&gt;http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-0F875632-0DCB-4F18-9176-9617783AE794&lt;/A&gt;), the distance is given by a&amp;nbsp;ValueInput object (&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-bdeb52e0-a6af-4909-93e8-3b13acd0e39c" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-bdeb52e0-a6af-4909-93e8-3b13acd0e39c&lt;/A&gt;) :&lt;/P&gt;&lt;PRE&gt;extrudes.addSimple(profile, adsk.core.ValueInput.createByReal(5), adsk.fusion.FeatureOperations.NewBodyFeatureOperation)        &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To add a circle(&lt;A href="http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-f52e70b8-4566-4944-9e57-be4f13f59e0e" target="_blank"&gt;http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-f52e70b8-4566-4944-9e57-be4f13f59e0e&lt;/A&gt;), the radius is given by a real:&lt;/P&gt;&lt;PRE&gt;sketchCircles.addByCenterRadius(adsk.core.Point3D.create(0, 0, 0), 5.0)&lt;/PRE&gt;&lt;P&gt;Why is that? Does one not need the benefits from the&amp;nbsp;ValueInput object here?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 11:42:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/real-vs-valueinput/m-p/9087154#M13422</guid>
      <dc:creator>hpekristiansen</dc:creator>
      <dc:date>2019-10-15T11:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Real vs ValueInput</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/real-vs-valueinput/m-p/9087672#M13423</link>
      <description>&lt;P&gt;The reason you see a difference in the input is because of a difference in what Fusion is creating.&amp;nbsp; In the case of creating an extrusion and defining the extrude length of the extrude, the value you enter becomes the value of a parameter.&amp;nbsp; That value can be a simple number but can also be more complex.&amp;nbsp; For example, you can enter "5", "3 + 2", "Length", "Length / 2", "Length * sin(45)" and many more.&amp;nbsp; Whatever you type in, as long as Fusion can use it to define a length, becomes the value of the newly created parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even entering a simple value like "5" isn't so simple.&amp;nbsp; When you enter a number, what are the unit?&amp;nbsp; 5 of what?&amp;nbsp; If you don't specify the units then Fusion assumes it's 5 of whatever the default units are for the document.&amp;nbsp; But even if the document is inches I can enter "5 cm" and override that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using the UI and entering values, you're essentially always entering a string, even when it's simple like "5" and then Fusion is interpreting that.&amp;nbsp; When using the API, that would be the equivalent of always using the createByString method of the ValueInput object.&amp;nbsp; However, that's not always the best when using the API because you're computing precise values using floating point numbers and would like to provide those directly rather than concoct an equivalent string.&amp;nbsp; That's why the API also supports createByReal method so you can pass in a precise number and use it directly.&amp;nbsp; In this case, it is always in centimeters.&amp;nbsp; Fusion will still create a parameter but its value will be the precise value you provided.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you sketch a circle, there isn't a parameter created and Fusion just needs the size of the circle.&amp;nbsp; Internally, Fusion uses centimeters for all lengths so that's also what the API uses.&amp;nbsp; So, specifying a floating point number for the size of a circle is defining the radius in centimeters, regardless of the document default units.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 15:10:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/real-vs-valueinput/m-p/9087672#M13423</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2019-10-15T15:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Real vs ValueInput</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/real-vs-valueinput/m-p/9087893#M13424</link>
      <description>&lt;P&gt;Thank you - Your summary of the API units and the benefits of a&amp;nbsp;ValueInput object is very good, but I already knew that. I did not consider, that creating an extrusion also creates a parameter - that explains a lot, but I am still confused.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I want to create a circle with a radius of 2 inches in the API, is my only option to do the conversion by hand?&lt;/P&gt;&lt;P&gt;A naive thing like this does not work, as the object is created by a string:&lt;/P&gt;&lt;PRE&gt;#not legal code&lt;BR /&gt;radius = adsk.core.ValueInput.createByString("5 in").realValue&lt;/PRE&gt;&lt;P&gt;I do not fully understand why wherever a 'ValueInput object created by a real' is expected, the function does not also accept a real real &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; . Like this:&lt;/P&gt;&lt;PRE&gt;#Legal code 
extrudes.addSimple(profile, adsk.core.ValueInput.createByReal(5), adsk.fusion.FeatureOperations.NewBodyFeatureOperation)

#Not legal code 
extrudes.addSimple(profile, 5.0, adsk.fusion.FeatureOperations.NewBodyFeatureOperation) &lt;/PRE&gt;&lt;P&gt;The function could be overloaded, and realize the real input by creating the ValueInput object itself!?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 16:49:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/real-vs-valueinput/m-p/9087893#M13424</guid>
      <dc:creator>hpekristiansen</dc:creator>
      <dc:date>2019-10-15T16:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Real vs ValueInput</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/real-vs-valueinput/m-p/9092785#M13425</link>
      <description>&lt;P&gt;It does come down to whether the value being provided will be used to create a parameter or not.&amp;nbsp; If it is, then a ValueInput is needed to support the input of either a value or a string.&amp;nbsp; Ideally, we would have used overloaded functions but unfortunately, that wasn't possible.&amp;nbsp; The API is implemented internally in C++ and then that API is wrapped to support Python.&amp;nbsp; C++ supports true overloading by letting you create functions with the same name but differ in argument types and at compile time the compiler decides which of the two functions should be called.&amp;nbsp; Python doesn't support this type of overloading so it can't be simply wrapped.&amp;nbsp; The alternative was to create a new class type that can act as either a floating-point number or a string and pass that into the single function.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 16:00:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/real-vs-valueinput/m-p/9092785#M13425</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2019-10-17T16:00:14Z</dc:date>
    </item>
  </channel>
</rss>

