Exemplo n.º 1
0
    def execute(self, context): 
        
        addon_key = __package__.split(".")[0]    
        panel_prefs = context.user_preferences.addons[addon_key].preferences
 
        settings_write(self) # custom props  

        selected = bpy.context.selected_objects        

        for obj in selected:

            if self.tp_select_rename == False:


                if self.tp_sel == "tp_01":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern= "*_box_shaded", extend=self.tp_extend)           

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(pattern="*_box_shadeless", extend=self.tp_extend)      

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_box_wired", extend=self.tp_extend)   

                elif self.tp_sel == "tp_02":
                    
                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_grid_shaded", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(pattern="*_grid_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_grid_wired", extend=self.tp_extend)

                elif self.tp_sel == "tp_03":
                    
                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_circle_shaded", extend=self.tp_extend)
          
                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(pattern="*_circle_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_circle_wired", extend=self.tp_extend)

                elif self.tp_sel == "tp_04":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_tube_shaded", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(pattern="*_tube_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_tube_wired", extend=self.tp_extend)

                elif self.tp_sel == "tp_05":
                    
                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_cone_shaded", extend=self.tp_extend) 

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(pattern="*_cone_shadeless", extend=self.tp_extend) 

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_cone_wired", extend=self.tp_extend) 

                elif self.tp_sel == "tp_06":
                    
                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_sphere_shaded", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(pattern="*_sphere_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_sphere_wired", extend=self.tp_extend)

                elif self.tp_sel == "tp_07":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_ico_shaded", extend=self.tp_extend)            

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(pattern="*_ico_shadeless", extend=self.tp_extend)    

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_ico_wired", extend=self.tp_extend)    

                elif self.tp_sel == "tp_08":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_torus_shaded", extend=self.tp_extend)
                    
                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(pattern="*_torus_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_torus_wired", extend=self.tp_extend)

            
            else:

                bpy.ops.object.select_pattern(pattern = self.tp_select_custom, extend=self.tp_extend)  


            # display: link
            for i in range(self.tp_link):         
                bpy.ops.object.make_links_data(type='OBDATA')
                
            
        return {'FINISHED'}     
Exemplo n.º 2
0
    def execute(self, context):

        settings_write(self) # custom props
        
        selected = bpy.context.selected_objects

        # set 3d cursor
        bpy.ops.view3d.snap_cursor_to_selected()
        # store 3d cursor
        v3d = context.space_data
        if v3d.type == 'VIEW_3D':
                        
            rv3d = v3d.region_3d
            current_cloc = v3d.cursor_location.xyz         
            #v3d.cursor_location = ()
        
            for obj in selected:
                # add source to name list
                name_list.append(obj.name)                                       
                
                # add geometry and first rename 
                if self.tp_geom_sphere == "tp_add_sph":
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')                
                    add_sphere(self.bsph_seg, self.bsph_rig, self.bsph_siz, self.bsph_rota_x, self.bsph_rota_y, self.bsph_rota_z)           
                    bpy.context.object.name = obj.name + "_shaded_sphere"
                    bpy.context.object.data.name = obj.name + "_shaded_sphere"
                    
                    # add new object to dummy name list
                    new_object_name = obj.name + "_shaded_sphere"
                    dummy_list.append(new_object_name) 

                else:            
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')  
                    add_ico(self.bico_div, self.bico_siz, self.bico_rota_x, self.bico_rota_y, self.bico_rota_z)
                    bpy.context.object.name = obj.name + "_shaded_ico"
                    bpy.context.object.data.name = obj.name + "_shaded_ico"

                    # add new object to dummy name list
                    new_object_name = obj.name + "_shaded_ico"
                    dummy_list.append(new_object_name) 



                active = bpy.context.active_object             
                
                # add material with enabled object color
                for i in range(self.sph_mat):            
                    mat_name = [obj.name]
                    mat = bpy.data.materials.new(obj.name)

                    if len(active.data.materials):
                        active.data.materials[0] = mat
                    else:
                        active.data.materials.append(mat)

                    if bpy.context.scene.render.engine == 'CYCLES':
                        bpy.context.object.active_material.diffuse_color = (self.sph_cyclcolor)
                    else:
                        bpy.context.object.active_material.use_object_color = True
                        bpy.context.object.color = (self.sph_color)


                # copy data from to new object
                active.location = obj.location
                
                for i in range(self.sphere_dim):
                    active.dimensions = obj.dimensions

                    # apply scale                    
                    for i in range(self.sphere_dim_apply):
                        bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)

                for i in range(self.sphere_rota):
                    active.rotation_euler = obj.rotation_euler
                                                 
                # reload 3d cursor
                v3d.cursor_location = current_cloc 
                
                # select objects in lists
                bpy.data.objects[obj.name].select = True                  
                bpy.data.objects[new_object_name].select = True                                  

                # place origin
                bpy.ops.object.origin_set(type='ORIGIN_CURSOR')

                # deselect source
                bpy.data.objects[obj.name].select = False   

                # set origin 
                if self.sphere_origin == "tp_o0":
                    pass
                
                if self.sphere_origin == "tp_o1":                                
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')                      
               
                if self.sphere_origin == "tp_o2":
                    bpy.ops.tp_ops.bbox_origin_minus_z()     
     
                if self.sphere_origin == "tp_o3":                                
                    bpy.ops.tp_ops.bbox_origin_plus_z()   
                            
                # display: xray
                for i in range(self.sphere_xray):
                    bpy.context.object.show_x_ray = True

                # display: draw all edges
                for i in range(self.sphere_edges):
                    bpy.ops.tp_ops.wire_on()
               
                # stay shaded
                if self.sphere_meshtype == "tp_00":
                    pass 
                                    
                # create shadeless
                if self.sphere_meshtype == "tp_01":
                    bpy.context.object.draw_type = 'WIRE'

                    # second rename 
                    if self.tp_geom_sphere == "tp_add_sph":          
                        bpy.context.object.name = obj.name + "_shadless_sphere"
                        bpy.context.object.data.name = obj.name + "_shadless_sphere"

                    if self.tp_geom_sphere == "tp_add_ico":              
                        bpy.context.object.name =  obj.name +"_shadless_ico"
                        bpy.context.object.data.name = obj.name + "_shadless_ico"                                
                    
                # display: smooth
                for i in range(self.sphere_smooth):
                    bpy.ops.object.shade_smooth()

                # create wired 
                if self.sphere_meshtype == "tp_02": 
                    bpy.ops.object.editmode_toggle()
                    bpy.ops.mesh.select_all(action='SELECT')
                    bpy.ops.mesh.delete(type='ONLY_FACE')
                    bpy.ops.object.editmode_toggle()
          
                    # third rename 
                    if self.tp_geom_sphere == "tp_add_sph":          
                        bpy.context.object.name = obj.name + "_wire_sphere"
                        bpy.context.object.data.name = obj.name + "_wire_sphere"

                    if self.tp_geom_sphere == "tp_add_ico":              
                        bpy.context.object.name = obj.name + "_wire_ico"
                        bpy.context.object.data.name = obj.name + "_wire_ico"
                                    

        # set widget orientation
        if self.sph_get_local == "tp_w0":
            pass
        elif self.sph_get_local == "tp_w1":
            bpy.ops.tp_ops.space_local()               
        else:
            bpy.ops.tp_ops.space_global()   
            
        return {'FINISHED'}
Exemplo n.º 3
0
    def execute(self, context):

        settings_write(self)  # custom props

        selected = bpy.context.selected_objects

        # set 3d cursor
        bpy.ops.view3d.snap_cursor_to_selected()

        # store 3d cursor
        v3d = context.space_data
        if v3d.type == 'VIEW_3D':

            rv3d = v3d.region_3d
            current_cloc = v3d.cursor_location.xyz
            #v3d.cursor_location = ()

            for obj in selected:
                # add source to name list
                name_list.append(obj.name)

                # first rename
                if self.tp_rename_tubes == False:

                    # add geometry and first rename
                    if self.tp_geom_tube == "tp_add_cyl":
                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
                                                  center='BOUNDS')
                        add_cyl(self.bcyl_res, self.bcyl_rad, self.bcyl_dep,
                                self.tube_fill, self.bcyl_rota_x,
                                self.bcyl_rota_y, self.bcyl_rota_z)
                        bpy.context.object.name = self.bcyl_prefix + obj.name + self.bcyl_shaded_suffix
                        bpy.context.object.data.name = self.bcyl_prefix + obj.name + self.bcyl_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.bcyl_prefix + obj.name + self.bcyl_shaded_suffix
                        dummy_list.append(new_object_name)

                    if self.tp_geom_tube == "tp_add_cone":
                        bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS')
                        add_cone(self.bcon_res, self.bcon_res1, self.bcon_res2,
                                 self.bcon_depth, self.tube_fill,
                                 self.bcon_rota_x, self.bcon_rota_y,
                                 self.bcon_rota_z)
                        bpy.context.object.name = self.bcon_prefix + obj.name + self.bcon_shaded_suffix
                        bpy.context.object.data.name = self.bcon_prefix + obj.name + self.bcon_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.bcon_prefix + obj.name + self.bcon_shaded_suffix
                        dummy_list.append(new_object_name)

                    if self.tp_geom_tube == "tp_add_circ":
                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
                                                  center='BOUNDS')
                        add_circ(self.bcirc_res, self.bcirc_rad,
                                 self.tube_fill, self.bcirc_rota_x,
                                 self.bcirc_rota_y, self.bcirc_rota_z)
                        bpy.context.object.name = self.bcirc_prefix + obj.name + self.bcirc_shaded_suffix
                        bpy.context.object.data.name = self.bcirc_prefix + obj.name + self.bcirc_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.bcirc_prefix + obj.name + self.bcirc_shaded_suffix
                        dummy_list.append(new_object_name)

                    if self.tp_geom_tube == "tp_add_tor":
                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
                                                  center='BOUNDS')
                        add_torus(self.btor_seg1, self.btor_seg2,
                                  self.btor_siz1, self.btor_siz2,
                                  self.btor_rota_x, self.btor_rota_y,
                                  self.btor_rota_z)
                        bpy.context.object.name = self.btor_prefix + obj.name + self.btor_shaded_suffix
                        bpy.context.object.data.name = self.bcyl_prefix + obj.name + self.btor_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.bcyl_prefix + obj.name + self.btor_shaded_suffix
                        dummy_list.append(new_object_name)

                else:

                    # add geometry and first rename
                    if self.tp_geom_tube == "tp_add_cyl":
                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
                                                  center='BOUNDS')
                        add_cyl(self.bcyl_res, self.bcyl_rad, self.bcyl_dep,
                                self.tube_fill, self.bcyl_rota_x,
                                self.bcyl_rota_y, self.bcyl_rota_z)
                        bpy.context.object.name = self.bcyl_prefix + self.bcyl_name + self.bcyl_shaded_suffix
                        bpy.context.object.data.name = self.bcyl_prefix + self.bcyl_name + self.bcyl_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.bcyl_prefix + self.bcyl_name + self.bcyl_shaded_suffix
                        dummy_list.append(new_object_name)

                    if self.tp_geom_tube == "tp_add_cone":
                        bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS')
                        add_cone(self.bcon_res, self.bcon_res1, self.bcon_res2,
                                 self.bcon_depth, self.tube_fill,
                                 self.bcon_rota_x, self.bcon_rota_y,
                                 self.bcon_rota_z)
                        bpy.context.object.name = self.bcon_prefix + self.bcon_name + self.bcon_shaded_suffix
                        bpy.context.object.data.name = self.bcon_prefix + self.bcon_name + self.bcon_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.bcon_prefix + self.bcon_name + self.bcon_shaded_suffix
                        dummy_list.append(new_object_name)

                    if self.tp_geom_tube == "tp_add_circ":
                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
                                                  center='BOUNDS')
                        add_circ(self.bcirc_res, self.bcirc_rad,
                                 self.tube_fill, self.bcirc_rota_x,
                                 self.bcirc_rota_y, self.bcirc_rota_z)
                        bpy.context.object.name = self.bcirc_prefix + self.bcirc_name + self.bcirc_shaded_suffix
                        bpy.context.object.data.name = self.bcirc_prefix + self.bcirc_name + self.bcirc_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.bcirc_prefix + self.bcirc_name + self.bcirc_shaded_suffix
                        dummy_list.append(new_object_name)

                    if self.tp_geom_tube == "tp_add_tor":
                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
                                                  center='BOUNDS')
                        add_torus(self.btor_seg1, self.btor_seg2,
                                  self.btor_siz1, self.btor_siz2,
                                  self.btor_rota_x, self.btor_rota_y,
                                  self.btor_rota_z)
                        bpy.context.object.name = self.btor_prefix + self.btor_name + self.btor_shaded_suffix
                        bpy.context.object.data.name = self.bcyl_prefix + self.btor_name + self.btor_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.bcyl_prefix + self.btor_name + self.btor_shaded_suffix
                        dummy_list.append(new_object_name)

                active = bpy.context.active_object

                # add material with enabled object color
                for i in range(self.tube_mat):
                    mat_name = [obj.name]
                    mat = bpy.data.materials.new(obj.name)

                    if len(active.data.materials):
                        active.data.materials[0] = mat
                    else:
                        active.data.materials.append(mat)

                    if bpy.context.scene.render.engine == 'CYCLES':
                        bpy.context.object.active_material.diffuse_color = (
                            self.tube_cyclcolor)
                    else:
                        bpy.context.object.active_material.use_object_color = True
                        bpy.context.object.color = (self.tube_color)

                # copy data from to new object
                for i in range(self.tube_dim):
                    active.dimensions = obj.dimensions

                    # apply scale
                    for i in range(self.tube_dim_apply):
                        bpy.ops.object.transform_apply(location=False,
                                                       rotation=False,
                                                       scale=True)

                active.location = obj.location

                for i in range(self.tube_rota):
                    active.rotation_euler = obj.rotation_euler

                # reload 3d cursor
                v3d.cursor_location = current_cloc

                # select objects in lists
                bpy.data.objects[obj.name].select = True
                bpy.data.objects[new_object_name].select = True

                # place origin
                bpy.ops.object.origin_set(type='ORIGIN_CURSOR')

                # deselect source
                bpy.data.objects[obj.name].select = False

                # set origin
                if self.tube_origin == "tp_o0":
                    pass

                if self.tube_origin == "tp_o1":
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')

                if self.tube_origin == "tp_o2":
                    bpy.ops.tp_ops.bbox_origin_minus_z()

                if self.tube_origin == "tp_o3":
                    bpy.ops.tp_ops.bbox_origin_plus_z()

                # display: xray
                for i in range(self.tube_xray):
                    bpy.context.object.show_x_ray = True

                # display: draw all edges
                for i in range(self.tube_edges):
                    bpy.ops.tp_ops.wire_on()

                # stay shaded
                if self.tube_meshtype == "tp_00":
                    pass

                # create shadeless
                if self.tube_meshtype == "tp_01":
                    bpy.context.object.draw_type = 'WIRE'

                    # second rename
                    if self.tp_rename_tubes == False:

                        if self.tp_geom_tube == "tp_add_cyl":
                            bpy.context.object.name = self.bcyl_prefix + obj.name + self.bcyl_shadeless_suffix
                            bpy.context.object.data.name = self.bcyl_prefix + obj.name + self.bcyl_shadeless_suffix

                        if self.tp_geom_tube == "tp_add_cone":
                            bpy.context.object.name = self.bcon_prefix + obj.name + self.bcon_shadeless_suffix
                            bpy.context.object.data.name = self.bcon_prefix + obj.name + self.bcon_shadeless_suffix

                        if self.tp_geom_tube == "tp_add_circ":
                            bpy.context.object.name = self.bcirc_prefix + obj.name + self.bcirc_shadeless_suffix
                            bpy.context.object.data.name = self.bcirc_prefix + obj.name + self.bcirc_shadeless_suffix

                        if self.tp_geom_tube == "tp_add_torus":
                            bpy.context.object.name = self.btor_prefix + obj.name + self.btor_shadeless_suffix
                            bpy.context.object.data.name = self.bcyl_prefix + obj.name + self.btor_shadeless_suffix

                    else:

                        if self.tp_geom_tube == "tp_add_cyl":
                            bpy.context.object.name = self.bcyl_prefix + self.bcyl_name + self.bcyl_shadeless_suffix
                            bpy.context.object.data.name = self.bcyl_prefix + self.bcyl_name + self.bcyl_shadeless_suffix

                        if self.tp_geom_tube == "tp_add_cone":
                            bpy.context.object.name = self.bcon_prefix + self.bcon_name + self.bcon_shadeless_suffix
                            bpy.context.object.data.name = self.bcon_prefix + self.bcon_name + self.bcon_shadeless_suffix

                        if self.tp_geom_tube == "tp_add_circ":
                            bpy.context.object.name = self.bcirc_prefix + self.bcirc_name + self.bcirc_shadeless_suffix
                            bpy.context.object.data.name = self.bcirc_prefix + self.bcirc_name + self.bcirc_shadeless_suffix

                        if self.tp_geom_tube == "tp_add_torus":
                            bpy.context.object.name = self.btor_prefix + self.btor_name + self.btor_shadeless_suffix
                            bpy.context.object.data.name = self.bcyl_prefix + self.btor_name + self.btor_shadeless_suffix

                # display: smooth
                for i in range(self.tube_smooth):
                    bpy.ops.object.shade_smooth()

                # create extrusion
                for i in range(self.bvl_extrude_use):
                    func_extrude(self.bvl_extrude_offset)

                # create pipe
                if self.tp_geom_tube == "tp_add_cyl" or self.tp_geom_tube == "tp_add_cone":
                    if self.tube_fill == "NGON":
                        for i in range(self.bvl_pipe_use):
                            func_pipe(self.bvl_pipe_offset)

                # create bevel
                for i in range(self.bvl_bevel_use):
                    func_bevel(self.bvl_offset, self.bvl_segment,
                               self.bvl_profile, self.bvl_select_all,
                               self.bvl_verts_use)

                # create wired
                if self.tube_meshtype == "tp_02":
                    bpy.ops.object.editmode_toggle()
                    bpy.ops.mesh.select_all(action='SELECT')
                    bpy.ops.mesh.delete(type='ONLY_FACE')
                    bpy.ops.object.editmode_toggle()

                    # third rename
                    if self.tp_rename_tubes == False:

                        if self.tp_geom_tube == "tp_add_cyl":
                            bpy.context.object.name = self.bcyl_prefix + obj.name + self.bcyl_wired_suffix
                            bpy.context.object.data.name = self.bcyl_prefix + obj.name + self.bcyl_wired_suffix

                        if self.tp_geom_tube == "tp_add_cone":
                            bpy.context.object.name = self.bcon_prefix + obj.name + self.bcon_wired_suffix
                            bpy.context.object.data.name = self.bcon_prefix + obj.name + self.bcon_wired_suffix

                        if self.tp_geom_tube == "tp_add_circ":
                            bpy.context.object.name = self.bcirc_prefix + obj.name + self.bcirc_wired_suffix
                            bpy.context.object.data.name = self.bcirc_prefix + obj.name + self.bcirc_wired_suffix

                        if self.tp_geom_tube == "tp_add_torus":
                            bpy.context.object.name = self.btor_prefix + obj.name + self.btor_wired_suffix
                            bpy.context.object.data.name = self.bcyl_prefix + obj.name + self.btor_wired_suffix

                    else:

                        if self.tp_geom_tube == "tp_add_cyl":
                            bpy.context.object.name = self.bcyl_prefix + self.bcyl_name + self.bcyl_wired_suffix
                            bpy.context.object.data.name = self.bcyl_prefix + self.bcyl_name + self.bcyl_wired_suffix

                        if self.tp_geom_tube == "tp_add_cone":
                            bpy.context.object.name = self.bcon_prefix + self.bcon_name + self.bcon_wired_suffix
                            bpy.context.object.data.name = self.bcon_prefix + self.bcon_name + self.bcon_wired_suffix

                        if self.tp_geom_tube == "tp_add_circ":
                            bpy.context.object.name = self.bcirc_prefix + self.bcirc_name + self.bcirc_wired_suffix
                            bpy.context.object.data.name = self.bcirc_prefix + self.bcirc_name + self.bcirc_wired_suffix

                        if self.tp_geom_tube == "tp_add_torus":
                            bpy.context.object.name = self.btor_prefix + self.btor_name + self.btor_wired_suffix
                            bpy.context.object.data.name = self.bcyl_prefix + self.btor_name + self.btor_wired_suffix

        # set widget orientation
        if self.tube_get_local == "tp_w0":
            pass
        elif self.tube_get_local == "tp_w1":
            bpy.ops.tp_ops.space_local()
        else:
            bpy.ops.tp_ops.space_global()

        return {'FINISHED'}
Exemplo n.º 4
0
    def execute(self, context):

        settings_write(self)  # custom props

        selected = bpy.context.selected_objects

        for obj in selected:

            if self.tp_sel == "tp_01":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_box",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_box",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_box",
                                                  extend=self.tp_extend)

            elif self.tp_sel == "tp_02":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_grid",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_grid",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_grid",
                                                  extend=self.tp_extend)

            elif self.tp_sel == "tp_03":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_circle",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_circle",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_circle",
                                                  extend=self.tp_extend)

            elif self.tp_sel == "tp_04":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_tube",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_tube",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_tube",
                                                  extend=self.tp_extend)

            elif self.tp_sel == "tp_05":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_cone",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_cone",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_cone",
                                                  extend=self.tp_extend)

            elif self.tp_sel == "tp_06":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_sphere",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_sphere",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_sphere",
                                                  extend=self.tp_extend)

            elif self.tp_sel == "tp_07":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_ico",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_ico",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_ico",
                                                  extend=self.tp_extend)

            elif self.tp_sel == "tp_08":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_torus",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_torus",
                                                  extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_torus",
                                                  extend=self.tp_extend)

            # display: link
            for i in range(self.tp_link):
                bpy.ops.object.make_links_data(type='OBDATA')

        return {'FINISHED'}
Exemplo n.º 5
0
    def execute(self, context):

        settings_write(self) # custom props
        
        selected = bpy.context.selected_objects

        # set 3d cursor
        bpy.ops.view3d.snap_cursor_to_selected()
        # store 3d cursor
        v3d = context.space_data
        if v3d.type == 'VIEW_3D':
                        
            rv3d = v3d.region_3d
            current_cloc = v3d.cursor_location.xyz         

            for obj in selected:
                # add source to name list
                name_list.append(obj.name)                                       
                
                # add geometry and first rename 
                if self.tp_geom_sphere == "tp_add_sph":
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')                
                    add_sphere(self.bsph_seg, self.bsph_rig, self.bsph_siz, self.bsph_rota_x, self.bsph_rota_y, self.bsph_rota_z)           

                    # first rename 
                    if self.tp_rename_spheres == True:
                       
                        bpy.context.object.name = self.bsph_prefix + obj.name + self.bsph_shaded_suffix
                        bpy.context.object.data.name = self.bsph_prefix + obj.name + self.bsph_shaded_suffix
                    
                        # add new object to dummy name list
                        new_object_name = self.bsph_prefix + obj.name + self.bsph_shaded_suffix
                        dummy_list.append(new_object_name) 

                    else:
                       
                        bpy.context.object.name = self.bsph_prefix + self.bsph_name + self.bsph_shaded_suffix
                        bpy.context.object.data.name = self.bsph_prefix + self.bsph_name + self.bsph_shaded_suffix
                        
                        # add new object to dummy name list
                        new_object_name = self.bsph_prefix + self.bsph_name + self.bsph_shaded_suffix
                        dummy_list.append(new_object_name) 

                else:            
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')  
                    add_ico(self.bico_div, self.bico_siz, self.bico_rota_x, self.bico_rota_y, self.bico_rota_z)
                    
                    # first rename 
                    if self.tp_rename_spheres == True: 
                                           
                        bpy.context.object.name =  self.bico_prefix + obj.name + self.bico_shaded_suffix
                        bpy.context.object.data.name = self.bico_prefix + obj.name + self.bico_shaded_suffix   

                        # add new object to dummy name list
                        new_object_name = self.bico_prefix + obj.name + self.bico_shaded_suffix  
                        dummy_list.append(new_object_name) 

                    else: 
                                           
                        bpy.context.object.name =  self.bico_prefix + self.bico_name + self.bico_shaded_suffix
                        bpy.context.object.data.name = self.bico_prefix + self.bico_name + self.bico_shaded_suffix   

                        # add new object to dummy name list
                        new_object_name = self.bico_prefix + self.bico_name + self.bico_shaded_suffix 
                        dummy_list.append(new_object_name) 



                active = bpy.context.active_object             
                
                # add material with enabled object color
                for i in range(self.sph_mat):            
                    mat_name = [obj.name]
                    mat = bpy.data.materials.new(obj.name)

                    if len(active.data.materials):
                        active.data.materials[0] = mat
                    else:
                        active.data.materials.append(mat)

                    if bpy.context.scene.render.engine == 'CYCLES':
                        bpy.context.object.active_material.diffuse_color = (self.sph_cyclcolor)
                    else:
                        bpy.context.object.active_material.use_object_color = True
                        bpy.context.object.color = (self.sph_color)



                # copy data from to new object
                active.location = obj.location
                
                for i in range(self.sphere_dim):
                    active.dimensions = obj.dimensions

                    # apply scale                    
                    for i in range(self.sphere_dim_apply):
                        bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)

                for i in range(self.sphere_rota):
                    active.rotation_euler = obj.rotation_euler
                                                 
                # reload 3d cursor
                v3d.cursor_location = current_cloc 
                
                # select objects in lists
                bpy.data.objects[obj.name].select = True                  
                bpy.data.objects[new_object_name].select = True                                  

                # place origin
                bpy.ops.object.origin_set(type='ORIGIN_CURSOR')

                # deselect source
                bpy.data.objects[obj.name].select = False   

                # set origin 
                if self.sphere_origin == "tp_o0":
                    pass
                
                if self.sphere_origin == "tp_o1":                                
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')                      
               
                if self.sphere_origin == "tp_o2":
                    bpy.ops.tp_ops.bbox_origin_minus_z()     
     
                if self.sphere_origin == "tp_o3":                                
                    bpy.ops.tp_ops.bbox_origin_plus_z()   
                            
                # display: xray
                for i in range(self.sphere_xray):
                    bpy.context.object.show_x_ray = True

                # display: draw all edges
                for i in range(self.sphere_edges):
                    bpy.ops.tp_ops.wire_on()
               
                # stay shaded
                if self.sphere_meshtype == "tp_00":
                    pass 
                                    
                # create shadeless
                if self.sphere_meshtype == "tp_01":
                    bpy.context.object.draw_type = 'WIRE'

                    # second rename 
                    if self.tp_rename_spheres == True:

                        if self.tp_geom_sphere == "tp_add_sph":          
                            bpy.context.object.name = self.bsph_prefix + obj.name + self.bsph_shadeless_suffix
                            bpy.context.object.data.name = self.bsph_prefix + obj.name + self.bsph_shadeless_suffix

                        if self.tp_geom_sphere == "tp_add_ico":              
                            bpy.context.object.name =  self.bico_prefix + obj.name + self.bico_shadeless_suffix
                            bpy.context.object.data.name = self.bico_prefix + obj.name + self.bico_shadeless_suffix                               

                    else:

                        if self.tp_geom_sphere == "tp_add_sph":          
                            bpy.context.object.name = self.bsph_prefix + self.bsph_name + self.bsph_shadeless_suffix
                            bpy.context.object.data.name = self.bsph_prefix + self.bsph_name + self.bsph_shadeless_suffix

                        if self.tp_geom_sphere == "tp_add_ico":              
                            bpy.context.object.name =  self.bico_prefix + self.bico_name + self.bico_shadeless_suffix
                            bpy.context.object.data.name = self.bico_prefix + self.bico_name + self.bico_shadeless_suffix    

                    
                # display: smooth
                for i in range(self.sphere_smooth):
                    bpy.ops.object.shade_smooth()

                # create wired 
                if self.sphere_meshtype == "tp_02": 
                    bpy.ops.object.editmode_toggle()
                    bpy.ops.mesh.select_all(action='SELECT')
                    bpy.ops.mesh.delete(type='ONLY_FACE')
                    bpy.ops.object.editmode_toggle()
          
                    # third rename
                    if self.tp_rename_spheres == True:
                        
                        if self.tp_geom_sphere == "tp_add_sph":          
                            bpy.context.object.name = self.bsph_prefix + obj.name + self.bsph_wired_suffix
                            bpy.context.object.data.name = self.bsph_prefix + obj.name + self.bsph_wired_suffix

                        if self.tp_geom_sphere == "tp_add_ico":              
                            bpy.context.object.name = self.bico_prefix + obj.name + self.bico_wired_suffix
                            bpy.context.object.data.name = self.bico_prefix + obj.name + self.bico_wired_suffix
                                    
                    else:

                        if self.tp_geom_sphere == "tp_add_sph":          
                            bpy.context.object.name = self.bsph_prefix+ self.bsph_name + self.bsph_wired_suffix
                            bpy.context.object.data.name = self.bsph_prefix+ self.bsph_name + self.bsph_wired_suffix

                        if self.tp_geom_sphere == "tp_add_ico":              
                            bpy.context.object.name = self.bico_prefix + self.bico_name + self.bico_wired_suffix
                            bpy.context.object.data.name = self.bico_prefix + self.bico_name + self.bico_wired_suffix


        # set widget orientation
        if self.sph_get_local == "tp_w0":
            pass
        elif self.sph_get_local == "tp_w1":
            bpy.ops.tp_ops.space_local()               
        else:
            bpy.ops.tp_ops.space_global()   
            
        return {'FINISHED'}
Exemplo n.º 6
0
    def execute(self, context): 
    
        settings_write(self) # custom props        
        
        #grid_name = "_grid"     
        #box_name = "_box"         
       
        selected = bpy.context.selected_objects

        # set 3d cursor     
        bpy.ops.view3d.snap_cursor_to_selected()      
                   
        # store 3d cursor
        v3d = context.space_data
        if v3d.type == 'VIEW_3D':
                        
            rv3d = v3d.region_3d
            current_cloc = v3d.cursor_location.xyz         
            #v3d.cursor_location = ()
        
            for obj in selected:
                # add source to name list
                name_list.append(obj.name) 

                # add geometry
                if self.tp_geom_box == "tp_bb1":
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')                
                    build_grid(self.subX, self.subY, self.subR, self.bgrid_rota_x, self.bgrid_rota_y, self.bgrid_rota_z)                                              

                    if self.tp_rename_boxes == False:

                        bpy.context.object.name = self.grid_prefix + obj.name + self.grid_shaded_suffix
                        bpy.context.object.data.name = self.grid_prefix + obj.name + self.grid_shaded_suffix  
                        
                        # add new object to dummy name list
                        new_object_name = self.grid_prefix + obj.name + self.grid_shaded_suffix
                        dummy_list.append(new_object_name) 
                      
                    else:

                        bpy.context.object.name = self.grid_prefix + self.grid_name + self.grid_shaded_suffix
                        bpy.context.object.data.name = self.grid_prefix + self.grid_name + self.grid_shaded_suffix  
                        
                        # add new object to dummy name list
                        new_object_name = self.grid_prefix + self.grid_name + self.grid_shaded_suffix
                        dummy_list.append(new_object_name) 


                else:
                    
                    # check if local view
                    if context.space_data.local_view is not None:
                        
                        # jump out from local view
                        #bpy.ops.view3d.localview()

                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')                                                   
                       
                        # add default cube primitiv
                        build_cube(self.bcube_rad, self.bcube_rota_x, self.bcube_rota_y, self.bcube_rota_z)

                    else:
                                        
                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')    
                        
                        # add defined mesh cube 
                        build_box(self, context)
                     
   
                    if self.tp_rename_boxes == False:
 
                        bpy.context.object.name = self.box_prefix + obj.name + self.box_shaded_suffix
                        bpy.context.object.data.name = self.box_prefix + obj.name + self.box_shaded_suffix
 
                        # add new object to dummy name list
                        new_object_name = self.box_prefix + obj.name + self.box_shaded_suffix
                        dummy_list.append(new_object_name) 

                    else:

                        bpy.context.object.name = self.box_prefix + self.box_name + self.box_shaded_suffix
                        bpy.context.object.data.name = self.box_prefix + self.box_name + self.box_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.box_prefix + self.box_name + self.box_shaded_suffix
                        dummy_list.append(new_object_name) 
                        

                active = bpy.context.active_object             
                
                # add material with enabled object color
                for i in range(self.box_mat):            
                    mat_name = [obj.name]
                    mat = bpy.data.materials.new(obj.name)

                    if len(active.data.materials):
                        active.data.materials[0] = mat
                    else:
                        active.data.materials.append(mat)

                    if bpy.context.scene.render.engine == 'CYCLES':
                        bpy.context.object.active_material.diffuse_color = (self.box_cyclcolor)
                    else:
                        bpy.context.object.active_material.use_object_color = True
                        bpy.context.object.color = (self.box_color)


                # copy data from to new object
                active.location = obj.location

                for i in range(self.box_dim):
                    active.dimensions = obj.dimensions
                
                    # apply scale                    
                    for i in range(self.box_dim_apply):
                        bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)

                for i in range(self.box_rota):
                    active.rotation_euler = obj.rotation_euler
                
                # reload 3d cursor
                v3d.cursor_location = current_cloc 
                
                # select objects in lists
                bpy.data.objects[obj.name].select = True                  
                bpy.data.objects[new_object_name].select = True                                  

                # place origin
                bpy.ops.object.origin_set(type='ORIGIN_CURSOR')

                # deselect source
                bpy.data.objects[obj.name].select = False    

                # set origin 
                if self.box_origin == "tp_o0":
                    pass
                
                if self.box_origin == "tp_o1":                                                
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')                      
               
                if self.box_origin == "tp_o2":
                    bpy.ops.tp_ops.bbox_origin_minus_z()     
     
                if self.box_origin == "tp_o3":                                
                    bpy.ops.tp_ops.bbox_origin_plus_z()   

             
                if self.tp_geom_box == "tp_bb2":

                    # subdivide
                    for i in range(self.box_subdiv_use): 
                        func_subdivide(self.box_subdiv, self.box_subdiv_smooth)  
     
                if self.tp_geom_box == "tp_bb1":

                    # to sphere
                    for i in range(self.box_sphere_use): 
                        func_sphere_cube(self.box_sphere)   
 
                # display: xray
                for i in range(self.box_xray):
                    bpy.context.object.show_x_ray = True
          
                # display: draw all edges
                for i in range(self.box_edges):
                    bpy.context.object.show_wire = True
                    bpy.context.object.show_all_edges = True                                   

                # stay shaded
                if self.box_meshtype == "tp_00":
                    pass

                # SHADLESS MESH
                if self.box_meshtype == "tp_01":
                    bpy.context.object.draw_type = 'WIRE'

                    # second rename
                    if self.tp_rename_boxes == False:
 
                        if self.tp_geom_box == "tp_bb1":               
                            bpy.context.object.name = self.grid_prefix + obj.name + self.grid_shadeless_suffix
                            bpy.context.object.data.name = self.grid_prefix + obj.name + self.grid_shadeless_suffix            
                        else:          
                            bpy.context.object.name = self.box_prefix + obj.name + self.box_shadeless_suffix
                            bpy.context.object.data.name = self.box_prefix + obj.name + self.box_shadeless_suffix 

                    else:
                        
                        if self.tp_geom_box == "tp_bb1":               
                            bpy.context.object.name = self.grid_prefix + self.grid_name + self.grid_shadeless_suffix
                            bpy.context.object.data.name = self.grid_prefix + self.grid_name + self.grid_shadeless_suffix             
                        else:          
                            bpy.context.object.name = self.box_prefix + self.box_name + self.box_shadeless_suffix
                            bpy.context.object.data.name = self.box_prefix + self.box_name + self.box_shadeless_suffix  



                # display: smooth
                for i in range(self.box_smooth):                 
                    bpy.ops.object.shade_smooth()
                
                # create bevel
                for i in range(self.box_bevel_use):                                   
                    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
                    func_bevel_cube(self.box_offset, self.box_segment, self.box_profile, self.box_verts_use)
                    
                # WIRED MESH
                if self.box_meshtype == "tp_02":            
                    bpy.ops.object.editmode_toggle()
                    bpy.ops.mesh.select_all(action='SELECT')
                    bpy.ops.mesh.delete(type='ONLY_FACE')
                    bpy.ops.object.editmode_toggle()
     
                    # third rename
                    if self.tp_rename_boxes == False:

                        if self.tp_geom_box == "tp_bb1":                
                            bpy.context.object.name = self.grid_prefix + obj.name + self.grid_wired_suffix  
                            bpy.context.object.data.name = self.grid_prefix + obj.name + self.grid_wired_suffix            
                        else:            
                            bpy.context.object.name = self.box_prefix + obj.name + self.box_wired_suffix
                            bpy.context.object.data.name = self.box_prefix + obj.name + self.box_wired_suffix 
                        
                    else:

                        if self.tp_geom_box == "tp_bb1":                
                            bpy.context.object.name = self.grid_prefix + self.grid_name + self.grid_wired_suffix
                            bpy.context.object.data.name = self.grid_prefix + self.grid_name + self.grid_wired_suffix            
                        else:            
                            bpy.context.object.name = self.box_prefix + self.box_name + self.box_wired_suffix
                            bpy.context.object.data.name = self.box_prefix + self.box_name + self.box_wired_suffix

         
                # fix normals
                bpy.ops.tp_ops.rec_normals()



        # set widget orientation
        if self.box_get_local == "tp_w0":
            pass
        elif self.box_get_local == "tp_w1":
            bpy.ops.tp_ops.space_local()               
        else:
            bpy.ops.tp_ops.space_global()         
             
        return {'FINISHED'}                        
Exemplo n.º 7
0
    def execute(self, context):

        addon_key = __package__.split(".")[0]
        panel_prefs = context.user_preferences.addons[addon_key].preferences

        settings_write(self)  # custom props

        selected = bpy.context.selected_objects

        for obj in selected:

            if self.tp_select_rename == False:

                if self.tp_sel == "tp_01":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_box_shaded",
                                                      extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(
                            pattern="*_box_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_box_wired",
                                                      extend=self.tp_extend)

                elif self.tp_sel == "tp_02":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_grid_shaded",
                                                      extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(
                            pattern="*_grid_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_grid_wired",
                                                      extend=self.tp_extend)

                elif self.tp_sel == "tp_03":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(
                            pattern="*_circle_shaded", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(
                            pattern="*_circle_shadeless",
                            extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_circle_wired",
                                                      extend=self.tp_extend)

                elif self.tp_sel == "tp_04":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_tube_shaded",
                                                      extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(
                            pattern="*_tube_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_tube_wired",
                                                      extend=self.tp_extend)

                elif self.tp_sel == "tp_05":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_cone_shaded",
                                                      extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(
                            pattern="*_cone_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_cone_wired",
                                                      extend=self.tp_extend)

                elif self.tp_sel == "tp_06":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(
                            pattern="*_sphere_shaded", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(
                            pattern="*_sphere_shadeless",
                            extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_sphere_wired",
                                                      extend=self.tp_extend)

                elif self.tp_sel == "tp_07":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_ico_shaded",
                                                      extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(
                            pattern="*_ico_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_ico_wired",
                                                      extend=self.tp_extend)

                elif self.tp_sel == "tp_08":

                    if self.tp_sel_meshtype == "tp_01":
                        bpy.ops.object.select_pattern(pattern="*_torus_shaded",
                                                      extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_02":
                        bpy.ops.object.select_pattern(
                            pattern="*_torus_shadeless", extend=self.tp_extend)

                    elif self.tp_sel_meshtype == "tp_03":
                        bpy.ops.object.select_pattern(pattern="*_torus_wired",
                                                      extend=self.tp_extend)

            else:

                bpy.ops.object.select_pattern(pattern=self.tp_select_custom,
                                              extend=self.tp_extend)

            # display: link
            for i in range(self.tp_link):
                bpy.ops.object.make_links_data(type='OBDATA')

        return {'FINISHED'}
Exemplo n.º 8
0
    def execute(self, context):

        settings_write(self)  # custom props

        #grid_name = "_grid"
        #box_name = "_box"

        selected = bpy.context.selected_objects

        # set 3d cursor
        bpy.ops.view3d.snap_cursor_to_selected()

        # store 3d cursor
        v3d = context.space_data
        if v3d.type == 'VIEW_3D':

            rv3d = v3d.region_3d
            current_cloc = v3d.cursor_location.xyz
            #v3d.cursor_location = ()

            for obj in selected:
                # add source to name list
                name_list.append(obj.name)

                # add geometry
                if self.tp_geom_box == "tp_bb1":
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
                                              center='BOUNDS')
                    build_grid(self.subX, self.subY, self.subR,
                               self.bgrid_rota_x, self.bgrid_rota_y,
                               self.bgrid_rota_z)

                    if self.tp_rename_boxes == False:

                        bpy.context.object.name = self.grid_prefix + obj.name + self.grid_shaded_suffix
                        bpy.context.object.data.name = self.grid_prefix + obj.name + self.grid_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.grid_prefix + obj.name + self.grid_shaded_suffix
                        dummy_list.append(new_object_name)

                    else:

                        bpy.context.object.name = self.grid_prefix + self.grid_name + self.grid_shaded_suffix
                        bpy.context.object.data.name = self.grid_prefix + self.grid_name + self.grid_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.grid_prefix + self.grid_name + self.grid_shaded_suffix
                        dummy_list.append(new_object_name)

                else:

                    # check if local view
                    if context.space_data.local_view is not None:

                        # jump out from local view
                        #bpy.ops.view3d.localview()

                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
                                                  center='BOUNDS')

                        # add default cube primitiv
                        build_cube(self.bcube_rad, self.bcube_rota_x,
                                   self.bcube_rota_y, self.bcube_rota_z)

                    else:

                        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',
                                                  center='BOUNDS')

                        # add defined mesh cube
                        build_box(self, context)

                    if self.tp_rename_boxes == False:

                        bpy.context.object.name = self.box_prefix + obj.name + self.box_shaded_suffix
                        bpy.context.object.data.name = self.box_prefix + obj.name + self.box_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.box_prefix + obj.name + self.box_shaded_suffix
                        dummy_list.append(new_object_name)

                    else:

                        bpy.context.object.name = self.box_prefix + self.box_name + self.box_shaded_suffix
                        bpy.context.object.data.name = self.box_prefix + self.box_name + self.box_shaded_suffix

                        # add new object to dummy name list
                        new_object_name = self.box_prefix + self.box_name + self.box_shaded_suffix
                        dummy_list.append(new_object_name)

                active = bpy.context.active_object

                # add material with enabled object color
                for i in range(self.box_mat):
                    mat_name = [obj.name]
                    mat = bpy.data.materials.new(obj.name)

                    if len(active.data.materials):
                        active.data.materials[0] = mat
                    else:
                        active.data.materials.append(mat)

                    if bpy.context.scene.render.engine == 'CYCLES':
                        bpy.context.object.active_material.diffuse_color = (
                            self.box_cyclcolor)
                    else:
                        bpy.context.object.active_material.use_object_color = True
                        bpy.context.object.color = (self.box_color)

                # copy data from to new object
                active.location = obj.location

                for i in range(self.box_dim):
                    active.dimensions = obj.dimensions

                    # apply scale
                    for i in range(self.box_dim_apply):
                        bpy.ops.object.transform_apply(location=False,
                                                       rotation=False,
                                                       scale=True)

                for i in range(self.box_rota):
                    active.rotation_euler = obj.rotation_euler

                # reload 3d cursor
                v3d.cursor_location = current_cloc

                # select objects in lists
                bpy.data.objects[obj.name].select = True
                bpy.data.objects[new_object_name].select = True

                # place origin
                bpy.ops.object.origin_set(type='ORIGIN_CURSOR')

                # deselect source
                bpy.data.objects[obj.name].select = False

                # set origin
                if self.box_origin == "tp_o0":
                    pass

                if self.box_origin == "tp_o1":
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')

                if self.box_origin == "tp_o2":
                    bpy.ops.tp_ops.bbox_origin_minus_z()

                if self.box_origin == "tp_o3":
                    bpy.ops.tp_ops.bbox_origin_plus_z()

                if self.tp_geom_box == "tp_bb2":

                    # subdivide
                    for i in range(self.box_subdiv_use):
                        func_subdivide(self.box_subdiv, self.box_subdiv_smooth)

                if self.tp_geom_box == "tp_bb1":

                    # to sphere
                    for i in range(self.box_sphere_use):
                        func_sphere_cube(self.box_sphere)

                # display: xray
                for i in range(self.box_xray):
                    bpy.context.object.show_x_ray = True

                # display: draw all edges
                for i in range(self.box_edges):
                    bpy.context.object.show_wire = True
                    bpy.context.object.show_all_edges = True

                # stay shaded
                if self.box_meshtype == "tp_00":
                    pass

                # SHADLESS MESH
                if self.box_meshtype == "tp_01":
                    bpy.context.object.draw_type = 'WIRE'

                    # second rename
                    if self.tp_rename_boxes == False:

                        if self.tp_geom_box == "tp_bb1":
                            bpy.context.object.name = self.grid_prefix + obj.name + self.grid_shadeless_suffix
                            bpy.context.object.data.name = self.grid_prefix + obj.name + self.grid_shadeless_suffix
                        else:
                            bpy.context.object.name = self.box_prefix + obj.name + self.box_shadeless_suffix
                            bpy.context.object.data.name = self.box_prefix + obj.name + self.box_shadeless_suffix

                    else:

                        if self.tp_geom_box == "tp_bb1":
                            bpy.context.object.name = self.grid_prefix + self.grid_name + self.grid_shadeless_suffix
                            bpy.context.object.data.name = self.grid_prefix + self.grid_name + self.grid_shadeless_suffix
                        else:
                            bpy.context.object.name = self.box_prefix + self.box_name + self.box_shadeless_suffix
                            bpy.context.object.data.name = self.box_prefix + self.box_name + self.box_shadeless_suffix

                # display: smooth
                for i in range(self.box_smooth):
                    bpy.ops.object.shade_smooth()

                # create bevel
                for i in range(self.box_bevel_use):
                    bpy.ops.object.transform_apply(location=False,
                                                   rotation=False,
                                                   scale=True)
                    func_bevel_cube(self.box_offset, self.box_segment,
                                    self.box_profile, self.box_verts_use)

                # WIRED MESH
                if self.box_meshtype == "tp_02":
                    bpy.ops.object.editmode_toggle()
                    bpy.ops.mesh.select_all(action='SELECT')
                    bpy.ops.mesh.delete(type='ONLY_FACE')
                    bpy.ops.object.editmode_toggle()

                    # third rename
                    if self.tp_rename_boxes == False:

                        if self.tp_geom_box == "tp_bb1":
                            bpy.context.object.name = self.grid_prefix + obj.name + self.grid_wired_suffix
                            bpy.context.object.data.name = self.grid_prefix + obj.name + self.grid_wired_suffix
                        else:
                            bpy.context.object.name = self.box_prefix + obj.name + self.box_wired_suffix
                            bpy.context.object.data.name = self.box_prefix + obj.name + self.box_wired_suffix

                    else:

                        if self.tp_geom_box == "tp_bb1":
                            bpy.context.object.name = self.grid_prefix + self.grid_name + self.grid_wired_suffix
                            bpy.context.object.data.name = self.grid_prefix + self.grid_name + self.grid_wired_suffix
                        else:
                            bpy.context.object.name = self.box_prefix + self.box_name + self.box_wired_suffix
                            bpy.context.object.data.name = self.box_prefix + self.box_name + self.box_wired_suffix

                # fix normals
                bpy.ops.tp_ops.rec_normals()

        # set widget orientation
        if self.box_get_local == "tp_w0":
            pass
        elif self.box_get_local == "tp_w1":
            bpy.ops.tp_ops.space_local()
        else:
            bpy.ops.tp_ops.space_global()

        return {'FINISHED'}
Exemplo n.º 9
0
    def execute(self, context): 
        
        settings_write(self) # custom props  

        selected = bpy.context.selected_objects        

        for obj in selected:

            if self.tp_sel == "tp_01":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern= "*_shaded_box", extend=self.tp_extend)           

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_box", extend=self.tp_extend)      

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_box", extend=self.tp_extend)   

            elif self.tp_sel == "tp_02":
                
                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_grid", extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_grid", extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_grid", extend=self.tp_extend)

            elif self.tp_sel == "tp_03":
                
                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_circle", extend=self.tp_extend)
      
                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_circle", extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_circle", extend=self.tp_extend)

            elif self.tp_sel == "tp_04":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_tube", extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_tube", extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_tube", extend=self.tp_extend)

            elif self.tp_sel == "tp_05":
                
                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_cone", extend=self.tp_extend) 

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_cone", extend=self.tp_extend) 

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_cone", extend=self.tp_extend) 

            elif self.tp_sel == "tp_06":
                
                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_sphere", extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_sphere", extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_sphere", extend=self.tp_extend)

            elif self.tp_sel == "tp_07":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_ico", extend=self.tp_extend)            

                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_ico", extend=self.tp_extend)    

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_ico", extend=self.tp_extend)    

            elif self.tp_sel == "tp_08":

                if self.tp_sel_meshtype == "tp_01":
                    bpy.ops.object.select_pattern(pattern="*_shaded_torus", extend=self.tp_extend)
                
                elif self.tp_sel_meshtype == "tp_02":
                    bpy.ops.object.select_pattern(pattern="*_shadeless_torus", extend=self.tp_extend)

                elif self.tp_sel_meshtype == "tp_03":
                    bpy.ops.object.select_pattern(pattern="*_wire_torus", extend=self.tp_extend)


            # display: link
            for i in range(self.tp_link):         
                bpy.ops.object.make_links_data(type='OBDATA')
                
            
        return {'FINISHED'}     
Exemplo n.º 10
0
    def execute(self, context):

        settings_write(self) # custom props
        
        selected = bpy.context.selected_objects
        
        # set 3d cursor
        bpy.ops.view3d.snap_cursor_to_selected() 
        
        # store 3d cursor
        v3d = context.space_data
        if v3d.type == 'VIEW_3D':
                        
            rv3d = v3d.region_3d
            current_cloc = v3d.cursor_location.xyz         
            #v3d.cursor_location = ()
        
            for obj in selected:
                # add source to name list
                name_list.append(obj.name) 
                                      
                # add geometry and first rename 
                if self.tp_geom_tube == "tp_add_cyl":
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')                
                    add_cyl(self.bcyl_res, self.bcyl_rad, self.bcyl_dep, self.tube_fill, self.bcyl_rota_x, self.bcyl_rota_y, self.bcyl_rota_z)            
                    bpy.context.object.name = obj.name + "_shaded_tube"
                    bpy.context.object.data.name = obj.name + "_shaded_tube"
                
                    # add new object to dummy name list
                    new_object_name = obj.name + "_shaded_tube"
                    dummy_list.append(new_object_name) 

                if self.tp_geom_tube == "tp_add_cone":              
                    bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS')
                    add_cone(self.bcon_res, self.bcon_res1, self.bcon_res2, self.bcon_depth, self.tube_fill, self.bcon_rota_x, self.bcon_rota_y, self.bcon_rota_z)
                    bpy.context.object.name = obj.name + "_shaded_cone"
                    bpy.context.object.data.name = obj.name + "_shaded_cone"

                    # add new object to dummy name list
                    new_object_name = obj.name + "_shaded_cone"
                    dummy_list.append(new_object_name) 

                if self.tp_geom_tube == "tp_add_circ":   
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')                
                    add_circ(self.bcirc_res, self.bcirc_rad, self.tube_fill, self.bcirc_rota_x, self.bcirc_rota_y, self.bcirc_rota_z)
                    bpy.context.object.name = obj.name + "_shaded_circle"
                    bpy.context.object.data.name = obj.name + "_shaded_circle"
                
                    # add new object to dummy name list
                    new_object_name = "_shaded_circle"
                    dummy_list.append(new_object_name) 

                if self.tp_geom_tube == "tp_add_tor":
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')  
                    add_torus(self.btor_seg1, self.btor_seg2, self.btor_siz1, self.btor_siz2, self.btor_rota_x, self.btor_rota_y, self.btor_rota_z)
                    bpy.context.object.name = obj.name + "_shaded_torus"
                    bpy.context.object.data.name = obj.name + "_shaded_torus"

                    # add new object to dummy name list
                    new_object_name = obj.name + "_shaded_torus"
                    dummy_list.append(new_object_name) 
                


                active = bpy.context.active_object             
                
                # add material with enabled object color
                for i in range(self.tube_mat):            
                    mat_name = [obj.name]
                    mat = bpy.data.materials.new(obj.name)

                    if len(active.data.materials):
                        active.data.materials[0] = mat
                    else:
                        active.data.materials.append(mat)

                    if bpy.context.scene.render.engine == 'CYCLES':
                        bpy.context.object.active_material.diffuse_color = (self.tube_cyclcolor)
                    else:
                        bpy.context.object.active_material.use_object_color = True
                        bpy.context.object.color = (self.tube_color)


                # copy data from to new object                
                for i in range(self.tube_dim):                    
                    active.dimensions = obj.dimensions

                    # apply scale
                    for i in range(self.tube_dim_apply):
                        bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)

                active.location = obj.location

                for i in range(self.tube_rota):   
                    active.rotation_euler = obj.rotation_euler
                                                 
                # reload 3d cursor
                v3d.cursor_location = current_cloc 
                
                # select objects in lists
                bpy.data.objects[obj.name].select = True                  
                bpy.data.objects[new_object_name].select = True                                  

                # place origin
                bpy.ops.object.origin_set(type='ORIGIN_CURSOR')

                # deselect source
                bpy.data.objects[obj.name].select = False    

                # set origin 
                if self.tube_origin == "tp_o0":
                    pass
                
                if self.tube_origin == "tp_o1":                                
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')                      
               
                if self.tube_origin == "tp_o2":
                    bpy.ops.tp_ops.bbox_origin_minus_z()     
     
                if self.tube_origin == "tp_o3":                                
                    bpy.ops.tp_ops.bbox_origin_plus_z()   
                            
                # display: xray
                for i in range(self.tube_xray):
                    bpy.context.object.show_x_ray = True

                # display: draw all edges
                for i in range(self.tube_edges):
                    bpy.ops.tp_ops.wire_on()
               
                # stay shaded
                if self.tube_meshtype == "tp_00":
                    pass 
                                    
                # create shadeless
                if self.tube_meshtype == "tp_01":
                    bpy.context.object.draw_type = 'WIRE'

                    # second rename
                    if self.tp_geom_tube == "tp_add_cyl":
                        bpy.context.object.name = obj.name + "_shadless_tube"
                        bpy.context.object.data.name = obj.name + "_shadless_tube"
                    
                    if self.tp_geom_tube == "tp_add_cone":              
                        bpy.context.object.name = obj.name + "_shadless_cone"
                        bpy.context.object.data.name = obj.name + "_shadless_cone"

                    if self.tp_geom_tube == "tp_add_circ": 
                        bpy.context.object.name = obj.name + "_shadless_circle"
                        bpy.context.object.data.name = obj.name + "_shadless_circle"

                    if self.tp_geom_tube == "tp_add_torus":
                        bpy.context.object.name = obj.name + "_shadless_torus"
                        bpy.context.object.data.name = obj.name + "_shadless_torus"


                # display: smooth
                for i in range(self.tube_smooth):
                    bpy.ops.object.shade_smooth()

                # create extrusion
                for i in range(self.bvl_extrude_use):                                                    
                    func_extrude(self.bvl_extrude_offset)
                            
                # create pipe                     
                if self.tp_geom_tube == "tp_add_cyl" or self.tp_geom_tube == "tp_add_cone":
                    if self.tube_fill == "NGON": 
                        for i in range(self.bvl_pipe_use): 
                            func_pipe(self.bvl_pipe_offset)
                                                                                  
                # create bevel            
                for i in range(self.bvl_bevel_use):                                    
                    func_bevel(self.bvl_offset, self.bvl_segment, self.bvl_profile, self.bvl_select_all, self.bvl_verts_use)                  
                                         
                # create wired 
                if self.tube_meshtype == "tp_02": 
                    bpy.ops.object.editmode_toggle()
                    bpy.ops.mesh.select_all(action='SELECT')
                    bpy.ops.mesh.delete(type='ONLY_FACE')
                    bpy.ops.object.editmode_toggle()
          
                    # third rename
                    if self.tp_geom_tube == "tp_add_cyl":
                        bpy.context.object.name = obj.name + "_wire_tube"
                        bpy.context.object.data.name = obj.name + "_wire_tube"
                    
                    if self.tp_geom_tube == "tp_add_cone":              
                        bpy.context.object.name = obj.name + "_wire_cone"
                        bpy.context.object.data.name = obj.name + "_wire_cone"

                    if self.tp_geom_tube == "tp_add_circ": 
                        bpy.context.object.name = obj.name + "_wire_circle"
                        bpy.context.object.data.name = obj.name + "_wire_circle"

                    if self.tp_geom_tube == "tp_add_torus":
                        bpy.context.object.name = obj.name + "_wire_torus"
                        bpy.context.object.data.name = obj.name + "_wire_torus"

        # set widget orientation
        if self.tube_get_local == "tp_w0":
            pass
        elif self.tube_get_local == "tp_w1":
            bpy.ops.tp_ops.space_local()               
        else:
            bpy.ops.tp_ops.space_global()   
            
        return {'FINISHED'}