Is there a way to create a multi-value parameter with ilogic?
Solved! Go to Solution.
Solved by MegaJerk. Go to Solution.
I use something like this ::
Imports Inventor.UnitsTypeEnum Dim oPartDoc As Document oPartDoc = ThisDoc.Document If oPartDoc.DocumentType = kPartDocumentObject Then
Dim oPartCompDef As PartComponentDefinition oPartCompDef = oPartDoc.ComponentDefinition
Dim oParams As Parameters oParams=oPartCompDef.Parameters Dim oUserParams As UserParameters oUserParams=oParams.UserParameters Dim oAwesomeParameter As Parameter Try otester = oUserParams.Item("AwesomeParameter") Catch oInsulationType=oUserParams.AddByValue("AwesomeParameter", "Option1", kTextUnits) MultiValue.SetList("AwesomeParameter", "Option1", "Option2", "Option3", "Option4") End Try End If Parameter.Param("AwesomeParameter").ExposedAsProperty = False Parameter.Param("AwesomeParameter").IsKey = True
Also. A list of enums (for unit types) :
Public Enum UnitsTypeEnum kUnitlessUnits = 11265 kDefaultDisplayLengthUnits = 11266 kDatabaseLengthUnits = 11267 kCentimeterLengthUnits = 11268 kMillimeterLengthUnits = 11269 kMeterLengthUnits = 11270 kMicronLengthUnits = 11271 kInchLengthUnits = 11272 kFootLengthUnits = 11273 kYardLengthUnits = 11274 kMileLengthUnits = 11275 kDefaultDisplayAngleUnits = 11276 kDatabaseAngleUnits = 11277 kRadianAngleUnits = 11278 kDegreeAngleUnits = 11279 kGradAngleUnits = 11280 kDefaultDisplayMassUnits = 11281 kDatabaseMassUnits = 11282 kKilogramMassUnits = 11283 kGramMassUnits = 11284 kSlugMassUnits = 11285 kLbMassMassUnits = 11286 kOunceMassUnits = 11287 kDefaultDisplayTimeUnits = 11288 kDatabaseTimeUnits = 11289 kSecondTimeUnits = 11290 kMinuteTimeUnits = 11291 kHourTimeUnits = 11292 kDefaultDisplayTemperatureUnits = 11293 kDatabaseTemperatureUnits = 11294 kKelvinTemperatureUnits = 11295 kCelsiusTemperatureUnits = 11296 kFahrenheitTemperatureUnits = 11297 kMetersPerSecondSpeedUnits = 11298 kFeetPerSecondSpeedUnits = 11299 kMilesPerHourSpeedUnits = 11300 kAcreAreaUnits = 11301 kLiterVolumeUnits = 11302 kGallonVolumeUnits = 11303 kQuartVolumeUnits = 11304 kPintVolumeUnits = 11305 kCupVolumeUnits = 11306 kOunceVolumeUnits = 11307 kPascalPressureUnits = 11308 kPSIPressureUnits = 11309 kKSIPressureUnits = 11310 kNewtonForceUnits = 11311 kDyneForceUnits = 11312 kLbForceUnits = 11313 kOunceForceUnits = 11314 kWattPowerUnits = 11315 kHorsePowerPowerUnits = 11316 kJouleWorkUnits = 11317 kErgWorkUnits = 11318 kCalorieWorkUnits = 11319 kBTUWorkUnits = 11320 kRPMAngularVelocityUnits = 11321 kCompositeUnits = 11322 kNauticalMileLengthUnits = 11323 kMilLengthUnits = 11324 kSteradianAngleUnits = 11325 kCircularMilAreaUnits = 11326 kAmpElectricalCurrentUnits = 11327 kVoltElectricalVoltageUnits = 11328 kOhmElectricalResistanceUnits = 11329 kCoulombElectricalChargeUnits = 11330 kFaradElectricalCapacitanceUnits = 11331 kSiemensElectricalConductanceUnits = 11332 kmhoElectricalConductanceUnits = 11333 kWeberMagneticFluxUnits = 11334 kMaxwellMagneticFluxUnits = 11335 kTeslaMagneticInductionUnits = 11336 kGammaMagneticInductionUnits = 11337 kGaussMagneticInductionUnits = 11338 kHenryElectricalInductanceUnits = 11339 kOerstedMagneticInductionUnits = 11340 kHertzFrequencyUnits = 11341 kCandelaLuminousIntensityUnits = 11342 kLumenLuminousFluxUnits = 11343 kLuxIlluminationUnits = 11344 kMoleSubstanceUnits = 11345 kTextUnits = 11346 kBooleanUnits = 11347 End Enum
*Edit : Code formatting will seem a bit strange, but I wanted those lines to be full lines instead of broken!
Hi,
Not sure if i would have a use for your rule, but i wanted to try it out.
I get a error on the line
oInsulationType
=oUserParams.AddByValue("AwesomeParameter", "Option1", kTextUnits)
it wants to convert Option1 from a string to a double..........any ideas?
Hi swordmaster,
I noticed you stated you're using Inventor 2010. I'm guessing that is the issue, since Text parameters were not added until Inventor 2011.
As an alternative you might be able to use something like this:
oStringArray = new string(){"Pinched", "Drilled", "Milled (2 step)", "EDM"} oList = InputListBox("Select a feature type", oStringArray, "Punched", "iLogic", "Available Feature Types") MessageBox.Show(oList, "ilogic")
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Hello Curtis,
Yes i use inv 2009 (work) and 2010 (home) !
I should have remembered about not being able to create string parameters.
However the original question was "how to create multi-value parameters with ilogic" and I can create a
ilogic parameter from the ilogic parameter editor , this allows me to choose from types User, String or Boolean.
So i believe the code will work with a little "tweaking" so that it creates a ilogic not a user parameter
thanks for the reply 🙂
Thanks, that helps a lot. I knew how to make a text parameter and for some reason thought that it had to be a multi-value list at creation. it never occured to me to try just adding the list afterwards.
Hi 🙂
this rule work really great in text unit but i try to put my new parameter in inch?
This is my try, sorry for my horrible english 😞
but dont work 😞
Thanks for your help 🙂
Imports Inventor.UnitsTypeEnum
Dim oPartDoc As Document
oPartDoc = ThisDoc.Document
If oPartDoc.DocumentType = kPartDocumentObject Then
Dim oPartCompDef As PartComponentDefinition
oPartCompDef = oPartDoc.ComponentDefinition
Dim oParams As Parameters
oParams=oPartCompDef.Parameters
Dim oUserParams As UserParameters
oUserParams=oParams.UserParameters
Dim oAwesomeParameter As Parameter
Try
otester = oUserParams.Item("ÉPAISSEUR")
Catch
oInsulationType=oUserParams.AddByValue("ÉPAISSEUR", "11/16", kInchLengthUnits)
MultiValue.SetList("ÉPAISSEUR", "1/32", "1/16", "1/8", "1/4", "3/8", "7/16", "1/2", "9/16", "5/8", "11/16", "3/4", "13/16", "7/8", "1", "1 1/4", "1 3/8", "1 1/2")
End Try
End If
Parameter.Param("ÉPAISSEUR").ExposedAsProperty = False
Parameter.Param("ÉPAISSEUR").IsKey = True
another question 🙂
it'S possible to add a <custom value> in MultiValue.SetList
ex.:
MultiValue.SetList("CHANTS", "AUCUN", "1C", "1L", "1L-1C", "1L-2C", "2L", "2L-1C", "2L-2C", <custom value>)
Thanks all 🙂
If you want to add an Inch based Multivalue list, then you can do so using this method :
Imports Inventor.UnitsTypeEnum Dim oPartDoc As Document oPartDoc = ThisDoc.Document If oPartDoc.DocumentType = kPartDocumentObject Then Dim oPartCompDef As PartComponentDefinition oPartCompDef = oPartDoc.ComponentDefinition Dim oParams As Parameters oParams=oPartCompDef.Parameters Dim oUserParams As UserParameters oUserParams=oParams.UserParameters Dim oAwesomeParameter As Parameter Try otester = oUserParams.Item("InchParameter") Catch oInsulationType=oUserParams.AddByValue("InchParameter", 1/16*2.54, kInchLengthUnits ) MultiValue.SetList("InchParameter", 1/16, 3/16, 5/16, 7/16, 9/16) End Try End If Parameter.Param("InchParameter").ExposedAsProperty = False Parameter.Param("InchParameter").IsKey = True
If you want to add custom values, you can, BUT they will not work correctly if the parameter itself is of a different unit type! A parameter with kInchLengthUnits, will not enjoy if you select text from the multivalue list (even though it will allow you to put it there).
If you need to add numbers and text, then I would suggest keeping kTextUnits and use a Select Case statement if there will only be a handful of selectable options.
Side note: when you put things in quotes (“11/16” or “400*2” or “Jimmy”) the compiler interprets that as text input. That is why you were having your problem above.
Side note Part 2 : Do you need to have the value show as “11/16” instead of .6875? If not, then you could just make it a MultivalueList text parameter (“.6875”, “.875”, “Some Text Here”) and use the
IsNumeric(Parameter) method to check if the selection is a valid number or not. Using IsNumeric on an expresion like “11/16” returns false, so if you pre-converted them out of fraction to decimal, it may help you in the long run.
To be honest, I looked, and looked, and looked, but I could not find any real hints as to where that option is. Why exactly do you need to set that up? If the user has a choice in what the parameter can be, why not either prompt them for input, or leave it blank to let them fill out?
Perhaps someone else can shine some light on that option.
I no longer really work with Inventor, but I imagine that because everything in the above code is so generic, it should just be a matter of changing
kPartDocumentObject
into
kAssemblyDocumentObject
Create a new Assembly File and give it a shot!
Hi, MegaJerk
I read data from table in excel to my oMyArray. I can't to insert it to multi-value parameter:
oMyArray = GoExcel.CellValues("A2", "A" & LastRowNumber)
MultiValue.SetList("PROJEKT_VAULT", oMyArray)
Can you help me? Thanks
Jan
Standard function in iLogic, see SNIPPETS in EXCEL DATA LINKS folder:
MultiValue.List("d0") = GoExcel.CellValues("filename.xls", "Sheet1", "A2", "A10")
Hello,
Upper rule works very good for Part. How to modified it for assembly. Upper help with change kPartDocumentObject into kAssemblyDocumentObject doesn't work.
Thanks.
I'm trying to do something similar but with an IDW file instead of a part file. Trying to navigate my way through editing the first accepted code to change things from a part file to a drawing file but not having much luck finding the right snippets to use in the ilogic editor.
What I'm trying to create is a text-based user parameter named "TYPE_OF_DWG" and the multi-value text selections being:
I have a global form that allows the user to select the multi-value parameter. I'm task with revamping all of the ETO department drawings with a new/updated border which includes this form and multi-value parameter. Any help would be greatly appreciated!
Can't find what you're looking for? Ask the community or share your knowledge.