Can you have dropdowns in an ilogic FORM?
For example I want to setup 5 choices for a custom iproperty. Then when I run the form I can pick from those 5 choices only?
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
The way I have done it in the past is with a Custom Parameter that is Exported to be a Custom iProperty. I use the Multi-value list from the parameter to drive the value of the Custom iProperty
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Mark Flayler - Engagement Engineer
IMAGINiT Manufacturing Solutions Blog: https://resources.imaginit.com/manufacturing-solutions-blog
Mark, how do you export a multi-value text parameter?
Actually I misspoke, I use an ilogic rule to copy the value of the MultiValue parameter to the value of the custom iproperty. There is no export on the MultiValue parameters.
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Mark Flayler - Engagement Engineer
IMAGINiT Manufacturing Solutions Blog: https://resources.imaginit.com/manufacturing-solutions-blog
Would you mind sharing this code?
Hi everyone,
You can use MultiValue.SetList to add values and convert a parameter to a multi-value parameter.
Here's a quick example.
There is a sketch dimension / parameter called Length.
There is a rule with this line of code.
MultiValue.SetList("Length", 100, 150, 200, 250)
There is a form set up like this:
Attached is the example file (Inventor 2013)
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Hi mcgyvr,
You could also add a few lines to expose (export) the parameter value as a property. So using the previous example you set the Length using a form, and this code sets the list and ensures the parameter is exported as a custom iProperty.
'set list of values MultiValue.SetList("Length", 100, 150, 200, 250) Dim oLength As Parameter oLength = Parameter.Param("Length") oLength.ExposedAsProperty = True
But if you need the parameter value to be written to a custom iProperty that is not the same name as the parameter you could use something like this. In this example a custom iProperty called L1 is created or reused, depending if it exists. And the Length parameter value is written to it:
'set list of values MultiValue.SetList("Length", 100, 150, 200, 250) Dim propertyName1 As String = "L1" 'define custom property collection oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Try 'set property value oProp = oCustomPropertySet.Item(propertyName1) Catch ' Assume error means not found so create it oCustomPropertySet.Add("", propertyName1) End Try 'set custom property value iProperties.Value("Custom", "L1") = Length
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
iproperty NOT parameter
I just want a form with a drop down to fill in the value of a custom iproperty.
Currently I'm doing it with an "Input Box" rule which is fine but not as pretty as I could make a form.
Seems totally silly to me this isn't build into ilogic forms already..
It should be as simple as this.. See attached
Hi mcgyvr,
You're correct. There isn't a way to point the form to the iProperty and have a list, at least not that I'm aware of.
Therefore we need to use the paramter list in the form, and hand the value from the paramter to the iProperty. I used a model parameter in the example, but you could also use a user parameter if a model parameter would not work.
The iLogic forms have some limitations compared to standard VB userforms, but I'm not sure why certain option are included / not included for the controls.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sure would have made life easier..
Autodesk needs more forward thinkers or better "brainstorming" sessions.
blah I'll just stick with the ugly inputbox rules I've already got..
rhasell
use row and place the perameters in there if i put 3 there would be 3 columns and so on. Here is a pic. and don't give me credit some one showed me..
I'm trying to do a similar code that dynamically updates a drop down menu with the selection of a primary criteria from a drop down menu. Looking at the Parameters menu it works flawlessly. When attempting to do it via a Form it doesn't work. I don't get the second menu as a drop down but only as a text field for input. What am I missing?
(Inventor Pro 2015)
edit: NVM, had to re-add the field after the coding.
Thanks for your previous as it has me well on my way.
I'm working on a rule to check whether a user parameter exists and if not, creates it.
I'm using Try/Catch.
My question is: how do I ensure that if the user parameter already exists, I use the already present value and do not overwrite it?
Any help is appreciated!
Hi
Thats all you need. it wont overwrite the value.
I have a few rules, some a little more detailed, here is an extract from one of them.
Dim oPartDoc as PartDocument = ThisDoc.Document Dim userParams As UserParameters = oPartDoc.ComponentDefinition.Parameters.UserParameters Dim newParam As UserParameter ' Placeholder Dim oFormat As CustomPropertyFormat 'LENGTH Try oParam = oPartDoc.ComponentDefinition.Parameters("LENGTH") Catch 'If the parameter was not found, then create a new one. newParam = userParams.AddByExpression("LENGTH", 0, "mm") ' Create the Parameter as per above newParam.ExposedAsProperty=True 'Flag for Export oFormat=newParam.CustomPropertyFormat 'For some reason or other this line is needed to enable the following formatting oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kzeroDecimalPlacePrecision 'Set one decimal place 'oFormat.Units="mm" 'Units oFormat.ShowUnitsString=False oFormat.ShowLeadingZeros=False oFormat.ShowTrailingZeros=False End Try
Thanks for that. Okay, I've modified my code a bit to better reflect your approach, and I'll try to describe what is happening.
A little bit of background. I'm trying to create the rule so that I can select a part 'type' such as plate, sheet, round, PFC, SHS, etc and then relevant parameters only are created for the part. So if I have a plate part, I want G_L, G_W, and G_T. If I have a bar component, I want just G_L and G_D. If SHS I want G_W and/or G_H, G_L, and G_T. I'm accomplishing that with Select Case. Ultimately the idea is to export these to a formatted Custom Property description for use on autopopulating the BOMs and part descriptions.
So looking just at, in this case, SHS:
First, I'm trying to use the same code three times in a row to create and format the three different user parameters (G_L, G_W, G_T). No problem there: it creates all three and formats them as desired.
Before I run the rule:
After I run the rule:
So like I said, no issues there.
But if I immediately run the rule again, I get an error:
Messing around with it, I've found that it does not like having the first previously created user parameter already present when running the rule the second time.
So if I delete the first created user parameter, leaving the subsequent two, there are no problems: it runs and creates the missing one.
But if I delete the second and/or third but leave the first, I get the error.
I have rearranged the order of creation of the parameters, and it does not matter what order they are in: whichever one is first has to be deleted from the parameters before running the rule again, or I get the error.
Here is my code...
Select Case strSelectedPartType 'Filter on those components requiring G_L, G_W, G_T Case "SHS", "Flat", "Plate", "Rolled Ring", "Sheetmetal", "Chequerplate" 'If strSelectedPartType = "SHS" Then 'Check whether G_T exists and create it if not Try oParam = oPartDoc.ComponentDefinition.Parameters("G_T") Catch oParameter = oGeometricParameter.AddByExpression("G_T", "999", UnitsTypeEnum.kMillimeterLengthUnits) End Try 'Format G_T for use in descriptive custom property oParameter.ExposedAsProperty = True oFormat = oParameter.CustomPropertyFormat oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.ShowUnitsString = False oFormat.ShowLeadingZeros = False oFormat.ShowTrailingZeros = False 'Check whether G_L exists and create it if not Try oParam = oPartDoc.ComponentDefinition.Parameters("G_L") Catch oParameter = oGeometricParameter.AddByExpression("G_L", "999", UnitsTypeEnum.kMillimeterLengthUnits) End Try 'Format G_L for use in descriptive custom property oParameter.ExposedAsProperty = True oFormat = oParameter.CustomPropertyFormat oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.ShowUnitsString = False oFormat.ShowLeadingZeros = False oFormat.ShowTrailingZeros = False 'Check whether G_W exists and create it if not Try oParam = oPartDoc.ComponentDefinition.Parameters("G_W") Catch oParameter = oGeometricParameter.AddByExpression("G_W", "999", UnitsTypeEnum.kMillimeterLengthUnits) End Try 'Format G_W for use in descriptive custom property oParameter.ExposedAsProperty = True oFormat = oParameter.CustomPropertyFormat oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.ShowUnitsString = False oFormat.ShowLeadingZeros = False oFormat.ShowTrailingZeros = False End Select
I don't understand the error behaviour.
Hi
Just busy at the moment, I will have a look in a moment.
I noticed that the formatting is being done after the "end try" This might also affect the rule. (Dont know, I will have to test it.)
While working with parameters, I found that they are very sensitive to the creation and formating sytanxes.
As a test, create and format your parameters exacly as I have done, see if that works.
Hi
I ran your code, I had to modify it to suit, as I did not have your case select, so I just removed it for testing. I also changed the "oGeometricParameter" to suit my definitions.
The fault was the formatting option after the END TRY. After moving the lines, it worked correctly.
See the updated code:
Hope this helps.
Dim oPartDoc as PartDocument = ThisDoc.Document Dim userParams As UserParameters = oPartDoc.ComponentDefinition.Parameters.UserParameters Dim newParam As UserParameter ' Placeholder Dim oFormat As CustomPropertyFormat 'Select Case strSelectedPartType 'Filter on those components requiring G_L, G_W, G_T 'Case "SHS", "Flat", "Plate", "Rolled Ring", "Sheetmetal", "Chequerplate" 'If strSelectedPartType = "SHS" Then 'Check whether G_T exists and create it if not Try oParam = oPartDoc.ComponentDefinition.Parameters("G_T") Catch oParameter = userParams.AddByExpression("G_T", "999", UnitsTypeEnum.kMillimeterLengthUnits) oParameter.ExposedAsProperty = True oFormat = oParameter.CustomPropertyFormat oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.ShowUnitsString = False oFormat.ShowLeadingZeros = False oFormat.ShowTrailingZeros = False End Try 'Format G_T for use in descriptive custom property 'Check whether G_L exists and create it if not Try oParam = oPartDoc.ComponentDefinition.Parameters("G_L") Catch oParameter = userParams.AddByExpression("G_L", "999", UnitsTypeEnum.kMillimeterLengthUnits) oParameter.ExposedAsProperty = True oFormat = oParameter.CustomPropertyFormat oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.ShowUnitsString = False oFormat.ShowLeadingZeros = False oFormat.ShowTrailingZeros = False End Try 'Format G_L for use in descriptive custom property 'Check whether G_W exists and create it if not Try oParam = oPartDoc.ComponentDefinition.Parameters("G_W") Catch oParameter = userParams.AddByExpression("G_W", "999", UnitsTypeEnum.kMillimeterLengthUnits) oParameter.ExposedAsProperty = True oFormat = oParameter.CustomPropertyFormat oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.ShowUnitsString = False oFormat.ShowLeadingZeros = False oFormat.ShowTrailingZeros = False End Try 'Format G_W for use in descriptive custom property 'End Select
Okay, I'll give that a shot. However, my intent is to set the formatting for both existing and new parameters...should I just repeat the formatting between Try and Catch for the parameters which already exist? Seems a bit repetitive.
Or maybe the formatting should be moved to be done after all the parameters are created...?
Can't find what you're looking for? Ask the community or share your knowledge.