当前位置: 首页>>代码示例>>Python>>正文


Python object_utils.object_data_add方法代码示例

本文整理汇总了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 
开发者ID:WiresoulStudio,项目名称:W_Mesh_28x,代码行数:27,代码来源:W_Screw.py

示例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 
开发者ID:SCSSoftware,项目名称:BlenderTools,代码行数:24,代码来源:object.py

示例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) 
开发者ID:WiresoulStudio,项目名称:Wonder_Mesh,代码行数:11,代码来源:gen_func.py

示例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'} 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:28,代码来源:operator_mesh_add.py

示例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'} 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:32,代码来源:add_mesh_torus.py

示例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'} 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:36,代码来源:add_mesh_torus.py

示例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 
开发者ID:WiresoulStudio,项目名称:W_Mesh_28x,代码行数:28,代码来源:W_Sphere.py

示例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 
开发者ID:WiresoulStudio,项目名称:W_Mesh_28x,代码行数:32,代码来源:W_Tube.py

示例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 
开发者ID:WiresoulStudio,项目名称:W_Mesh_28x,代码行数:28,代码来源:W_Torus.py

示例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 
开发者ID:WiresoulStudio,项目名称:W_Mesh_28x,代码行数:29,代码来源:W_Cone.py

示例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() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:62,代码来源:fd_types.py

示例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) 
开发者ID:vilemduha,项目名称:blendercam,代码行数:54,代码来源:utils.py


注:本文中的bpy_extras.object_utils.object_data_add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。