<?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: javascript list item add in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/javascript-list-item-add/m-p/5663697#M21192</link>
    <description>&lt;P&gt;I didn't try putting a sample together to test that everything is working as it should but I do see a problem with your code.&amp;nbsp; A ValueInput object is used when you first create a ValueInput object but after that you access the value of the input using either the expression or value properties.&amp;nbsp; Using a ValueInput lets you use either a string or a double to set the initial value of the input.&amp;nbsp; If a string is used it is evaluated using the current document units and any units within the string.&amp;nbsp; If a double is used then it is treated as database units.&amp;nbsp; For example, for lengths it will always be centimeters.&amp;nbsp; However the result in the dialog will be displayed in the current document units.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One the command input has been created you can get and set it's value using the expression property (which requires a string and is evaluated using document units) or the value property (which is a double and will be in database units).&amp;nbsp; Which one to use depends on which is the most convenient for you and typically depends on where the data comes from.&amp;nbsp; For example, if you're reading if from a file or from some user entered data then it a string is typically more convenient.&amp;nbsp; If it's a value you've calculate then a double is better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a small section of your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if(getFixture == 'D051251WM') {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoveLengthInput = initialVal10;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoveWidthInput = initialVal11;&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try changing it to this and see if it solves the problem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if(getFixture == 'D051251WM') {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoveLengthInput.value = 1.475;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoveWidthInput.value = 0.7;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also don't see in your code where you're setting DoveLengthInput and DoveWidthInput.&amp;nbsp; You can get them doing something like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DoveLengthInput = inputs.itemById('WhateverIDYouUsedWhenCreatingIt');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jun 2015 23:22:43 GMT</pubDate>
    <dc:creator>ekinsb</dc:creator>
    <dc:date>2015-06-03T23:22:43Z</dc:date>
    <item>
      <title>javascript list item add</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/javascript-list-item-add/m-p/5661615#M21189</link>
      <description>&lt;P&gt;I am new to creating scripts in Fusion, but am having an issue with creating list items for a dropdown menu.&lt;/P&gt;&lt;P&gt;I know this is a basic item, but if someone could help give me a nudge in the right direction that would be awesome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2015 18:47:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/javascript-list-item-add/m-p/5661615#M21189</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-02T18:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: javascript list item add</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/javascript-list-item-add/m-p/5661957#M21190</link>
      <description>&lt;P&gt;The add-in sample named&amp;nbsp;"AddInSample" that's delivered with Fusion demonstrates creating a command with several different types of command inputs, including two drop-downs.&amp;nbsp; You can see it in the "Scripts and Add-Ins" dialog and can run it from there.&amp;nbsp; I would suggest first looking at this sample.&amp;nbsp; If this sample doesn't demonstrate what you need please provide a more complete description of what you're trying to accomplish and I'll see if I can help.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2015 22:25:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/javascript-list-item-add/m-p/5661957#M21190</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2015-06-02T22:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: javascript list item add</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/javascript-list-item-add/m-p/5663176#M21191</link>
      <description>&lt;P&gt;hey Brian,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, that did have in it what i was wanting for the drop down list. &amp;nbsp;Now, What i am trying to do is drive values in some valueinputs when i select different items in that drop down. &amp;nbsp;I created an oninputchange function, and this is what i have in there.&lt;/P&gt;&lt;PRE&gt;var onInputChanged = function(args) {&lt;BR /&gt; try {&lt;BR /&gt; var DoveLengthInput;&lt;BR /&gt; var DoveWidthInput;&lt;BR /&gt; var BoxLengthInput;&lt;BR /&gt; var BoxWidthInput;&lt;BR /&gt; var BoxHeightInput;&lt;BR /&gt; var CylDiaInput;&lt;BR /&gt; var CylLengthInput;&lt;BR /&gt; &lt;BR /&gt; var command = adsk.core.Command(args.firingEvent.sender);&lt;BR /&gt; var inputs = command.commandInputs;&lt;BR /&gt; var materialListInput;&lt;BR /&gt; //Values for d1151s fixture&lt;BR /&gt; var initialVal10 = adsk.core.ValueInput.createByReal(1.475);&lt;BR /&gt; var initialVal11 = adsk.core.ValueInput.createByReal(0.7);&lt;BR /&gt; //Values for d1151p fixture&lt;BR /&gt; var initialVal12 = adsk.core.ValueInput.createByReal(1.475);&lt;BR /&gt; var initialVal13 = adsk.core.ValueInput.createByReal(0.994);&lt;BR /&gt; //Values for d221m fixture&lt;BR /&gt; var initialVal14 = adsk.core.ValueInput.createByReal(4.5);&lt;BR /&gt; var initialVal15 = adsk.core.ValueInput.createByReal(2);&lt;BR /&gt; //Values for d362m fixture&lt;BR /&gt; var initialVal16 = adsk.core.ValueInput.createByReal(6);&lt;BR /&gt; var initialVal17 = adsk.core.ValueInput.createByReal(3);&lt;BR /&gt; //Values for D051251WM fixture&lt;BR /&gt; var initialVal18 = adsk.core.ValueInput.createByReal(1.23);&lt;BR /&gt; var initialVal19 = adsk.core.ValueInput.createByReal(0.4);&lt;BR /&gt; for (var x = 0; x &amp;lt; inputs.count; ++x) {&lt;BR /&gt; var input = inputs.item(x);&lt;BR /&gt; if (input.id === 'fixtureselectiondrop') {&lt;BR /&gt; materialListInput = input;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; var changedInput = args.input;&lt;BR /&gt; if (changedInput.id === 'fixtureselectiondrop') {&lt;BR /&gt; var getFixture = materialListInput.selecteditem.name;&lt;BR /&gt; if(getFixture == 'D051251WM'){&lt;BR /&gt; DoveLengthInput = initialVal10;&lt;BR /&gt; DoveWidthInput = initialVal11;&lt;BR /&gt; }&lt;BR /&gt; else if (getFixture == 'D1151P'){&lt;BR /&gt; DoveLengthInput = initialVal12;&lt;BR /&gt; DoveWidthInput = initialVal13; &lt;BR /&gt; }&lt;BR /&gt; else if (getFixture == 'D221M'){&lt;BR /&gt; DoveLengthInput = initialVal14;&lt;BR /&gt; DoveWidthInput = initialVal15; &lt;BR /&gt; }&lt;BR /&gt; else if (getFixture == 'D362M'){&lt;BR /&gt; DoveLengthInput = initialVal16;&lt;BR /&gt; DoveWidthInput = initialVal17; &lt;BR /&gt; }&lt;BR /&gt; else if (getFixture == 'D051251WM'){&lt;BR /&gt; DoveLengthInput = initialVal18;&lt;BR /&gt; DoveWidthInput = initialVal19; &lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; } catch(e) {&lt;BR /&gt; ui.messageBox('input change failed: ' + errorDescription(e));&lt;BR /&gt; }&lt;BR /&gt; };&lt;/PRE&gt;&lt;P&gt;It still isn't changing the values in the input. &amp;nbsp;Is this the correct way to go about it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2015 18:01:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/javascript-list-item-add/m-p/5663176#M21191</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-03T18:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: javascript list item add</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/javascript-list-item-add/m-p/5663697#M21192</link>
      <description>&lt;P&gt;I didn't try putting a sample together to test that everything is working as it should but I do see a problem with your code.&amp;nbsp; A ValueInput object is used when you first create a ValueInput object but after that you access the value of the input using either the expression or value properties.&amp;nbsp; Using a ValueInput lets you use either a string or a double to set the initial value of the input.&amp;nbsp; If a string is used it is evaluated using the current document units and any units within the string.&amp;nbsp; If a double is used then it is treated as database units.&amp;nbsp; For example, for lengths it will always be centimeters.&amp;nbsp; However the result in the dialog will be displayed in the current document units.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One the command input has been created you can get and set it's value using the expression property (which requires a string and is evaluated using document units) or the value property (which is a double and will be in database units).&amp;nbsp; Which one to use depends on which is the most convenient for you and typically depends on where the data comes from.&amp;nbsp; For example, if you're reading if from a file or from some user entered data then it a string is typically more convenient.&amp;nbsp; If it's a value you've calculate then a double is better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a small section of your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if(getFixture == 'D051251WM') {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoveLengthInput = initialVal10;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoveWidthInput = initialVal11;&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try changing it to this and see if it solves the problem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if(getFixture == 'D051251WM') {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoveLengthInput.value = 1.475;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoveWidthInput.value = 0.7;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also don't see in your code where you're setting DoveLengthInput and DoveWidthInput.&amp;nbsp; You can get them doing something like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DoveLengthInput = inputs.itemById('WhateverIDYouUsedWhenCreatingIt');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2015 23:22:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/javascript-list-item-add/m-p/5663697#M21192</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2015-06-03T23:22:43Z</dc:date>
    </item>
  </channel>
</rss>

