Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create Multi-value parameter with iLogic

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
Lance127
13878 Views, 20 Replies

Create Multi-value parameter with iLogic

Is there a way to create a multi-value parameter with ilogic?


Lance W.
Inventor Pro 2013 (PDS Ultimate)
Vault Pro 2013
Windows 7 64
Xeon 2.4 Ghz 12GB
20 REPLIES 20
Message 2 of 21
MegaJerk
in reply to: Lance127

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!  



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 3 of 21
swordmaster
in reply to: MegaJerk

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?

Inventor 2010 Certified Professional
Message 4 of 21

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


Message 5 of 21

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 🙂

Inventor 2010 Certified Professional
Message 6 of 21
Lance127
in reply to: Lance127

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.


Lance W.
Inventor Pro 2013 (PDS Ultimate)
Vault Pro 2013
Windows 7 64
Xeon 2.4 Ghz 12GB
Message 7 of 21
ChristinaForest
in reply to: Lance127

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

 

 

Message 8 of 21

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 🙂

Message 9 of 21
MegaJerk
in reply to: ChristinaForest

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.

 

 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 10 of 21
ChristinaForest
in reply to: Lance127

ok i understand, but what is the right rule to tell in my multivalue parameter the <custom value>??

Message 11 of 21
MegaJerk
in reply to: Lance127

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. 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 12 of 21
ChristinaForest
in reply to: MegaJerk

Thank's for your time   🙂

 

maybe anybody have the solution one day 🙂

Message 13 of 21
jan.kubeczka
in reply to: MegaJerk

Hi, all,

it is the same for ipt and iam or not?

Thanks

Message 14 of 21
MegaJerk
in reply to: jan.kubeczka

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!



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 15 of 21
jan.kubeczka
in reply to: MegaJerk

Thank you very much. Best regards.

Message 16 of 21
jan.kubeczka
in reply to: MegaJerk

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 

Message 17 of 21
Bram_Baars
in reply to: jan.kubeczka

@jan.kubeczka 

Standard function in iLogic, see SNIPPETS in EXCEL DATA LINKS folder:

 

MultiValue.List("d0") = GoExcel.CellValues("filename.xls", "Sheet1", "A2", "A10")

Message 18 of 21
Lukasz.Dudkowski
in reply to: Lance127

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.

Message 19 of 21

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: 

  • ASSEMBLY DETAILS
  • CONTROL DETAILS 
  • STEEL DETAILS

 

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!

 

parameter.jpg

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 20 of 21
jltw7PSW2
in reply to: kwilson_design

Hi Kenny,

Out of curiosity, did you find a solution to this?
I am trying to do a very identical thing, but I am very awful at iLogic 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report