<?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: adding parameters in C++ in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595452#M14643</link>
    <description>&lt;P&gt;1) some inconsistency in your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="code.PNG" style="width: 574px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/602906i076D430CF14EC870/image-size/large?v=v2&amp;amp;px=999" role="button" title="code.PNG" alt="code.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) you did not post the code for the object "fileParam" - so I used string objects/literals in my example. If you extract the correct strings from your "fileParam" object, it should work as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;Ptr&amp;lt;Product&amp;gt; product2 = app-&amp;gt;activeProduct();
	if (!product2) return false;
	Ptr&amp;lt;Design&amp;gt; design2 = product2;
	if (!design2) return false;
	Ptr&amp;lt;UserParameters&amp;gt; userParameters = design2-&amp;gt;userParameters();
	if (!userParameters) return false;

	Ptr&amp;lt;ValueInput&amp;gt; valueInput = adsk::core::ValueInput::createByString("5 mm");
	isOk = userParameters-&amp;gt;add("Test_blabla", valueInput, "mm", "comment_blabla");&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="parameter.PNG" style="width: 632px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/602908i6DDF2586913F0EEC/image-size/large?v=v2&amp;amp;px=999" role="button" title="parameter.PNG" alt="parameter.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Feb 2019 10:45:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-02-14T10:45:50Z</dc:date>
    <item>
      <title>adding parameters in C++</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595139#M14642</link>
      <description>&lt;P&gt;Is there an example somewhere for C++ in adding user parameters? I have trouble adding them to the active file. I can read them, count them and so on, but when I make changes or add another one nothing changes in the parameters tab.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so the code is something similar to this:&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Ptr&amp;lt;Product&amp;gt; product2 = app-&amp;gt;activeProduct();
if (!product) return false;
Ptr&amp;lt;Design&amp;gt; design2 = product;
if (!design) return false;
Ptr&amp;lt;UserParameters&amp;gt; userParameters = design2-&amp;gt;userParameters();
if(!userParameters) return false;

Ptr&amp;lt;ValueInput&amp;gt; valueInput = adsk::core::ValueInput::createByString(fileParam-&amp;gt;expression());
userParameters-&amp;gt;add(fileParam-&amp;gt;name(), valueInput, fileParam-&amp;gt;unit(), fileParam-&amp;gt;comment());&lt;/PRE&gt;
&lt;P class="p1"&gt;I can though edit parameters in other files with pretty much the same code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 08:18:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595139#M14642</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-14T08:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: adding parameters in C++</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595452#M14643</link>
      <description>&lt;P&gt;1) some inconsistency in your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="code.PNG" style="width: 574px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/602906i076D430CF14EC870/image-size/large?v=v2&amp;amp;px=999" role="button" title="code.PNG" alt="code.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) you did not post the code for the object "fileParam" - so I used string objects/literals in my example. If you extract the correct strings from your "fileParam" object, it should work as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;Ptr&amp;lt;Product&amp;gt; product2 = app-&amp;gt;activeProduct();
	if (!product2) return false;
	Ptr&amp;lt;Design&amp;gt; design2 = product2;
	if (!design2) return false;
	Ptr&amp;lt;UserParameters&amp;gt; userParameters = design2-&amp;gt;userParameters();
	if (!userParameters) return false;

	Ptr&amp;lt;ValueInput&amp;gt; valueInput = adsk::core::ValueInput::createByString("5 mm");
	isOk = userParameters-&amp;gt;add("Test_blabla", valueInput, "mm", "comment_blabla");&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="parameter.PNG" style="width: 632px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/602908i6DDF2586913F0EEC/image-size/large?v=v2&amp;amp;px=999" role="button" title="parameter.PNG" alt="parameter.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 10:45:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595452#M14643</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-14T10:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: adding parameters in C++</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595490#M14644</link>
      <description>&lt;P&gt;Still no luck. It doesn't really do anything.&lt;BR /&gt;The product2 was a typo since the code was a quick rewrite. I tried your code and added a messagebox to it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Ptr&amp;lt;Product&amp;gt; product2 = app-&amp;gt;activeProduct();
if (!product2) return false;
Ptr&amp;lt;Design&amp;gt; design2 = product2;
 if (!design2) return false;
Ptr&amp;lt;UserParameters&amp;gt; userParameters = design2-&amp;gt;userParameters();
if (!userParameters) return false;
                                    
Ptr&amp;lt;ValueInput&amp;gt; valueInput = adsk::core::ValueInput::createByString("5 mm");
Ptr&amp;lt;UserParameter&amp;gt; test = userParameters-&amp;gt;add("Test_blabla", valueInput, "mm", "comment_blabla");
if(!test) ui-&amp;gt;messageBox("this is not working");&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Skärmavbild 2019-02-14 kl. 12.37.03.png" style="width: 195px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/602912i1793CF438A4F9B02/image-dimensions/195x133?v=v2" width="195" height="133" role="button" title="Skärmavbild 2019-02-14 kl. 12.37.03.png" alt="Skärmavbild 2019-02-14 kl. 12.37.03.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Skärmavbild 2019-02-14 kl. 12.47.44.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/602916i3EDE8512EF26A694/image-size/large?v=v2&amp;amp;px=999" role="button" title="Skärmavbild 2019-02-14 kl. 12.47.44.png" alt="Skärmavbild 2019-02-14 kl. 12.47.44.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Could it have something to do with the fact that I have another file opened in silent mode at the same time?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 10:50:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595490#M14644</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-14T10:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: adding parameters in C++</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595518#M14645</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;Could it have something to do with the fact that I have another file opened in silent mode at the same time?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;?? -&amp;gt; &lt;A href="https://forums.autodesk.com/t5/fusion-360-api-and-scripts/opening-files-on-a-new-thread/td-p/8589537" target="_blank" rel="noopener"&gt;Opening files on a new thread&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 11:00:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595518#M14645</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-14T11:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: adding parameters in C++</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595521#M14646</link>
      <description>&lt;P&gt;Ok, I found the problem. I am executing the command with a button in Add-In menu and it seems to only work when executing it from the&amp;nbsp;CommandExecutedHandler.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone have an idea if I can get execute it in the InputChangedHandler?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 11:02:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595521#M14646</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-14T11:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: adding parameters in C++</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595530#M14647</link>
      <description>&lt;P&gt;I had to do this in the same thread and it's unfortunately really slow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wrote a sharedParameters add-in and would like functionality to import parameters to the current file. Right now it is sending sending/updating the parameters in the other tagged project files.&amp;nbsp; Then I'll probably also add file exporting possibility(parameterIO) just to have everything in one place.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 11:07:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8595530#M14647</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-14T11:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: adding parameters in C++</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8596706#M14648</link>
      <description>&lt;P&gt;Changes to the model should be done in either the executePreview or execute events.&amp;nbsp; However, anything done in the executePreview will automatically be aborted the next time executePreview is called and if it's a permanent change you're making you'll need to continually keep making the change until the command is finally executed.&amp;nbsp; If you set the isValidResult&amp;nbsp;property of the CommandEventArgs object passed into the executePreview to True, then execute event will be skipped and you'll keep whatever was created in the last executePreview event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm surprised your program is slow.&amp;nbsp; I wouldn't expect creating parameters to be an expensive operation.&amp;nbsp; Maybe there's something else in your workflow that's contributing the time?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 18:20:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8596706#M14648</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2019-02-14T18:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: adding parameters in C++</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8597963#M14649</link>
      <description>&lt;P&gt;Thanks for the info. Sounds like I should read through the documentation again, I haven't touched fusion360 API in while and my memory isn't the greatest &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;The slowness unfortunately comes from accessing/saving files in the cloud. If you have any idea in how to modify/access file parameters faster i'm all ears &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 07:59:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adding-parameters-in-c/m-p/8597963#M14649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-15T07:59:02Z</dc:date>
    </item>
  </channel>
</rss>

