Hi Steve
ObjectMaterialSource has a bug in the loop for multiple objects where the material source is changed (fixed below). It was not using the Enum to get the material source. I tried to check it directly into GitHub but got a forbidden note. How can I use GitHub properly. Will I have to make a new branch? I am using it actually as a SVN repro.
Silvan
def ObjectMaterialSource(object_ids, source=None):
"""Returns or modifies the rendering material source of an object.
Parameters:
object_ids = one or more object identifiers
source [opt] = The new rendering material source. If omitted and a single
object is provided in object_ids, then the current material source is
returned. This parameter is required if multiple objects are passed in
object_ids
0 = Material from layer
1 = Material from object
3 = Material from parent
Returns:
If source is not specified, the current rendering material source
If source is specified, the previous rendering material source
If object_ids refers to multiple objects, the number of objects modified
"""
id = rhutil.coerceguid(object_ids, False)
if id: # working with single object
rhino_object = rhutil.coercerhinoobject(id, True, True)
rc = int(rhino_object.Attributes.MaterialSource)
if source is not None:
rhino_object.Attributes.MaterialSource = System.Enum.ToObject(Rhino.DocObjects.ObjectMaterialSource, source)
rhino_object.CommitChanges()
return rc
# else working with multiple objects
if source is None: raise Exception("source is required when object_ids represents multiple objects")
for id in object_ids:
rhino_object = rhutil.coercerhinoobject(id, True, True)
rhino_object.Attributes.MaterialSource = System.Enum.ToObject(Rhino.DocObjects.ObjectMaterialSource, source)
rhino_object.CommitChanges()
return len(object_ids)