- 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.
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.
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.
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.