Last active
September 16, 2016 09:47
-
-
Save dskjal/7efcc568738ae93c7a74a322f2c20668 to your computer and use it in GitHub Desktop.
プロパティシェルフにショートカットプロパティを用意するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
from bpy.props import * | |
bl_info = { | |
"name" : "My Properties", | |
"author" : "", | |
"version" : (0,1), | |
"blender" : (2, 77, 0), | |
"location" : "", | |
"description" : "", | |
"warning" : "", | |
"wiki_url" : "", | |
"tracker_url" : "", | |
"category" : "UI" | |
} | |
class UI(bpy.types.Panel): | |
bl_label = "my panel" | |
bl_space_type = "VIEW_3D" | |
bl_region_type = "UI" | |
def draw(self, context): | |
layout = self.layout | |
active = context.scene.objects.active | |
layout.prop(active,'show_wire') | |
for m in active.modifiers: | |
if m.type == "SUBSURF": | |
layout.prop(m, 'show_viewport',text=m.name) | |
layout.prop(m, 'levels') | |
if active.active_material: | |
layout.prop(active.active_material, "diffuse_color") | |
layout.prop(context.scene.cycles,"preview_samples") | |
layout.operator("my.backtodefault") | |
class BackToDefaultButton(bpy.types.Operator): | |
bl_idname = "my.backtodefault" | |
bl_label = "デフォルトに戻す" | |
def execute(self, context): | |
active = context.scene.objects.active | |
active.show_wire = False | |
hasSubsurf = False | |
for m in active.modifiers: | |
if m.type == "SUBSURF": | |
m.show_viewport = True | |
m.levels = 2 | |
hasSubsurf = True | |
if not hasSubsurf: | |
active.modifiers.new("SubSurf", type='SUBSURF') | |
active.modifiers['SubSurf'].levels = 2 | |
if not active.active_material: | |
mat = bpy.data.materials.new("Default Material") | |
active.active_material = mat | |
active.active_material.diffuse_color = (1,1,1) | |
context.scene.cycles.preview_samples = 32 | |
return{'FINISHED'} | |
def register(): | |
bpy.utils.register_module(__name__) | |
def unregister(): | |
bpy.utils.unregister_module(__name__) | |
if __name__ == "__main__": | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment