Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5846

Python: How to assign attributes to existing objects?

$
0
0

@Michael_Meyer wrote:

Hi...,

sorry, me again. :wink: Can someone show me the way to assign attributes(with material) to existing objects in Python?

# materials are stored in the document's material table
index = scriptcontext.doc.Materials.Add()
mat = scriptcontext.doc.Materials[index]
mat.DiffuseColor = System.Drawing.Color.Chocolate
mat.CommitChanges()

# set up object attributes to say they use a specific material
attr = Rhino.DocObjects.ObjectAttributes()
attr.MaterialIndex = index
attr.MaterialSource = Rhino.DocObjects.ObjectMaterialSource.MaterialFromObject

objects = rhinoscriptsyntax.LastCreatedObjects();
# how to assign attr to objects?

Thanks

Michael
www.flexiCAD.com

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5846

Latest Images

Trending Articles



Latest Images