View blender_rename_objects_numbered.py
import bpy | |
objects = bpy.context.selected_objects | |
base_name = "new_name" | |
for (i,o) in enumerate(objects): | |
o.name = "{}_{:03d}".format(base_name, i) |
View blender_remove_last_name_chars.py
import bpy | |
objects = bpy.context.selected_objects | |
num_chars = 3 | |
for o in objects: | |
o.name = o.name[:-num_chars] |
View blender_get_vert_uvs.py
import bpy | |
# access mesh data: | |
obj = bpy.context.active_object | |
mesh_data = obj.data | |
mesh_loops = mesh_data.loops | |
uv_index = 0 | |
# iterate teh mesh loops: | |
for lp in mesh_loops: | |
# access uv loop: | |
uv_loop = mesh_data.uv_layers[uv_index].data[lp.index] |
View blender_animated_verts_data.py
import bpy | |
import bmesh | |
obj = bpy.context.active_object | |
frames = range(0,10) | |
# get the object's evaluated dependency graph: | |
depgraph = bpy.context.evaluated_depsgraph_get() | |
# iterate animation frames: | |
for f in frames: | |
bpy.context.scene.frame_set(f) | |
# define new bmesh object: |
View blender_access_mesh_triangles.py
import bpy | |
mesh = bpy.context.active_object.data | |
mesh.calc_loop_triangles() | |
for tri in mesh.loop_triangles: | |
tri_center = (mesh.vertices[tri.vertices[0]].co * 0.333) +\ | |
(mesh.vertices[tri.vertices[1]].co * 0.333) +\ | |
(mesh.vertices[tri.vertices[2]].co * 0.333) | |
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.1,enter_editmode=False,location=tri_center) |
View max_mesh_animation.py
import MaxPlus | |
import math | |
from MaxPlus import INode | |
from MaxPlus import TriObject | |
from MaxPlus import SelectionManager | |
from MaxPlus import Factory | |
from MaxPlus import Animation | |
from MaxPlus import Point3 | |
from MaxPlus import Control |
View ue4_place_actors_at_z.py
import unreal | |
from unreal import Vector | |
lst_actors = unreal.EditorLevelLibrary.get_all_level_actors() | |
print('place actors at 0 z') | |
for act in lst_actors: | |
act_label = act.get_actor_label() | |
if 'Sphere_' in act_label: | |
print('placing: {}'.format(act_label)) | |
act_location = act.get_actor_location() |
View ue4_import_assets.py
from os import listdir | |
from os.path import isfile, join | |
import unreal | |
dir = "D:\\" | |
files = [f for f in listdir(dir) if isfile(join(dir, f)) and f[-3:]=='jpg'] | |
AssetTools = unreal.AssetToolsHelpers.get_asset_tools() | |
import_tasks = [] | |
for f in files: | |
print join(dir, f) |
View max_select_objects_by_type.py
from MaxPlus import SuperClassIds | |
from MaxPlus import SelectionManager | |
def scene_objects(): | |
def list_children(node): | |
list = [] | |
for c in node.Children: | |
list.append(c) | |
list = list + list_children(c) | |
return list |
View max_list_scene_objects.py
def scene_objects(): | |
def list_children(node): | |
list = [] | |
for c in node.Children: | |
list.append(c) | |
list = list + list_children(c) | |
return list | |
return list_children(MaxPlus.Core.GetRootNode()) |
NewerOlder