Selecting Splines by Display Colour


#1

Hi all,

I imported an illustrator file using CV-Artsmart and I got around 7500 splines with the Use Colour option activated in the Basic tab and a Display Colour assigned to each one.

How can I tell Cinema to select splines that share the same Display colour?

Since there are so many splines I need to find an automatic way of doing this.

Thanks in advance!
M.


#2

import c4d

def iterateHierarchy(obj, doc, colorToMatch):
    while obj:
        if obj[c4d.ID_BASEOBJECT_COLOR] == colorToMatch and isinstance(obj, c4d.SplineObject):
                doc.SetActiveObject(obj, c4d.SELECTION_ADD)
        iterateHierarchy(obj.GetDown(), doc, colorToMatch)
        obj = obj.GetNext()
def main():
    obj = op
    if not obj: return
    
    color = obj[c4d.ID_BASEOBJECT_COLOR]
    
    iterateHierarchy(doc.GetFirstObject(), doc, color)
    
    c4d.EventAdd()
if __name__=='__main__':
    main()

It will select all splines that have the same color than the object you currently select.


#3

I’ll try it right away, thank you so much!!


#4

It works perfect! Thanks again!! :bowdown:


#5

This is so cool man…!!! It even works with Polygon Objects with a minor change… Thanks.


#6

Yes of course, just remove “and isinstance(obj, c4d.SplineObject)” and it will select all kind of objects. :slight_smile:


#7

Very generous gr4ph0s, so great to see such help from the community.