<?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 Reference to ModelParameter object in an expression property? in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438666#M14987</link>
    <description>&lt;P&gt;After much experimentation, searching of the forum and exploration of the API documentation, I've been unable to answer a pretty simple question: Is it possible to include a reference to a &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt; in the &lt;STRONG&gt;expression&lt;/STRONG&gt; property of a &lt;STRONG&gt;UserParameter&lt;/STRONG&gt; or another &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt;? If it is possible, I'd very much like to know how!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, if I have a &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt; whose &lt;STRONG&gt;name&lt;/STRONG&gt; property is "D23" and I'd like to add a &lt;STRONG&gt;SketchOffsetDimension&lt;/STRONG&gt; whose value is, say, 0.25 times the current &lt;STRONG&gt;value&lt;/STRONG&gt; of the "D23" &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt;, how can I do that? I'm sure I'm not the first person with this use case, but I simply can't figure out how to make it happen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd really appreciate any hints!&lt;/P&gt;</description>
    <pubDate>Sat, 01 Dec 2018 20:48:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-12-01T20:48:29Z</dc:date>
    <item>
      <title>Reference to ModelParameter object in an expression property?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438666#M14987</link>
      <description>&lt;P&gt;After much experimentation, searching of the forum and exploration of the API documentation, I've been unable to answer a pretty simple question: Is it possible to include a reference to a &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt; in the &lt;STRONG&gt;expression&lt;/STRONG&gt; property of a &lt;STRONG&gt;UserParameter&lt;/STRONG&gt; or another &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt;? If it is possible, I'd very much like to know how!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, if I have a &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt; whose &lt;STRONG&gt;name&lt;/STRONG&gt; property is "D23" and I'd like to add a &lt;STRONG&gt;SketchOffsetDimension&lt;/STRONG&gt; whose value is, say, 0.25 times the current &lt;STRONG&gt;value&lt;/STRONG&gt; of the "D23" &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt;, how can I do that? I'm sure I'm not the first person with this use case, but I simply can't figure out how to make it happen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd really appreciate any hints!&lt;/P&gt;</description>
      <pubDate>Sat, 01 Dec 2018 20:48:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438666#M14987</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-01T20:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reference to ModelParameter object in an expression property?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438820#M14988</link>
      <description>&lt;P&gt;Here's a small example that creates a diameter dimension that is based on an existing parameter named "MyValue".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;def run(context):
    try:
        app = adsk.core.Application.get()
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent

        # Create a new sketch.
        sk = root.sketches.add(root.xYConstructionPlane)
        
        # Draw a circle.
        circ = sk.sketchCurves.sketchCircles.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 5)
    
        # Add a diameter constraint.
        skDim = sk.sketchDimensions.addDiameterDimension(circ, adsk.core.Point3D.create(5,5,0), True)
        
        # Set the expression of the parameter controlling the dimension constraint.
        skDim.parameter.expression = 'MyValue / 4'
    except:
        app.userInterface.messageBox('Failed:\n{}'.format(traceback.format_exc()))
&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Dec 2018 00:24:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438820#M14988</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2018-12-02T00:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reference to ModelParameter object in an expression property?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438869#M14989</link>
      <description>&lt;P&gt;Thanks for responding and for the example code. The use case I'm struggling with is just slightly different. If I understand correctly, in example code, "MyValue" is the &lt;STRONG&gt;name&lt;/STRONG&gt; of a &lt;STRONG&gt;UserParameter&lt;/STRONG&gt; object. In the case I'm struggling with the reference has to be to a &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt; object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Extending the example a little:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;def run(context):
    try:
        app = adsk.core.Application.get()
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent

        # Create a new sketch.
        sk = root.sketches.add(root.xYConstructionPlane)

        &amp;lt;A bunch of code that creates two SketchPoint objects, pointOne and pointTwo, 
        from information elsewhere in the design.&amp;gt;

        # Make a driven dimension across the two points of interest 
        dim = sk.sketchDimensions.addDistanceDimension(
            pointOne,
            pointTwo,
            adsk.fusion.DimensionOrientations.AlignedDimensionOrientation,
            adsk.core.Point3D.create(0, 0, 0),
            False)
        
        # Draw a circle.
        circ = sk.sketchCurves.sketchCircles.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 5)
    
        # Add a diameter constraint.
        skDim = sk.sketchDimensions.addDiameterDimension(circ, adsk.core.Point3D.create(5,5,0), True)
        
        # Set the controlling the dimension constraint to be 1/4 the distance from pointOne to pointTwo.
        skDim.parameter.expression = dim.parameter.name + ' / 4'
    except:
        app.userInterface.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doesn't work because, it appears, dim is a &lt;STRONG&gt;ModelParameter&lt;/STRONG&gt;, 
not a &lt;STRONG&gt;UserParameter&lt;/STRONG&gt;. Does this make sense?&lt;/P&gt;</description>
      <pubDate>Sun, 02 Dec 2018 01:58:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438869#M14989</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-02T01:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reference to ModelParameter object in an expression property?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438877#M14990</link>
      <description>&lt;P&gt;My sample code will work with either user or model parameters.&amp;nbsp; The difference with your code is that the parameter you're trying to reference is associated with a driven dimension constraint.&amp;nbsp; Fusion 360 doesn't support creating a reference to a driven dimension.&amp;nbsp; If you look at the parameters dialog, you'll find that parameters associated with driven dimensions aren't displayed so you can't try and create any equations using them.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Dec 2018 02:33:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438877#M14990</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2018-12-02T02:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reference to ModelParameter object in an expression property?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438917#M14991</link>
      <description>&lt;P&gt;Ah, thanks so much for the clarification. Yes, I do see that if I enter the name of a ModelParameter that's not a driven dimension in the&amp;nbsp; Modify-&amp;gt;Change Parameters dialog I can create an equation involving that. But if I enter the name of the driven dimension's parameter object, the name reference stays red.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I need to figure out a different way of creating an equation that represents the distance between two &lt;STRONG&gt;SketchPoint&lt;/STRONG&gt; objects. I need an equation because, for a parametric model, the distance between the two points is an arbitrary function of parameters that the user could change. A driven dimension looked so appealing for that.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Dec 2018 03:15:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reference-to-modelparameter-object-in-an-expression-property/m-p/8438917#M14991</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-02T03:15:46Z</dc:date>
    </item>
  </channel>
</rss>

