The implementation of rs.MatchObjectAttributes should probably look more like this:
def MatchObjectAttributes(target_ids, source_id=None):
"""Matches, or copies the attributes of a source object to a target object
Parameters:
target_ids = identifiers of objects to copy attributes to
source_id[opt] = identifier of object to copy attributes from. If None,
then the default attributes are copied to the target_ids
Returns:
number of objects modified
"""
id = rhutil.coerceguid(target_ids, False)
if id: target_ids = [id]
source_attr = scriptcontext.doc.CreateDefaultAttributes()
if source_id:
source = rhutil.coercerhinoobject(source_id, True, True)
source_attr = source.Attributes.Duplicate()
rc = 0
for id in target_ids:
id = rhutil.coerceguid(id, True)
if scriptcontext.doc.Objects.ModifyAttributes(id, source_attr, True):
rc += 1
if rc: scriptcontext.doc.Views.Redraw()
return rc
If you are trying to use the above in your own code, then use this:
import rhinoscriptsyntax as rs
import scriptcontext
def MyMatchObjectAttributes(target_ids, source_id=None):
"""Matches, or copies the attributes of a source object to a target object
Parameters:
target_ids = identifiers of objects to copy attributes to
source_id[opt] = identifier of object to copy attributes from. If None,
then the default attributes are copied to the target_ids
Returns:
number of objects modified
"""
id = rs.coerceguid(target_ids, False)
if id: target_ids = [id]
source_attr = scriptcontext.doc.CreateDefaultAttributes()
if source_id:
source = rs.coercerhinoobject(source_id, True, True)
source_attr = source.Attributes.Duplicate()
rc = 0
for id in target_ids:
id = rs.coerceguid(id, True)
if scriptcontext.doc.Objects.ModifyAttributes(id, source_attr, True):
rc += 1
if rc: scriptcontext.doc.Views.Redraw()
return rc