<?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 Set limit on inputvalues in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/set-limit-on-inputvalues/m-p/8604823#M14609</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm looking for a solution where I can limit the input range of values. My goal is to rule out negative numbers and numbers higher than a set limit. For example: input is valid when between 10 and 100. Let's say someone tries 1000, it's not valid and an errormessage is displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My ideas of doing this:&lt;/P&gt;
&lt;P&gt;In the&amp;nbsp;CommandValidateInputsHandler, but I can test on (e.g.) toplimit but not the lower limit at the same time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second idea: this must be done in the creation of the input as a isValidExpression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I've tried, but not seems to be working..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;# Event handler for the validateInputs event.
class SampleCommandValidateInputsHandler(adsk.core.ValidateInputsEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            app = adsk.core.Application.get()
            ui  = app.userInterface     
            
            eventArgs = adsk.core.ValidateInputsEventArgs.cast(args)
            inputs = eventArgs.firingEvent.sender.commandInputs
            
            
            # Verify .
            scaleInput = inputs.itemById('scale')
            if 10 &amp;lt; scaleInput.value &amp;lt; 100 :
                eventArgs.areInputsValid = True
            else:
                scaleInput = inputs.itemById('value')
                if 10 &amp;lt; scaleInput.value &amp;lt; 100 :
                    eventArgs.areInputsValid = True
                else:    
                    eventArgs.areInputsValid = False
                    
            
        except:
            if ui:
                ui.messageBox('Failed ValidateInputsHandler:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you point me in the right direction?&lt;/P&gt;</description>
    <pubDate>Tue, 19 Feb 2019 09:23:00 GMT</pubDate>
    <dc:creator>theartezt</dc:creator>
    <dc:date>2019-02-19T09:23:00Z</dc:date>
    <item>
      <title>Set limit on inputvalues</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/set-limit-on-inputvalues/m-p/8604823#M14609</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm looking for a solution where I can limit the input range of values. My goal is to rule out negative numbers and numbers higher than a set limit. For example: input is valid when between 10 and 100. Let's say someone tries 1000, it's not valid and an errormessage is displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My ideas of doing this:&lt;/P&gt;
&lt;P&gt;In the&amp;nbsp;CommandValidateInputsHandler, but I can test on (e.g.) toplimit but not the lower limit at the same time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second idea: this must be done in the creation of the input as a isValidExpression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I've tried, but not seems to be working..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;# Event handler for the validateInputs event.
class SampleCommandValidateInputsHandler(adsk.core.ValidateInputsEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            app = adsk.core.Application.get()
            ui  = app.userInterface     
            
            eventArgs = adsk.core.ValidateInputsEventArgs.cast(args)
            inputs = eventArgs.firingEvent.sender.commandInputs
            
            
            # Verify .
            scaleInput = inputs.itemById('scale')
            if 10 &amp;lt; scaleInput.value &amp;lt; 100 :
                eventArgs.areInputsValid = True
            else:
                scaleInput = inputs.itemById('value')
                if 10 &amp;lt; scaleInput.value &amp;lt; 100 :
                    eventArgs.areInputsValid = True
                else:    
                    eventArgs.areInputsValid = False
                    
            
        except:
            if ui:
                ui.messageBox('Failed ValidateInputsHandler:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you point me in the right direction?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 09:23:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/set-limit-on-inputvalues/m-p/8604823#M14609</guid>
      <dc:creator>theartezt</dc:creator>
      <dc:date>2019-02-19T09:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Set limit on inputvalues</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/set-limit-on-inputvalues/m-p/8607144#M14610</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Hi Mr. TheArterzt,&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;class SampleCommandChangedInputsHandler(adsk.core.InputChangedEventHandler):&lt;BR /&gt;bla, bla bla,...&lt;/PRE&gt;
&lt;PRE&gt;            if scaleInput.value &amp;lt; 10 :
                scaleInput.value = 10&lt;BR /&gt;&lt;BR /&gt;bla, bla bla&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Regards&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;MichaelT&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 00:04:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/set-limit-on-inputvalues/m-p/8607144#M14610</guid>
      <dc:creator>MichaelT_123</dc:creator>
      <dc:date>2019-02-20T00:04:38Z</dc:date>
    </item>
  </channel>
</rss>

