Direct Shape Import material quirk, Material Color is invalid via API until material is edited via UI

 - Testing in Revit 2017 
 - Dynamo Python node (/ revit lookup / any API call)

Description

I would like to query a material’s Color Property. This material is an automatically generated material from a Rhino 3dm(DirectShape Import). The Color property should be the layer color and this holds true when looking in the material browser and how its rendered. However, quierying it via the Revit API results in an invalid color property.

The color parameter stored in a material from a direct shape is not properly initialized/errors out until you actively use the ui material browser and modify the material. Until then, using the API (u can test this with revit lookup) to get the material color return an invalid color, making retrieving the rgb value not possible

However edit the material via the Ui, such as editing the surface pattern or color…This somehow refreshes the color parameter and allows one to use the revit API to read the color parameter afterward.

Things I’ve tried thus far

 + Updating another property (such as surface pattern / color) via the API, doesn't do the same as when updating via the UI material browser
 + Doc.Regenerate() after updating the property. (No changes)
 + tried getting built in parameter'doc.GetElement(ElementId(28736714)).Parameter[BuiltInParameter.MATERIAL_PARAM_COLOR].AsValueString()' returns blank.
 + tried saving document after updating misc. property via api, doesnt change anything.

Ideas

 + reading the solids and faces , somehow translating them to brep geometry and recreating the direct shape. in this way one can assign the material IDs to each face. however, geometry faces as far as i know cannot be converted into brep builder faces.

Visual Explanation

Visual PDF explanation of the problem can be seen here: https://www.docdroid.net/n2j9Auy/170628-color-direct-shape-material-quirk.pdf.html

Upload a sample DYN and an RVT file with an example of imported geometry (Ideally something simple like five cubes with materials on it) which was created by your current workflow?

I have an idea but don’t have the time or resources to recreate your issue, but should have time to test the issue tomorrow.

Hi Jacob please see this upload and screenshots. You’ll see the material color not being read due to their invalid/uninitialized error.

Zip file: https://www.dropbox.com/s/92ewz0h09ckhotu/material%20color%20direct%20shapes.zip?dl=0

I’ll give it a shot on Monday, assuming I can finish my other tasks prior to having to flee the city to escape the incoming tourists.

Hi Jacob,

did you ever get a chance to troubleshoot this? Thanks.

Sorry I forgot to get back to this.

I’m unable to open the file as I’m in Revit 2017 and your file was 2018… Can you do an import in a 2017 file and send that?

Hi Jacob,
Please find the 2017 version here:

Chris,

Looks to me as if both the Material.Color node and the direct shape import process are broken. I can’t get the material color node to directly retrieve ANY colors correctly no matter what I do.

However, Using an Element.GetParameterValueByName node indicates the error with the DS import - the direct shape materials have negative values while all other colors are positive. I tried using a math.ABS node on that value and set it to the material’s color value. It took but it wasn’t the right color. Not even close. I will try and look into color values later this month, and in the meantime I recommend you try to feed the rhino file into dynamo directly, and read the material color values from the file that way as you may be able to set the material colors correctly with that type of workflow.

Hi Jacob, I will try that. yes very strange, Ill look into the rhino file import for the time being. Thanks for looking into it!

So I tried making a material for all possible color combinations so I could try and see how the numbers correlate to the colors. This is 256^3 materials before taking alpha into account. I figured my CPU would try its best before bursting into flames or crashing in some other spectacular manor. It didn’t.

It did run out of resources and throw a “Cannot find a version of ‘material.duplicate’ that takes arguments of (material, array, array)” error, after making about 1500 materials of the 16,777,216 I requested. I’m going to try and come at this in a different manor next weekend, but in the meantime if anyone else can shed any light on this it would be helpful.

Please post your graph that makes new Materials.

Sadly this only lives on with my previous employer.

@jacob.small, did you use something like the Python shown here: Create materials (from Excel to Revit) ?

Or, can you point us to other clues about making Materials in Dynamo (especially using material images)?

Images as a texture or images as a parameter value?

As rendering texture.

I don’t have anything on that just yet, but I’ve been working on something for a large webinar series I’m doing. I’ll share once done. :slight_smile:

1 Like