當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。