Add a material to the Materials Database
-
Hello,
I would like to get some assistance in editting the material database, using python API.
I tried this code, but nothing changed in the database:import XMaterials as xm
import s4l_v1 as s4ldb = s4l.materials.database['User test']
print('#1| number of materials in "test" db: '+ str(len(s4l.materials.database['User test'].AllMaterials)))
mat = [m for m in db.AllMaterials if m.Name == u'test'][0]
new_mat = s4l.materials.database.Edit().CreateMaterial(db._Database__raw,'test3',db._Database__raw.Id)
s4l.materials.database.Edit().UpdateMaterial(new_mat,u'test3',db._Database__raw)
s4l.materials.database.Edit().Commit()
print('#2| number of materials in "test" db: '+ str(len(s4l.materials.database['User test'].AllMaterials)))>>>
#1| number of materials in "test" db: 2
#2| number of materials in "test" db: 2Thanks a lot,
Oshrit
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login