#add matrial to an object new_mat = create_material("New Material") add_matrial_to_object(object, new_mat)
# get all materials from an object mat_ref = get_materials_form_object(object) mat_names = get_materials_names_from_object(object)
# remove material from objs remove_material_from_object(object, new_mat) # or remove_material_from_object(object, "New Material")
变换操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# location # get the location of the selcted object with consideration of the context of the args location() # get location of the object location(object) # set location of the object location(object, [1.0, 2.0, 3.0])
# rotation and scaling are the same as location rotation() rotation(object) rotation(object, [45.0, -25.0, 60,0])
# also you can delect_all_objects() select_all_meshed() select_all_curves() select_all_cameras() invert_selection() delect_slected_objects()
实例
假设需要将一堆物体加入到一个集合,现在我们假设objs是需要操作的物体的列表
1 2 3 4 5 6 7 8 9 10 11 12
# assume objs is a list of objects
# create a new collectiona and link the objs to the collection # be careful of the plural col = create_collection("Collection") link_objects_to_collection(objs, col)
if collection_exists("Collection"): duplicate_collection("Collection")
# delete the used unnecessary layout delete_hierarchy(col)
使用EasyBPY, 你几乎可以做任何事情,就像你可以创建一个物体,然后再给他添加一个修改器
1 2
curt = cerate_cube() add_subsurt(curt, "Name of Modifier")