Inventor Customization

Inventor Customization

Reply
Mentor
Lance_White
Posts: 154
Registered: ‎06-13-2011
Message 1 of 12 (2,179 Views)
Accepted Solution

Create Multi-value parameter with iLogic

2179 Views, 11 Replies
05-01-2012 06:58 AM

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

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!  

Valued Mentor
MegaJerk
Posts: 277
Registered: ‎01-26-2011
Message 2 of 12 (2,176 Views)

Re: Create Multi-value parameter with iLogic

05-01-2012 09:36 AM in reply to: Lance_White

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 seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Distinguished Mentor
swordmaster
Posts: 541
Registered: ‎12-15-2008
Message 3 of 12 (2,171 Views)

Re: Create Multi-value parameter with iLogic

05-01-2012 12:53 PM 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
*Expert Elite*
Curtis_Waguespack
Posts: 2,986
Registered: ‎03-08-2006
Message 4 of 12 (2,166 Views)

Re: Create Multi-value parameter with iLogic

05-01-2012 02:48 PM in reply to: swordmaster

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




  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Distinguished Mentor
swordmaster
Posts: 541
Registered: ‎12-15-2008
Message 5 of 12 (2,156 Views)

Re: Create Multi-value parameter with iLogic

05-02-2012 05:27 AM in reply to: Curtis_Waguespack

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 :smileyhappy:

Inventor 2010 Certified Professional
Mentor
Lance_White
Posts: 154
Registered: ‎06-13-2011
Message 6 of 12 (2,155 Views)

Re: Create Multi-value parameter with iLogic

05-02-2012 05:31 AM in reply to: Lance_White

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
Distinguished Contributor
sergelachance
Posts: 182
Registered: ‎04-30-2012
Message 7 of 12 (1,731 Views)

Re: Create Multi-value parameter with iLogic

02-19-2013 06:11 AM in reply to: Lance_White

Hi :smileyhappy:

 

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 :smileysad:

but dont work :smileysad:

Thanks for your help :smileyhappy:

 

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

 

 

Distinguished Contributor
sergelachance
Posts: 182
Registered: ‎04-30-2012
Message 8 of 12 (1,724 Views)

Re: Create Multi-value parameter with iLogic

02-19-2013 08:38 AM in reply to: sergelachance

another question :smileyhappy:

 

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 :smileyhappy:

Valued Mentor
MegaJerk
Posts: 277
Registered: ‎01-26-2011
Message 9 of 12 (1,710 Views)

Re: Create Multi-value parameter with iLogic

02-20-2013 05:24 AM in reply to: sergelachance

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 seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Distinguished Contributor
sergelachance
Posts: 182
Registered: ‎04-30-2012
Message 10 of 12 (1,705 Views)

Re: Create Multi-value parameter with iLogic

02-20-2013 09:25 AM in reply to: Lance_White

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post