本文整理汇总了Python中bpy_extras.object_utils.object_data_add方法的典型用法代码示例。如果您正苦于以下问题:Python object_utils.object_data_add方法的具体用法?Python object_utils.object_data_add怎么用?Python object_utils.object_data_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bpy_extras.object_utils
的用法示例。
在下文中一共展示了object_utils.object_data_add方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def execute(self, context):
mesh = bpy.data.meshes.new("wScrew")
wD = mesh.wData
wD.seg_1 = self.rounds
wD.seg_2 = self.segments
wD.siz_z = self.height
wD.rad_1 = self.radius_1
wD.rad_2 = self.radius_2
wD.smo = self.smoothed
wD.wType = 'WSCREW'
mesh.from_pydata(*update_WScrew(wD))
mesh.update()
object_utils.object_data_add(context, mesh, operator=None)
bpy.ops.object.shade_smooth()
context.object.data.use_auto_smooth = True
context.object.data.auto_smooth_angle = 1.0
return {'FINISHED'}
# create UI panel
示例2: make_mesh_from_verts_and_faces
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def make_mesh_from_verts_and_faces(verts, faces, convex_props):
"""Creates a new mesh object from provided vertices and faces and their properties."""
new_mesh = bpy.data.meshes.new(convex_props['name'])
new_bm = bmesh.new()
# MAKE VERTICES
_mesh.bm_make_vertices(new_bm, verts)
# MAKE FACES
_mesh.bm_make_faces(new_bm, faces, [])
new_bm.to_mesh(new_mesh)
new_mesh.update()
new_bm.free()
# Add the mesh as an object into the scene with this utility module.
new_object = bpy_object_utils.object_data_add(bpy.context, new_mesh)
new_object = set_collider_props(new_object, convex_props)
new_object.location = convex_props['location']
new_object.rotation_euler = convex_props['rotation']
return new_object
示例3: create_mesh_object
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
mesh = bpy.data.meshes.new(name)
mesh.from_pydata(verts, edges, faces)
mesh.update()
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)
示例4: execute
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def execute(self, context):
verts_loc, faces = add_box(self.width,
self.height,
self.depth,
)
mesh = bpy.data.meshes.new("Box")
bm = bmesh.new()
for v_co in verts_loc:
bm.verts.new(v_co)
bm.verts.ensure_lookup_table()
for f_idx in faces:
bm.faces.new([bm.verts[i] for i in f_idx])
bm.to_mesh(mesh)
mesh.update()
# add the mesh as an object into the scene with this utility module
from bpy_extras import object_utils
object_utils.object_data_add(context, mesh, operator=self)
return {'FINISHED'}
示例5: execute
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def execute(self, context):
if self.mode == 'EXT_INT':
extra_helper = (self.abso_major_rad - self.abso_minor_rad) * 0.5
self.major_radius = self.abso_minor_rad + extra_helper
self.minor_radius = extra_helper
verts_loc, faces = add_torus(self.major_radius,
self.minor_radius,
self.major_segments,
self.minor_segments)
mesh = bpy.data.meshes.new(data_("Torus"))
mesh.vertices.add(len(verts_loc) // 3)
nbr_loops = len(faces)
nbr_polys = nbr_loops // 4
mesh.loops.add(nbr_loops)
mesh.polygons.add(nbr_polys)
mesh.vertices.foreach_set("co", verts_loc)
mesh.polygons.foreach_set("loop_start", range(0, nbr_loops, 4))
mesh.polygons.foreach_set("loop_total", (4,) * nbr_polys)
mesh.loops.foreach_set("vertex_index", faces)
mesh.update()
object_utils.object_data_add(context, mesh, operator=self)
return {'FINISHED'}
示例6: execute
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def execute(self, context):
if self.mode == 'EXT_INT':
extra_helper = (self.abso_major_rad - self.abso_minor_rad) * 0.5
self.major_radius = self.abso_minor_rad + extra_helper
self.minor_radius = extra_helper
verts_loc, faces = add_torus(self.major_radius,
self.minor_radius,
self.major_segments,
self.minor_segments)
mesh = bpy.data.meshes.new(data_("Torus"))
mesh.vertices.add(len(verts_loc) // 3)
nbr_loops = len(faces)
nbr_polys = nbr_loops // 4
mesh.loops.add(nbr_loops)
mesh.polygons.add(nbr_polys)
mesh.vertices.foreach_set("co", verts_loc)
mesh.polygons.foreach_set("loop_start", range(0, nbr_loops, 4))
mesh.polygons.foreach_set("loop_total", (4,) * nbr_polys)
mesh.loops.foreach_set("vertex_index", faces)
if self.generate_uvs:
add_uvs(mesh, self.minor_segments, self.major_segments)
mesh.update()
object_utils.object_data_add(context, mesh, operator=self)
return {'FINISHED'}
示例7: execute
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def execute(self, context):
mesh = bpy.data.meshes.new("wSphere")
wD = mesh.wData
wD.sBase = self.base
wD.rad_1 = self.radius
wD.seg_1 = self.segments
wD.seg_2 = self.rings
wD.seg_3 = self.divisions
wD.inn = self.tris
wD.smo = self.smoothed
wD.wType = 'WSPHERE'
mesh.from_pydata(*update_WSphere(wD))
mesh.update()
object_utils.object_data_add(context, mesh, operator=None)
bpy.ops.object.shade_smooth()
context.object.data.use_auto_smooth = True
context.object.data.auto_smooth_angle = 1.0
return {'FINISHED'}
# create UI panel
示例8: execute
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def execute(self, context):
mesh = bpy.data.meshes.new("wTube")
wD = mesh.wData
wD.rad_1 = self.radius_out
wD.rad_2 = self.radius_in
wD.siz_z = self.height
wD.inn = self.use_inner
wD.seg_1 = self.seg_perimeter
wD.seg_2 = self.seg_radius
wD.seg_3 = self.seg_height
wD.sec_f = self.sector_from
wD.sec_t = self.sector_to
wD.cent = self.centered
wD.smo = self.smoothed
wD.wType = 'WTUBE'
mesh.from_pydata(*update_WTube(wD))
mesh.update()
object_utils.object_data_add(context, mesh, operator=None)
bpy.ops.object.shade_smooth()
context.object.data.use_auto_smooth = True
context.object.data.auto_smooth_angle = 1.0
return {'FINISHED'}
# create UI panel
示例9: execute
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def execute(self, context):
mesh = bpy.data.meshes.new("wTorus")
wD = mesh.wData
wD.rad_1 = self.radius_main
wD.rad_2 = self.radius_minor
wD.seg_1 = self.seg_main
wD.seg_2 = self.seg_minor
wD.sec_f = self.sec_from
wD.sec_t = self.sec_to
wD.smo = self.smoothed
wD.wType = 'WTORUS'
mesh.from_pydata(*update_WTorus(wD))
mesh.update()
object_utils.object_data_add(context, mesh, operator=None)
bpy.ops.object.shade_smooth()
context.object.data.use_auto_smooth = True
context.object.data.auto_smooth_angle = 1.0
return {'FINISHED'}
# create UI panel
示例10: execute
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def execute(self, context):
mesh = bpy.data.meshes.new("wCone")
wD = mesh.wData
wD.rad_1 = self.radius_main
wD.rad_2 = self.radius_top
wD.siz_z = self.height
wD.seg_1 = self.seg_perimeter
wD.seg_2 = self.seg_height
wD.seg_3 = self.seg_radius
wD.cent = self.centered
wD.smo = True
wD.wType = 'WCONE'
mesh.from_pydata(*update_WCone(wD))
mesh.update()
object_utils.object_data_add(context, mesh, operator=None)
bpy.ops.object.shade_smooth()
context.object.data.use_auto_smooth = True
context.object.data.auto_smooth_angle = 1.0
return {'FINISHED'}
# create UI panel
示例11: create_assembly
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def create_assembly(self):
"""
This creates the basic structure for an assembly.
This must be called first when creating an assembly from a script.
"""
bpy.ops.object.select_all(action='DESELECT')
obj_parent = utils.create_single_vertex("New Assembly")
obj_parent.location = (0,0,0)
obj_parent.mv.type = 'BPASSEMBLY'
# verts = [(0, 0, 0)]
# mesh = bpy.data.meshes.new("Base Point")
# bm = bmesh.new()
# for v_co in verts:
# bm.verts.new(v_co)
# bm.to_mesh(mesh)
# mesh.update()
# obj_base = object_utils.object_data_add(bpy.context,mesh)
# obj_parent = obj_base.object
# obj_parent.location = (0,0,0)
# obj_parent.mv.type = 'BPASSEMBLY'
# obj_parent.mv.name_object = 'New Assembly'
bpy.ops.object.empty_add()
obj_x = bpy.context.active_object
obj_x.name = "VPDIMX"
obj_x.location = (0,0,0)
obj_x.mv.type = 'VPDIMX'
obj_x.lock_location[1] = True
obj_x.lock_location[2] = True
obj_x.parent = obj_parent
bpy.ops.object.empty_add()
obj_y = bpy.context.active_object
obj_y.name = "VPDIMY"
obj_y.location = (0,0,0)
obj_y.mv.type = 'VPDIMY'
obj_y.lock_location[0] = True
obj_y.lock_location[2] = True
obj_y.parent = obj_parent
bpy.ops.object.empty_add()
obj_z = bpy.context.active_object
obj_z.name = "VPDIMZ"
obj_z.location = (0,0,0)
obj_z.mv.type = 'VPDIMZ'
obj_z.lock_location[0] = True
obj_z.lock_location[1] = True
obj_z.parent = obj_parent
self.obj_bp = obj_parent
self.obj_x = obj_x
self.obj_y = obj_y
self.obj_z = obj_z
obj_x.location.x = unit.inch(10)
obj_y.location.y = unit.inch(10)
obj_z.location.z = unit.inch(10)
self.set_object_names()
示例12: reload_paths
# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import object_data_add [as 别名]
def reload_paths(o):
oname = "cam_path_" + o.name
s = bpy.context.scene
# for o in s.objects:
ob = None
old_pathmesh = None
if oname in s.objects:
old_pathmesh = s.objects[oname].data
ob = s.objects[oname]
picklepath = getCachePath(o) + '.pickle'
f = open(picklepath, 'rb')
d = pickle.load(f)
f.close()
'''
passed=False
while not passed:
try:
f=open(picklepath,'rb')
d=pickle.load(f)
f.close()
passed=True
except:
print('sleep')
time.sleep(1)
'''
o.warnings = d['warnings']
o.duration = d['duration']
verts = d['path']
edges = []
for a in range(0, len(verts) - 1):
edges.append((a, a + 1))
oname = "cam_path_" + o.name
mesh = bpy.data.meshes.new(oname)
mesh.name = oname
mesh.from_pydata(verts, edges, [])
if oname in s.objects:
s.objects[oname].data = mesh
else:
object_utils.object_data_add(bpy.context, mesh, operator=None)
ob = bpy.context.active_object
ob.name = oname
ob = s.objects[oname]
ob.location = (0, 0, 0)
o.path_object_name = oname
o.changed = False
if old_pathmesh != None:
bpy.data.meshes.remove(old_pathmesh)