Use parameters to set limits on iLogic form slider control

Use parameters to set limits on iLogic form slider control

pcrawley
Advisor Advisor
1,273 Views
8 Replies
Message 1 of 9

Use parameters to set limits on iLogic form slider control

pcrawley
Advisor
Advisor

Is it possible to set a slider's max/min/step values from other parameters?

 

I think the answer is "no" based on a few other similar queries, but I haven't found a definitive answer. 

 

According to the message, it might be addressable - but how...? 

ramStroke.jpg

 

Peter
0 Likes
Accepted solutions (1)
1,274 Views
8 Replies
Replies (8)
Message 2 of 9

Michael.Navara
Advisor
Advisor
Accepted solution

Simple answer is expected NO it isn't possible.

 

I recommend you to use WinForms dialog created by VisualStudio. It is much safer then solution described below.

 

 

But there is one hack, which enables to do it. Because iLogic form definition is stored as XML file in ...\Design Data\iLogic\UI you can modify its definition before form is shown. This is possible for global form. For local form is it much bigger hell, because the form definition is stored in file and you need to modify the inventor file each time you show the form.

 

My example expects:

  • Form "MyForm" is defined and contains slider control for parameter "MyValue"
  • Parameters "MinValue" and "MaxValue" exist.
  • Form must be shown by rule, not directly by click.

 

MyForm definition. Copy and save this as ...\Design Data\iLogic\UI\MyForm.xml

 

<?xml version="1.0" encoding="utf-8"?>
<FormSpecification xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>MyForm</Name>
  <Guid>988b033d-ad92-49b7-8ecf-fb81e11da583</Guid>
  <Items>
    <UiElementSpec xsi:type="NumericParameterControlSpec">
      <Name>MyValue</Name>
      <Guid>aad6aeef-574c-4636-b56e-5a91eb25db79</Guid>
      <ToolTip />
      <ParameterName>MyValue</ParameterName>
      <EditControlType>TrackBar</EditControlType>
      <TrackBarProperties>
        <MinimumValue>5</MinimumValue>
        <MaximumValue>20</MaximumValue>
        <ValueIncrement>1</ValueIncrement>
      </TrackBarProperties>
    </UiElementSpec>
  </Items>
  <StyleAndSkinName>
    <StyleName>Default</StyleName>
  </StyleAndSkinName>
  <AllowCustomization>true</AllowCustomization>
  <PredefinedButtons>Done</PredefinedButtons>
  <Modal>false</Modal>
</FormSpecification>

 

  

The rule for display form

 

Addreference "System.XML"

Sub Main()
    'Settings
    Dim formName As String = "MyForm"
    Dim valueParamName As String = "MyValue"
    Dim valueMinParamName As String = "MinValue"
    Dim valueMaxParamName As String = "MaxValue"

    'Form definition for Inventor 2020 in default location
    Dim formDefinitionFileName As String = "C:\Users\Public\Documents\Autodesk\Inventor 2020\Design Data\iLogic\UI\" & formName & ".xml"

    'xPaths for minimum and maximum values
    Dim xPathMinValue = "//Items//UiElementSpec[Name='" & valueParamName & "']/TrackBarProperties/MinimumValue"
    Dim xPathMaxValue = "//Items//UiElementSpec[Name='" & valueParamName & "']/TrackBarProperties/MaximumValue"

    'Min and Max value from actual parameter values
    Dim minValue As Double = Parameter.Value(valueMinParamName)
    Dim maxValue As Double = Parameter.Value(valueMaxParamName)

    'From definition loading
    Dim formDef = New System.Xml.XmlDocument
    formDef.Load(formDefinitionFileName)

    'Min and Max values modification
    formDef.DocumentElement.SelectSingleNode(xPathMinValue).InnerText = minValue
    formDef.DocumentElement.SelectSingleNode(xPathMaxValue).InnerText = maxValue

    'Save changes
    formDef.Save(formDefinitionFileName)

    'Show form
    iLogicForm.ShowGlobal(formName, FormMode.Modal)
End Sub

 

 

Message 3 of 9

pcrawley
Advisor
Advisor

Wow - thank you @Michael.Navara 

That was somewhat more comprehensive than the "no" I was expecting!

Peter
0 Likes
Message 4 of 9

johanCGD56
Explorer
Explorer

Can it be that in 2024 the 'slider' control type has disappeared? 

0 Likes
Message 5 of 9

Michael.Navara
Advisor
Advisor

No, you have selected multi-value parameter and there is not possible to have slider.
Select standard numeric parameter and then you can choose slider for Edit control type

0 Likes
Message 6 of 9

johanCGD56
Explorer
Explorer

ooh, thanks, so old explanations are obsolete. Far easier like this! Thanks a lot and also so quickly
So to use a slider in a form for a parameter, you MAY NOT set it to multi-value. One has to set the values in the forms slider properties with min and max. Great!

0 Likes
Message 7 of 9

RJ202020
Explorer
Explorer

Hi @Michael.Navara 

Thanks for the code. I created a form as in attachment with all the Iproperties, I've managed to consolidate all the Iprop in the global form. Now, my aim is to customize your code so that whenever I modify the description or revision number or any Iproperties and click on the update Iprop button, the Iproperties of the file get updated accordingly. I am new to coding, unfortunately, my attempts to modify your code haven't been successful so far.

Please check and let me know what I am missing?

 

iLogic code (Update Iprop)

 

Addreference "System.XML"
Sub Main()
    'Settings
    Dim formName As String = "iLogicBrowserUiFormSpecification"
    Dim valuePropName As String = "Description"
    Dim valueUpPropName As String = "UpdatedDescription"

    'Form definition for Inventor 2023 in default location
    Dim formDefinitionFileName As String = "C:\Users\Public\Documents\Autodesk\Inventor 2023\Design Data\iLogic\UI\" & formName & ".xml"

    'Path for Existing Values 'Values from actual parameter
    Dim xValue = "//Items//UiElementSpec[Name='" & valuePropName & "']/PropertyName"
	
	Dim UpdatedDescription As Double = Parameter.Value(valueUpPropName)

    'Form definition loading
    Dim formDef As New System.Xml.XmlDocument
    formDef.Load(formDefinitionFileName)
	
	'Dim newValue As String = xValue

    'Values modification
    formDef.DocumentElement.SelectSingleNode(xValue).InnerText = valueUpPropName

    'Save changes
    formDef.Save(formDefinitionFileName)

    'Show form
    'iLogicForm.ShowGlobal(formName, FormMode.Modal)
End Sub

 

XML Code:

 

<?xml version="1.0" encoding="utf-8"?>
<FormSpecification xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>iLogicBrowserUiFormSpecification</Name>
  <Guid>063b386d-1246-4525-86fc-7884fd2d8a79</Guid>
  <Items>
    <UiElementSpec xsi:type="ControlGroupSpec">
      <Name>Iprop</Name>
      <Guid>f1cc172e-63d8-48cf-9003-f889f3c3419d</Guid>
      <Font>
        <FamilyName>Tahoma</FamilyName>
        <Size>10.2</Size>
        <Bold>false</Bold>
        <Italic>false</Italic>
      </Font>
      <ContentsFont>
        <FamilyName>Tahoma</FamilyName>
        <Size>10.2</Size>
        <Bold>false</Bold>
        <Italic>false</Italic>
      </ContentsFont>
      <Items>
        <UiElementSpec xsi:type="TextPropertyControlSpec">
          <Name>Part Number</Name>
          <Guid>1663e854-6f0c-44b7-9e59-14b42e62d88d</Guid>
          <Font>
            <FamilyName>Tahoma</FamilyName>
            <Size>10.2</Size>
            <Bold>false</Bold>
            <Italic>false</Italic>
          </Font>
          <PropertyName>Part Number</PropertyName>
          <PropertySetName>Project</PropertySetName>
        </UiElementSpec>
        <UiElementSpec xsi:type="TextPropertyControlSpec">
          <Name>Stock Number</Name>
          <Guid>d02d0b2e-6cf1-4581-a389-bbe694e9230f</Guid>
          <Font>
            <FamilyName>Tahoma</FamilyName>
            <Size>10.2</Size>
            <Bold>false</Bold>
            <Italic>false</Italic>
          </Font>
          <PropertyName>Stock Number</PropertyName>
          <PropertySetName>Project</PropertySetName>
        </UiElementSpec>
        <UiElementSpec xsi:type="TextPropertyControlSpec">
          <Name>Description</Name>
          <Guid>baa6f2f6-4e36-452c-abbc-69d7d97f413d</Guid>
          <Font>
            <FamilyName>Tahoma</FamilyName>
            <Size>10.2</Size>
            <Bold>false</Bold>
            <Italic>false</Italic>
          </Font>
          <PropertyName>Description</PropertyName>
          <PropertySetName>Project</PropertySetName>
        </UiElementSpec>
        <UiElementSpec xsi:type="TextPropertyControlSpec">
          <Name>Revision Number</Name>
          <Guid>5e61b19a-1ee8-4a07-ba4d-9d1eac7fb673</Guid>
          <Font>
            <FamilyName>Tahoma</FamilyName>
            <Size>10.2</Size>
            <Bold>false</Bold>
            <Italic>false</Italic>
          </Font>
          <PropertyName>Revision Number</PropertyName>
          <PropertySetName>Project</PropertySetName>
        </UiElementSpec>
        <UiElementSpec xsi:type="TextPropertyControlSpec">
          <Name>Designer</Name>
          <Guid>ccc339eb-2cce-4e8b-a8c5-638ace3d38f8</Guid>
          <Font>
            <FamilyName>Tahoma</FamilyName>
            <Size>10.2</Size>
            <Bold>false</Bold>
            <Italic>false</Italic>
          </Font>
          <PropertyName>Designer</PropertyName>
          <PropertySetName>Project</PropertySetName>
        </UiElementSpec>
        <UiElementSpec xsi:type="DatePropertyControlSpec">
          <Name>Creation Date</Name>
          <Guid>91fd9a8b-82fa-43af-9df1-0ec3877558c3</Guid>
          <Font>
            <FamilyName>Tahoma</FamilyName>
            <Size>10.2</Size>
            <Bold>false</Bold>
            <Italic>false</Italic>
          </Font>
          <PropertyName>Creation Date</PropertyName>
          <PropertySetName>Project</PropertySetName>
        </UiElementSpec>
        <UiElementSpec xsi:type="iLogicExternalRuleControlSpec">
          <Name>Update iProp</Name>
          <Guid>5c953f60-e750-4fa7-9098-7936a7487edd</Guid>
          <Font>
            <FamilyName>Tahoma</FamilyName>
            <Size>10.2</Size>
            <Bold>false</Bold>
            <Italic>false</Italic>
          </Font>
          <Image>
            <BitmapByteArray />
          </Image>
          <TextVisible>true</TextVisible>
          <RuleName>Update iProp</RuleName>
          <RuleButtonBehavior>RunRule</RuleButtonBehavior>
          <Path>C:\CADLib\Templates\iLogic\Update iProp.txt</Path>
        </UiElementSpec>
      </Items>
      <CaptionImage>
        <BitmapByteArray />
      </CaptionImage>
      <BordersVisible>true</BordersVisible>
    </UiElementSpec>
  </Items>
  <StyleAndSkinName>
    <StyleName>Default</StyleName>
  </StyleAndSkinName>
  <AllowCustomization>true</AllowCustomization>
  <PredefinedButtons>OkCancelApply</PredefinedButtons>
  <Modal>false</Modal>
</FormSpecification>

 

0 Likes
Message 8 of 9

johan
Enthusiast
Enthusiast
It is not completely clear what you want to do. Note that not all properties can be changed if you didn't change the read-write rights. Please upload the part with the Irules and form present
0 Likes
Message 9 of 9

RJ202020
Explorer
Explorer

Thank you for your response. Rather than repeatedly navigating through the file menu to access "iproperties", I like to make a global form, so this form can be docked to the side, allowing me to conveniently view and modify the iproperties as needed.

 

I've changed all iproperties to write access.

 

To implement this, I created a form with all the necessary iproperties. Then I went into this folder:

C:\Users\Public\Documents\Autodesk\Inventor 2023\Design Data\iLogic\UI.

Within this folder, I opened the Form XML file and copied and pasted into the global form xml. Please see the attached document for reference. 

Iprop Global form.png

 

Additionally, I've already mentioned the "Update Iprop" button ilogic code in a previous message. Once I modified the properties in global form (i.e part number or revision number) and I press "update iprop" button, it should update the properties and it is not happening now. If any part of my explanation requires clarification, please let me know. which is not clear.

0 Likes