• Blog posts


    By Luke Davenport



    You want a drop-down list in an iLogic form that allows you to select from a list of materials or appearances. And you want that list to reflect the current contents of a material/appearance library of your choice. 


    Well its nice and easy to get a multivalue parameter for each material in the active material library, using this single line of iLogic code:

    MultiValue.List("param") = iProperties.Materials

    But this doesn’t offer you much flexibility if you have more than one potential material library (see this recent blog by Gus), as the active library may not be the correct one.

    And unless I’ve missed something, there’s no equivalent line of code for getting a list from an appearance library (active or otherwise). 

    So there’s my justification for this blog. And as I’m thinking about Friday’s roast potatoes, I thought I’d use a clumsily modelled Christmas lunch to illustrate. 

    Right. So it’s nice and simple. All you need to do is download the iLogic rules below, and adjust the following bits of code to your needs: 

    • Change this name to the name of the material (or appearance) library you want to read from.

    Dim MatLibraryName As String = "Inventor Material Library"

    • Change the name of the “Materials” string below to whatever you like. This will be the name of the multi-value parameter that is created. Be aware that there are certain limitations for the names of parameters in Inventor (must begin with a letter, no spaces/illegal characters etc…) 

    ' Attempt to set the value of a parameter containing the list of material names


    MultiValue.List("Materials") = MaterialArray


    ' parameter doesn't exist - create it

    Dim oParam As Parameter = oDef.Parameters.UserParameters.AddByValue("Materials", MaterialArray(0), UnitsTypeEnum.kTextUnits)

    MultiValue.List("Materials") = MaterialArray

    End Try

    And that’s it! 

    You can download the code below, or alternatively you can download the Inventor part file here.

    (Note it’s an Inventor 2016 part file so you won’t be able to open it in a previous release of Inventor)


1 comment

  • Avatar
    Edwinn Toorn

    nice rule, is it also possible that i can do that on a assembly?
    I want to have a list with my Appearances that I make myself

    That change my assembly with all his parts.



    Comment actions Permalink

Please sign in to leave a comment.