Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###!/usr/bin/env python
- bl_info = {
- "name": "AUTO_S",
- "author": "AlxMcKonst",
- "version": (1, 6, 0),
- "blender": (2, 77, 0),
- "location": "Mesh",
- "description": "My Collection automate scripts",
- "warning": "WIP",
- "wiki_url": "",
- "tracker_url": "",
- "category": "UI"}
- # -*- coding: utf-8 -*-
- import bpy
- from bpy.types import Panel, Menu
- p = "c:\\MY_SCRIPTS\\Auto\\Auto\\"
- #-----> """TEST""
- class TEST(bpy.types.Operator):
- """Test"""
- bl_idname = "scene.test"
- bl_label = "TEST MENU"
- bl_options = {"REGISTER", "UNDO"}
- nm = bpy.props.IntProperty(
- name="PITCH",
- description="111",
- default=0,
- min=0
- )
- def execute(self, context):
- imm = bpy.context.screen.areas[2].spaces[1].background_images
- d = []
- try:
- for i in range(10):
- d.append(imm[i])
- except IndexError:
- print(d)
- try:
- imy = bpy.context.screen.areas[3].spaces[0].background_images[self.nm]
- imx = bpy.context.screen.areas[3].spaces[0].background_images[self.nm]
- cly = bpy.context.screen.areas[2].spaces[0].cursor_location[1] #* 2.884052426250225
- clx = bpy.context.screen.areas[2].spaces[0].cursor_location[0]
- # bpy.ops.view3d.viewnumpad(type='TOP', align_active=False)
- imy.offset_y = cly
- imx.offset_x = clx
- except IndexError:
- self.nm = len(d)-1
- return {"FINISHED"}
- return {"FINISHED"}
- # rtrn = bpy.props.EmunProperty(
- # name = "000",
- # description = "000",
- # max = 3
- # )
- # def execute(self, context):
- # bpy.ops.view3d.view_orbit(angle=self.sptrn*0.1, type='ORBITLEFT')
- # from time import monotonic as mm
- # mm0 = int(mm())
- # i=1
- # while self.rtrn:
- # b=1
- # dt = int(mm())+1
- # val = dt-mm0
- # i = i+1
- # if i==1254*1000:
- # bpy.ops.view3d.view_orbit(angle=val*0.1, type='ORBITLEFT')
- # i=1
- # print (1)
- # mm0 = 20*int(mm())
- # for i in range(int(mm())):
- # dt = int(20*mm())+1
- # val = dt-mm0
- # print (val)
- # bpy.ops.view3d.view_orbit(angle=val*0.1, type='ORBITLEFT')
- #-----> """RotateObject(DUPLI)""
- class Robject(bpy.types.Operator):
- """Rotate&duble_object"""
- bl_idname = "scene.robject"
- bl_label = "Rotate & Duble Me"
- bl_options = {"REGISTER", "UNDO"}
- grad = bpy.props.IntProperty(
- name="copies",
- description="copies",
- default=2,
- min=2,
- max=8
- )
- arrc = bpy.props.BoolProperty(
- name="ArroundCursor",
- description="ArCrs",
- #default=0
- )
- dstp = bpy.props.BoolProperty(
- name="LinkStop",
- description="LnkStp",
- default=0
- )
- drot = bpy.props.BoolProperty(
- name="ORIENT",
- description="drotate",
- default=0
- )
- def execute(self, context):
- if self.arrc == 1:
- bpy.context.space_data.pivot_point = 'CURSOR'
- else:
- bpy.context.space_data.pivot_point = 'ACTIVE_ELEMENT'
- for i in range(self.grad):
- bpy.ops.object.duplicate_move_linked(OBJECT_OT_duplicate={"linked":True,
- "mode":'TRANSLATION'},
- TRANSFORM_OT_translate={"value":(0, 0, 0),
- "constraint_axis":(False, False, False),
- "constraint_orientation":'GLOBAL',
- "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SPHERE',
- "proportional_size":2.14359, "snap":False, "snap_target":'CLOSEST',
- "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0),
- "gpencil_strokes":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False})
- bpy.ops.transform.rotate(value=(360/self.grad)*0.017453292519943,
- axis=(0, 0, 1),
- constraint_axis=(False, False, True),
- constraint_orientation='GLOBAL' if self.drot == 0 else 'LOCAL',
- mirror=False, proportional='DISABLED',
- proportional_edit_falloff='SPHERE',
- proportional_size=2.14359, release_confirm=True
- )
- bpy.context.selected_objects
- bpy.ops.object.delete(use_global=False)
- # bpy.data.objects[self.robj.name].select = True
- # bpy.context.scene.objects.active = self.robj
- return {"FINISHED"}
- #-----> """Create_the_one_ring""
- class Crlwo(bpy.types.Operator):
- """create_the_one_ring
- _or_the_connection
- _of_the_two_rings_(bézier_curve)
- """
- bl_idname = "scene.crlwo"
- bl_label = "CrtCircle"
- bl_options = {"REGISTER", "UNDO"}
- bzc = bpy.props.FloatProperty(
- name="Indiameter",
- description="inner_diameter",
- default=1,
- min=0.0
- )
- bdc = bpy.props.FloatProperty(
- name="Diameter_prof",
- description="bevel_depth",
- default=1,
- min=0.0
- )
- lnc = bpy.props.BoolProperty(
- name="2Circle",
- description="2Circle",
- default=False
- )
- trcl = bpy.props.FloatProperty(
- name = "Move Circl 'X'",
- description = "TRANSFORM_OT_translate={"'value'":(self.trcl, 0, 0)",
- default = 1.07748
- )
- vwc = bpy.props.BoolProperty(
- name="Algin View",
- description="view_align",
- default=False
- )
- flc = bpy.props.BoolProperty(
- name = "FillCurve",
- description = "FllCrv",
- default = 1
- )
- cqv = bpy.props.BoolProperty(
- name = "quadro",
- description = "Q",
- default = 1,
- #options={'HIDDEN' if flc[1]['default']!=1 else 'ANIMATABLE'},
- update=None
- )
- def execute(self, context):
- s = self
- CdR = (s.bzc + s.bdc)/2
- # bpy.ops.script.python_file_run(filepath = p + "TranspON.py")
- if self.flc==0:
- bpy.ops.curve.primitive_bezier_circle_add(
- radius=CdR,
- view_align=s.vwc,
- enter_editmode=False,
- )
- bpy.context.object.data.fill_mode = 'FULL'
- bpy.context.object.data.bevel_depth = s.bdc / 2
- bpy.context.object.data.bevel_resolution = 16 #s.brc
- # leenk = s.lnc
- while s.lnc==True and self.flc==0:
- bpy.ops.object.duplicate_move_linked(OBJECT_OT_duplicate={"linked":True, "mode":'TRANSLATION'},
- TRANSFORM_OT_translate={"value":(s.trcl, 0, 0), "constraint_axis":(True, False, False),
- "constraint_orientation":'LOCAL', "mirror":False, "proportional":'DISABLED',
- "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False,
- "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0),
- "gpencil_strokes":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False})
- bpy.ops.transform.rotate(value=1.5708, axis=(0.397503, 0.917601, -2.2628e-007), constraint_axis=(True, False, False), constraint_orientation='LOCAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=6.11584, release_confirm=True)
- break
- if bpy.context.active_object.type == 'CURVE' and self.flc==1:
- bpy.context.object.data.fill_mode = 'FULL'
- bpy.context.object.data.bevel_depth = s.bdc/2
- if self.cqv !=1:
- bpy.context.object.data.bevel_resolution = 16 #s.brc
- else:
- bpy.context.object.data.bevel_resolution = 0
- return {"FINISHED"}
- #-----> """Props ops_Kursor"""
- class kurs(bpy.types.Operator):
- """Porps ops_Kursor"""
- bl_idname = "scene.kursor"
- bl_label = "Pos Kursor"
- bl_options = {"REGISTER", "UNDO"}
- kr1 = bpy.props.BoolProperty(name="To_selected", description="K1", default=0)
- kr2 = bpy.props.BoolProperty( name="point_align", description="K2", default=0)
- kNull = bpy.props.BoolProperty(name="0.0.0", description="0.0.0", default=1)
- defo = bpy.props.BoolProperty(name="reset", description="res", default=0)
- krpnt = bpy.props.BoolProperty(name="LOCpoint_to_kursor", description="pnt2krsr", default=0)
- def execute(self, context):
- if self.kr1 == 1:
- #Cur01(scale)
- bpy.ops.view3d.snap_cursor_to_selected()
- bpy.context.space_data.pivot_point = 'CURSOR'
- bpy.ops.object.orientationvariable(variable="GLOBAL")
- #Cur02(move)
- bpy.context.space_data.use_pivot_point_align = self.kr2
- if self.defo == 1:
- bpy.context.space_data.use_pivot_point_align = False
- bpy.context.space_data.pivot_point = 'ACTIVE_ELEMENT'
- bpy.context.space_data.transform_orientation = 'LOCAL'
- self.kr1=self.kr2=self.kNull=self.defo=0
- # self.kr1=0
- # self.kNull=0
- # self.defo=0
- if self.kNull == 1:
- bpy.context.scene.cursor_location.xyz = 0
- bpy.context.space_data.pivot_point = 'CURSOR'
- bpy.context.space_data.transform_orientation = 'GLOBAL'
- self.kr1=self.kr2=self.kNull=0
- if self.krpnt == 1:
- bpy.ops.view3d.snap_cursor_to_selected()
- bpy.ops.object.editmode_toggle()
- bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
- bpy.ops.object.editmode_toggle()
- self.krpnt = 0
- return {"FINISHED"}
- #-----> """dissolution"""
- class dissol(bpy.types.Operator):
- """dissolution"""
- bl_idname = "scene.dissol"
- bl_label = "dissolution"
- bl_options = {"REGISTER", "UNDO"}
- def execute(self, context):
- # bpy.ops.script.python_file_run(filepath = p + "Dsel_Vrtx_ches.py")
- bpy.ops.mesh.select_linked(delimit={'SEAM'})
- bpy.ops.mesh.select_nth()
- bpy.ops.mesh.dissolve_mode(use_verts=True)
- bpy.ops.mesh.select_linked(delimit={'SEAM'})
- bpy.ops.mesh.looptools_space()
- return {"FINISHED"}
- #-----> """Change active object"""
- class changobj(bpy.types.Operator):
- """Change active object"""
- bl_idname = "scene.changobj"
- bl_label = "Change_active_object"
- bl_options = {"REGISTER", "UNDO"}
- chl = bpy.props.BoolProperty(
- name="Set active object",
- description="chl",
- default=0
- )
- chlst = bpy.props.IntProperty(
- name="List active object",
- description="chlst",
- default=0,
- # min=-(len(bpy.context.selected_objects)),
- max=-1
- )
- # lo = bpy.selection_osc
- def execute(self, context):
- try:
- Ob = bpy.context.object.select
- except IndexError:
- print(No_Object)
- # if Ob == True:
- lo = bpy.context.selected_objects
- # bpy.context.object.show_name = False
- if self.chl==0 and self.chlst<len(lo)-1:
- try:
- bpy.context.scene.objects.active = bpy.data.objects[lo[self.chlst].name]
- # bpy.context.object.show_name = True
- except IndexError:
- bpy.context.scene.objects.active = bpy.data.objects[lo[-1].name]
- # bpy.context.object.show_name = True
- self.chl=0
- self.chlst=0
- # else:
- # bpy.context.scene.objects.active = bpy.data.objects[lo[0].name]
- if self.chl!=0:
- bpy.context.scene.objects.active = bpy.data.objects[lo[0].name]
- self.chl=0
- self.chlst=0
- # if self.chl !=0:
- # bpy.ops.script.python_file_run(filepath = p + "ChangeActiveObj.py")
- return {"FINISHED"}
- #-----> """Join 1 object (objects) to the active object"""
- class AplyJion(bpy.types.Operator):
- """Join 1 object (objects) to the active object"""
- bl_idname = "scene.apjion"
- bl_label = "aply_Join_locRot_Obj"
- bl_options = {"REGISTER", "UNDO"}
- CMs = bpy.props.BoolProperty(
- name="ORIGIN_CENTER_OF_MASS",
- description="CMs",
- default=0
- )
- def execute(self, context):
- obj = bpy.context.selected_objects
- obd = {i: obj[i] for i in range(len(obj))}
- def sel(SEL):
- import bmesh
- """Here second seleted all vertex"""
- bpy.ops.object.editmode_toggle()
- mesh = bmesh.from_edit_mesh(bpy.context.object.data)
- for v in mesh.verts:
- v.select = SEL
- for v in mesh.edges:
- v.select = SEL
- for v in mesh.faces:
- v.select = SEL
- ## trigger viewport update
- # bpy.context.scene.objects.active = bpy.context.scene.objects.active
- bpy.ops.object.editmode_toggle()
- # >> > d = {i: jh[i] for i in range(len(jh))}
- # >> > d
- # {0: bpy.data.objects['Cube.000'], 1: bpy.data.objects['Cube.003']}
- #
- # >> > jh[0]
- # bpy.data.objects['Cube.000']
- if len(obj) >= 2:
- sel(True)
- ## Here first object made is active
- bpy.context.scene.objects.active = obd[1]
- sel(False)
- # # bpy.ops.mesh.select_all(action='TOGGLE')
- # ## Selected acive seconde object
- bpy.context.scene.objects.active = obd[0]
- #
- # ## object.join
- bpy.ops.object.join()
- #
- # ## Edit mode del vertex
- bpy.ops.object.editmode_toggle()
- bpy.ops.mesh.delete(type='VERT')
- bpy.ops.object.editmode_toggle()
- bpy.context.object.name = obd[1].name
- if self.CMs == 1:
- bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS')
- #bpy.ops.script.python_file_run(filepath = p + "AplyJoinLoc.py")
- return {"FINISHED"}
- #-----> """Sculpt"""
- class SculptMyDint(bpy.types.Operator):
- """
- My prop for Sculpt(activate Dintopo)
- Get the name of the sculpture brush.
- Written to the variable "aname"
- Create a pattern brush in quotes
- Enter parametters
- """
- bl_idname = "scene.scdint"
- bl_label = "Sculpt_MyDintopo"
- bl_options = {"REGISTER", "UNDO"}
- myspec = bpy.props.BoolProperty(
- name="MY_SPEC",
- description="MSPC",
- default=0
- )
- def execute(self, context):
- # Get the name of the sculpture brush. Written to the variable "aname"
- #bpy.ops.script.python_file_run(filepath = p + "Sculpt_MyDint.py")
- aname = bpy.context.scene.tool_settings.sculpt.brush.name
- # Create a pattern brush in quotes
- B = "%s" % aname + ""
- # Put options sculpting
- bpy.context.scene.tool_settings.sculpt.detail_refine_method = 'SUBDIVIDE_COLLAPSE'
- bpy.context.scene.tool_settings.sculpt.detail_type_method = 'CONSTANT'
- bpy.context.scene.tool_settings.sculpt.use_symmetry_x = False
- bpy.context.scene.tool_settings.sculpt.use_symmetry_y = False
- bpy.context.scene.tool_settings.sculpt.use_symmetry_z = False
- bpy.data.brushes[B].use_frontface = True
- if self.myspec == 1:
- bpy.data.brushes[B].strength = 0.5
- bpy.data.brushes[B].auto_smooth_factor = 0.6
- bpy.context.scene.tool_settings.unified_paint_settings.size = 40
- bpy.context.scene.tool_settings.sculpt.constant_detail = 10
- md = bpy.context.mode
- if md == 'OBJECT':
- bpy.ops.sculpt.sculptmode_toggle()
- if bpy.context.sculpt_object.use_dynamic_topology_sculpting == False:
- bpy.ops.sculpt.dynamic_topology_toggle()
- if md == 'SCULPT' and self.myspec != 1:
- if bpy.context.sculpt_object.use_dynamic_topology_sculpting != False:
- bpy.ops.sculpt.dynamic_topology_toggle()
- bpy.ops.sculpt.sculptmode_toggle()
- return {"FINISHED"}
- #-----> """AutoRend+FS"""
- class OpsRenderLrs(bpy.types.Operator):
- """My Prop For Render & Render Layers, activate FS"""
- bl_idname = "scene.autorend"
- bl_label = "AutoRend+FS"
- bl_options = {"REGISTER", "UNDO"}
- rgsl = bpy.props.BoolProperty(
- name="RGSL",
- description="RGSL",
- default=0
- )
- rprop = bpy.props.BoolProperty(
- name="MySetR",
- description="MySetR",
- default=0
- )
- def execute(self, context):
- if self.rgsl == 1:
- bpy.context.scene.render.resolution_percentage = 100
- bpy.context.scene.render.use_antialiasing = True
- bpy.context.scene.render.antialiasing_samples = '16'
- bpy.context.scene.render.use_motion_blur = False
- bpy.context.scene.render.resolution_percentage = 100
- bpy.context.scene.render.alpha_mode = 'TRANSPARENT'
- bpy.context.space_data.viewport_shade = 'MATERIAL'
- bpy.context.scene.render.image_settings.file_format = 'PNG'
- bpy.context.scene.render.image_settings.color_mode = 'RGBA'
- bpy.context.scene.render.image_settings.compression = 0
- bpy.context.scene.render.use_freestyle = False
- self.rgsl = 0
- if self.rprop == 1:
- bpy.ops.script.python_file_run(filepath= p + "AutoRend.py")
- self.rprop = 0
- return {"FINISHED"}
- #-----> """Gruop For Name Items"""
- class GruopForNameItems(bpy.types.Operator):
- """Create a group by the name(item) of the active object"""
- bl_idname = "scene.grpnmimts"
- bl_label = "GruopForNameItems"
- def execute(self, context):
- obj = bpy.context.selected_objects
- # длина списока
- objl = len(obj)
- # снять выделение со всего
- bpy.ops.object.select_all(action='TOGGLE')
- for i in range(objl): # цикл от длины списка
- try:
- if obj != None:
- if obj != None:
- # удалитьт значение по идексу
- nm = obj.pop(0)
- # получение имени выделенного элемента
- nmpop = nm.name
- # выделяем обж по индексу
- obsl = bpy.data.objects[nmpop]
- obsl.select = True
- # делаем обж "активным"
- bpy.context.scene.objects.active = bpy.data.objects[nmpop]
- # показываем имя в окне вида и группируем по имени объекта
- bpy.context.object.show_name = True
- bpy.ops.group.create(name=nmpop)
- print(nmpop)
- # снимаем выделение
- obsl.select = False
- print('+')
- except IndexError:
- break
- # bpy.ops.script.python_file_run(filepath= p + "GruopForNameItems.py")
- return {"FINISHED"}
- #-----> """Name Items For Dupli Group Name"""
- class App_NmLink_ToEmpty(bpy.types.Operator):
- """Name dupltgruop + Replace name Empty"""
- bl_idname = "scene.rempty"
- bl_label = "App_NmLink_ToEmpty"
- bl_options = {"REGISTER", "UNDO"}
- gsz = bpy.props.FloatProperty(name="SIZE_SPHERE", description="chlst", default=1.45, min=0)
- def execute(self, context):
- """app_nameObj_to_Newgruop"""
- # bpy.ops.object.select_all(action='TOGGLE')
- for i in range(len(bpy.context.selected_objects)):
- n = bpy.context.selected_objects[i].name
- bpy.context.scene.objects.active = bpy.data.objects[n]
- e = bpy.context.active_object.dupli_group.name
- bpy.context.object.name = e
- bpy.context.object.show_name = True
- bpy.context.object.empty_draw_size = self.gsz
- bpy.context.object.empty_draw_type = 'SPHERE'
- # bpy.ops.script.python_file_run(filepath= p + "App_NmLink_ToEmpty.py")
- return {"FINISHED"}
- #-----> """ReScale & normalOut"""
- class Sacle_Nrml(bpy.types.Operator):
- """Aply sacle, outnormal"""
- bl_idname = "scene.rscnrm"
- bl_label = "ReScal & normalOut"
- bl_options = {"REGISTER", "UNDO"}
- unlo = bpy.props.BoolProperty(
- name="Unlink",
- description="Unlnk",
- default=0
- )
- def execute(self, context):
- # Here object make_single_user and transform_apply
- if self.unlo == 1:
- bpy.ops.object.make_single_user(
- object=True,
- obdata=True,
- material=False,
- texture=False,
- animation=False
- )
- bpy.ops.object.transform_apply(
- location=False,
- rotation=False,
- scale=True
- )
- self.unlo=0
- def strt():
- import bmesh
- mesh=bmesh.from_edit_mesh(bpy.context.object.data)
- for v in mesh.verts:
- v.select = False
- for v in mesh.edges:
- v.select = False
- for v in mesh.faces:
- v.select = False
- # trigger viewport update
- bpy.context.scene.objects.active = bpy.context.scene.objects.active
- bpy.ops.mesh.select_all(action='TOGGLE')
- bpy.ops.mesh.normals_make_consistent(inside=False)
- bpy.context.object.data.show_normal_loop = False
- bpy.context.object.data.show_normal_vertex = False
- bpy.context.object.data.show_normal_face = False
- bpy.ops.mesh.select_all(action='TOGGLE')
- bpy.ops.object.editmode_toggle()
- # Here object seleted all vertex
- sedt = bpy.context.mode
- scl = bpy.context.object.scale.xyz.to_tuple(1)
- if sedt == 'OBJECT':
- if scl == (1.0, 1.0, 1.0): # detect object scale Vector((1.0, 1.0, 1.0))
- bpy.ops.object.editmode_toggle() # edit mode
- strt() # run def strt()
- print('scene.rscnrm_scale Ok', scl)
- else:
- bpy.ops.apply.transformscale()
- bpy.ops.object.editmode_toggle()
- strt()
- print('scene.rscnrm_scale Edit', scl)
- if sedt == 'EDIT_MESH':
- strt()
- # bpy.ops.script.python_file_run(filepath= p + "OutNorm.py")
- return {"FINISHED"}
- #----->"""Bevel_0.2"""
- class BVLn2(bpy.types.Operator):
- """bevel(offset=0.2, segments=2)
- SELECT EDGE LOOP | | | | | | |
- """
- bl_idname = "scene.bvln"
- bl_label = "Bevel 0.2"
- bl_options = {"REGISTER", "UNDO"}
- bts = bpy.props.FloatProperty(name="depth/height", description="shrink_fatten", default=0.2)
- bss = bpy.props.IntProperty(name="subiv", description="subd", default=2, min=0)
- dmns = bpy.props.BoolProperty(name="Invert", description="INV", default=0)
- brx = bpy.props.BoolProperty(name="RELAX", description="looptools_relax", default=False)
- brd = bpy.props.FloatProperty(name="Remove_doubles", description="dbls", default=0.0)
- def execute(self, context):
- # bpy.ops.script.python_file_run(filepath= p + "Bvl0,2.py")
- Ob = bpy.context.object.select
- adtt = bpy.context.mode
- if Ob == True:
- if adtt == 'EDIT_MESH':
- bpy.ops.mesh.subdivide(smoothness=0)
- bpy.ops.mesh.select_less()
- bpy.ops.mesh.bevel(
- offset=0.1,
- segments=self.bss,
- vertex_only=False
- )
- bpy.ops.mesh.select_less()
- bpy.ops.transform.shrink_fatten(value=(self.bts * -1) if self.dmns == 1 else self.bts)
- bpy.ops.mesh.remove_doubles(threshold=self.brd)
- if self.brx == True:
- bpy.ops.mesh.looptools_relax(
- input='selected',
- interpolation='linear',
- iterations='3',
- regular=False
- )
- return {"FINISHED"}
- #----->"""Bevel_0.2"""
- class BVLnSingl(bpy.types.Operator):
- """bevel(offset=0.2, segments=2) Var 2
- SELECT EDGE LOOP ========
- """
- bl_idname = "scene.bvlntwo"
- bl_label = "BnS_Plus"
- bl_options = {"REGISTER", "UNDO"}
- bts = bpy.props.FloatProperty(name="depth/height", description="shrink_fatten", default=0.2)
- bss = bpy.props.IntProperty(name="subiv", description="subd", default=2,min=0)
- brd = bpy.props.FloatProperty(name="Remove_doubles", description="dbls", default=0.0)
- dsp = bpy.props.BoolProperty(name="Super_Dept", description="SDPT", default=0)
- bvs = bpy.props.FloatProperty(name="Bevel", description="BVL", default=0)
- dms = bpy.props.BoolProperty(name="Invert", description="INV", default=0)
- brx = bpy.props.BoolProperty(name="RELAX", description="looptlsrlx", default=0)
- def execute(self, context):
- def edbl():
- """
- Bevel(0.2, 2 - subd)
- loop multi_select(False) edges
- """
- bpy.ops.mesh.bevel(offset=0.1 , segments=self.bss , vertex_only=False)
- bpy.ops.mesh.select_less()
- bpy.ops.transform.shrink_fatten(value=(self.bts * -1) if self.dms == 1 else self.bts)
- bpy.ops.mesh.remove_doubles(threshold=self.brd)
- if self.brx == True:
- bpy.ops.mesh.looptools_relax(input='selected', interpolation='linear', iterations='3', regular=False)
- if self.dsp == 1:
- bpy.ops.mesh.bevel(offset=0.1, segments=2, vertex_only=False)
- bpy.ops.mesh.select_less()
- bpy.ops.transform.shrink_fatten(value=0.2, use_even_offset=False, mirror=False, proportional='CONNECTED',
- proportional_edit_falloff='SMOOTH', proportional_size=0.0839017)
- Ob = bpy.context.object.select
- adtt = bpy.context.mode
- if Ob == True and adtt == 'EDIT_MESH':
- edbl()
- if self.dsp == 1:
- self.bss = 2
- bpy.ops.mesh.bevel(offset=self.bvs, segments=1, vertex_only=False)
- return {"FINISHED"}
- #----->"""Normal out"""
- class normshow(bpy.types.Operator):
- """Normal out, show normal(0.6mm)"""
- bl_idname = "scene.normshow"
- bl_label = "Nout"
- bl_options = {"REGISTER", "UNDO"}
- nr = bpy.props.FloatProperty(
- name = "normal size",
- description = "normal size",
- default = 0.6,
- min=0.000,
- max=0.9
- )
- # nrmu = bpy.props.BoolProperty(
- # name="out",
- # description="Out",
- # default = 1
- # )
- def execute(self, context):
- nr1 = bpy.context.scene.tool_settings.normal_size = self.nr
- bpy.context.object.data.show_normal_vertex = True
- bpy.context.object.data.show_normal_loop = True
- bpy.context.space_data.show_backface_culling = True
- edm = bpy.context.mode
- if edm == 'OBJECT':
- bpy.ops.object.editmode_toggle()
- import bmesh
- mesh=bmesh.from_edit_mesh(bpy.context.object.data)
- for v in mesh.verts:
- v.select = False
- for v in mesh.edges:
- v.select = False
- for v in mesh.faces:
- v.select = False
- # trigger viewport update
- bpy.context.scene.objects.active = bpy.context.scene.objects.active
- bpy.ops.mesh.select_all(action='TOGGLE')
- bpy.ops.mesh.normals_make_consistent(inside = 1)
- nr1
- bpy.ops.mesh.select_all(action='TOGGLE')
- # bpy.ops.script.python_file_run(filepath= p + "Normal_out_0.6.py")
- return {"FINISHED"}
- #-----> """Bevel UP"""
- class B_UP(bpy.types.Operator):
- """Bevel UP to NULL"""
- bl_idname = "scene.bup"
- bl_label = "BVL_UP"
- bl_options = {"REGISTER", "UNDO"}
- mlst = bpy.props.BoolProperty(
- name = "UpModifier",
- description = "UpNull",
- default = 0
- )
- bm0 = bpy.props.BoolProperty(
- name = "Clear_eddge",
- description = "ClearEdg",
- default = 0
- )
- bclmp = bpy.props.BoolProperty(
- name = "Clamp",
- description = "Clamp",
- default = 0
- )
- bedt = bpy.props.BoolProperty(
- name = "EDITMODE",
- description = "EDITMODE",
- default = 0
- )
- def execute(self, context):
- slo = bpy.context.selected_objects[0].name
- edm = bpy.context.mode
- bmf = bpy.context.object.modifiers.items() # list modifrs
- bmf2 = [i[0] for i in bmf] # a list of the names of the modifiers
- def bvlprms():
- """Bevel parametrs for 'BUP'"""
- # cretate modifrs "BEVEL"
- bpy.ops.object.modifier_add(type='BEVEL')
- bnm = bpy.context.object.modifiers[- 1].name # name a last modifrs
- # my paramtrs a "BEVEL"
- bpy.context.object.modifiers[bnm].use_clamp_overlap = False
- bpy.context.object.modifiers[bnm].limit_method = 'WEIGHT'
- bpy.context.object.modifiers[bnm].width = 0.5
- bpy.context.object.modifiers[bnm].segments = 6
- bpy.context.object.modifiers["Bevel"].show_in_editmode = False
- def up_mod():
- bmf = bpy.context.object.modifiers.items()
- """move up modifier on the length of the list"""
- bnm = bpy.context.object.modifiers[-1].name # name a last modifrs
- if len(bmf) >= 2:
- for i in range(len(bmf) - 1):
- bpy.ops.object.modifier_move_up(modifier=bnm)
- bpy.context.object.modifiers[bnm].show_expanded = False
- self.mlst = 0
- if 'Bevel' in bmf2 and self.bclmp == 1:
- bpy.context.object.modifiers["Bevel"].use_clamp_overlap = True
- # EDITE MODE_BEVEL
- if 'Bevel' in bmf2: # CHECK FOR MODIFIER in the list and select the display mode
- if self.bedt == 1: # EDITE MODE_BEVEL
- bpy.context.object.modifiers["Bevel"].show_in_editmode = True
- else:
- bpy.context.object.modifiers["Bevel"].show_in_editmode = False
- # EDGE_BEVELWEIGHT == ON
- if edm == "EDIT_MESH" and self.bm0 !=1:
- bpy.ops.transform.edge_bevelweight(value=1)
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=True, type='EDGE')
- # if self.mlst !=1: # and self.bstp != 1:
- # EDGE_BEVELWEIGHT == OFF
- if edm == "EDIT_MESH" and self.bm0 ==1:
- bpy.ops.transform.edge_bevelweight(value=-1)
- # self.bm0 =0
- bch = 0
- bct = 0
- if bmf ==[]: # verifacation items for a "[]" если спискок пуст запускаем функцию сохдания бевела
- bvlprms()
- bct = 1
- while bct !=1: # create "BEVEL" and UP in steck вычисляем длину списка
- it = bmf[bch][1].type
- if it != 'BEVEL':
- bch = bch+1
- if it == 'BEVEL':
- bct = 1
- break
- if bch >= len(bmf):
- bvlprms()
- print('add bevel')
- up_mod()
- # self.bstp = 0
- bct = 1
- break
- if self.mlst ==1:
- up_mod()
- return {"FINISHED"}
- #-----> """Bevel UP"""
- class SDUP(bpy.types.Operator):
- """Select_Dupli"""
- bl_idname = "scene.sdup"
- bl_label = "Sel_SDUP"
- bl_options = {"REGISTER", "UNDO"}
- # dmv = bpy.props.BoolProperty(
- # name = "move",
- # description = "move",
- # default = 0
- # )
- # dinv = bpy.props.BoolProperty(
- # name="Invert_select",
- # description="invsel",
- # default=0
- # )
- Lc = bpy.props.BoolProperty(
- name="LOCAL",
- description="Local",
- default=0
- )
- LRt = bpy.props.BoolProperty(
- name="LOCAL_ROTATE",
- description="LRT",
- default=0
- )
- def execute(self, context):
- null = {} # выдаёт случайный порядок ключей
- sel = bpy.context.selected_objects # список выделенных обьектов
- bpy.ops.object.select_all(action='TOGGLE') #
- name_null = []
- for i in range(len(sel)):
- sel[i].select = True
- seloc = sel[i].location.to_tuple(1) # locaton
- el = sel[i].rotation_euler
- selrot = el[0], el[1], el[2] # -------
- dt = {'loc': str(seloc), 'rot': str(selrot)} # dict
- sel[i].select = False
- null[str(sel[i].name)] = dt
- name_null.append(str(sel[i].name))
- print('\n\n')
- dupli = {}
- # print(null)
- ig = ( )
- for i in null: # выбираем один элемент из "главного" списка(1действие)
- bc = null.copy() # копия "главного" словаря
- it = null[i] # получение значения ключа "главного" списка
- # print(i)
- del bc[i] # удаление ключа("самого себя")"i". можно bc.pop(i)
- for k in bc: # выбираем один элемент из копии "главного" списка(n-действий)
- if not dupli.get(k):
- itc = bc[k] # получение значения ключа оригинального списка
- if it == itc: # сравнение списков
- # print('i',i)
- dupli[i] = null[i] # одно дейс
- def locrot(): # функция выделения
- for i in dupli:
- # dupli[i]
- bpy.data.objects[i].select = True
- def fortune(): # функция перемещения дубликатов
- bpy.ops.transform.translate(value=(0, 0, -1.97685), constraint_axis=(False, False, True),
- constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED',
- proportional_edit_falloff='SMOOTH', proportional_size=8.95431,
- release_confirm=True)
- bpy.ops.scene.changobj()
- bpy.context.object.draw_type = 'WIRE'
- bpy.ops.object.copy_obj_drw()
- print('\n\n\n', len(dupli), '\n\n', dupli, '\n\n', it)
- def loca():
- single = [] # не дублируемые обьекты
- coord = [] # координаты location выделенных
- # sel = bpy.context.selected_objects
- for i in range(len(sel)):
- sel[i].select = True
- for i in range(len(sel)):
- vec = sel[i].location.to_tuple(1)
- if vec not in coord:
- coord.append(vec)
- single.append(sel[i]) # добавляем в список имена обьектов для выделения
- if vec in coord:
- print(vec)
- print(coord, '\n', single)
- bpy.ops.object.select_all(action='TOGGLE')
- # if self.dinv == 1:
- # for i in range(len(single)):
- # single[i].select = True
- # else:
- # for i in range(len(sel)):
- # if sel[i] not in single:
- # sel[i].select = True
- for i in range(len(sel)):
- if sel[i] not in single:
- sel[i].select = True
- # if self.dmv and dupli: # переместить
- # fortune()
- # self.dmv = 0
- if self.Lc == 1: # положение
- loca()
- self.Lc = 0
- self.report({'INFO'}, "LOC_MODE: I found %d objects" % len(bpy.context.selected_objects))
- print("LOC_MODE: %d objects" % len(bpy.context.selected_objects))
- if self.LRt == 1: # положение и вращение
- locrot()
- self.LRt = 0
- self.report({'INFO'}, "COMB_MODE:I found %d objects" % len(bpy.context.selected_objects))
- print("COMB_MODE: %d objects" % len(bpy.context.selected_objects))
- return {"FINISHED"}
- ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
- class AUTPanel(bpy.types.Panel):
- bl_label = "AP"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- #-----> """menu Draw Render & Simply"""
- def draw_header(self, context):
- #-----> """buttom simplify"""
- rd = context.scene.render
- view = context.space_data
- # sympli On_Off
- self.layout.prop(rd, "use_simplify",text="",
- icon='POSE_HLT' if bpy.context.scene.render.use_simplify == True else 'ARMATURE_DATA'
- )
- #-----> """buttom RenderView"""
- # ViewRender On_Off
- self.layout.prop(view, "show_only_render", text="",
- icon='RESTRICT_VIEW_OFF' if bpy.context.space_data.show_only_render == True else 'RESTRICT_VIEW_ON'
- )
- self.layout.prop(view, "use_matcap", text="",
- icon='MATCAP_01' if bpy.context.space_data.use_matcap == True else 'SOLID'
- )
- rdm = 1
- bpy.context.space_data.matcap_icon = '0'+'%s' %rdm
- # SSAO
- view = context.space_data
- scene = context.scene
- gs = scene.game_settings
- obj = context.object
- fx_settings = view.fx_settings
- self.layout.prop(fx_settings, "use_ssao", text="",
- icon='LINK' if fx_settings.use_ssao else 'INLINK'
- )
- #-----> """Draw subdiwision menu"""s
- def draw(self, context):
- layout = self.layout
- rd = context.scene.render # shade menu ))
- # layout.active = rd.use_simplify
- split = layout.split()
- col = split.column()
- if bpy.context.scene.render.use_simplify == True:
- col.prop(rd, "simplify_subdivision", text="Subdivision")
- col = split.column(align=True)
- # if bpy.context.scene.render.use_simplify == True:
- #-----> """WIRE_ZONE"""
- layout = self.layout
- obj = bpy.context.object
- # ПОКА ОСТАВИТЬ ЭТОТ КУСОК ДЛЯ ДАЛЬНЕЙШЕГО РАЗБИРАТЕЛЬСТВА С ОШИБКАМИ!!!
- if obj:
- obj_type = obj.type
- is_geometry = (obj_type in {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT'})
- is_wire = (obj_type in {'CAMERA', 'EMPTY'})
- is_empty_image = (obj_type == 'EMPTY' and obj.empty_draw_type == 'IMAGE')
- is_dupli = (obj.dupli_type != 'NONE')
- split = layout.split()
- col = split.column()
- col.prop(obj, "draw_type", text="")
- col = split.column(align=True)
- # Makes no sense for cameras, armatures, etc.!
- # but these settings do apply to dupli instances
- if is_geometry or is_dupli:
- col.prop(obj, "show_wire", text="W",) # text="Wire"
- col = split.column(align=True)
- if obj_type == 'MESH' or is_dupli:
- col.prop(obj, "show_all_edges", text="A")
- col = split.column(align=True)
- if is_geometry:
- col.prop(obj, "show_x_ray", text="X") # text="X-Ray"
- #-----> """Draw SSAO menu"""
- view = context.space_data
- scene = context.scene
- gs = scene.game_settings
- obj = context.object
- fx_settings = view.fx_settings
- if view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}:
- sub = col.column()
- sub.active = view.region_3d.view_perspective == 'CAMERA'
- if fx_settings.use_ssao:
- ssao_settings = fx_settings.ssao
- col.column(align=True)
- subcol = split.column(align=True)
- subcol.prop(ssao_settings, "factor")
- subcol = split.column(align=True)
- subcol.prop(ssao_settings, "distance_max")
- subcol = split.column(align=True)
- subcol.prop(ssao_settings, "samples")
- #-----> """Draw AUTO menu"""
- row = layout.row()
- layout = self.layout
- split = layout.split()
- col = split.column(align=True)
- slct = bpy.context.selected_objects
- edm = bpy.context.mode
- ob = context.object
- if edm != 'SCULPT':
- col.operator("scene.autorend", text="RL", icon="RENDERLAYERS")
- col = split.column(align=True)
- col.operator("scene.kursor", text="XYZ", icon="CURSOR")
- col = split.column(align=True)
- col.operator("scene.test", text="TST", icon="RADIO")
- split = layout.split()
- col = split.column(align=True)
- try:
- tp = bpy.context.selected_objects[0].type
- except IndexError:
- tp = 0
- if edm == 'SCULPT':
- split = layout.split()
- col = split.column(align=True)
- # Name Brush
- aname = bpy.context.scene.tool_settings.sculpt.brush.name
- # Create a pattern brush in quotes
- Btool = "%s" % aname + ""
- if tp != 'EMPTY' and edm!='EDIT_MESH':
- col.operator("scene.scdint", text="DIN" if edm != 'SCULPT' else Btool,
- icon="BRUSH_FILL" if edm != 'SCULPT' else 'SCULPTMODE_HLT')
- if slct != []:
- if tp != 'EMPTY' and edm != 'SCULPT' and edm!='EDIT_MESH':
- col.operator("scene.normshow", text="Nout", icon="INLINK")
- col.operator("scene.grpnmimts", text="Gruop", icon="GROUP")
- nmc=bpy.context.selected_objects[0].name
- col.operator("scene.changobj", text='Co' , icon="OUTLINER_DATA_META")
- col.operator("scene.crlwo", text='CW' , icon="MESH_TORUS")
- if slct != []:
- col = split.column(align=True)
- if tp == 'EMPTY':
- # col = split.column(align=True)
- layout.operator("scene.rempty", text="Name", icon="OUTLINER_OB_EMPTY")
- layout.operator("scene.crlwo", text='CW' , icon="MESH_TORUS")
- if ob.dupli_type == 'GROUP':
- layout.prop(ob, "dupli_group", text="Group")
- if slct != [] and edm == 'OBJECT':
- if tp != 'EMPTY':
- col.operator("scene.rscnrm", text="Restore", icon="MESH_ICOSPHERE")
- row = layout.row(align=True)
- col.operator("scene.sdup", text="SRCH", icon="MOD_ARRAY")
- col.operator("scene.apjion", text="JO", icon="OBJECT_DATAMODE")
- col.operator("scene.robject", text="Rot&Dub", icon="FORCE_VORTEX")
- col.operator("scene.bup", text="BUP", icon="MOD_BEVEL")
- if slct == []:
- col.operator("scene.crlwo", text='CW' , icon="MESH_TORUS")
- #-----> """Block EDIT_MESH"""
- if edm == 'EDIT_MESH':
- # split = layout.split(percentage=0.0, align=True)
- col.operator("scene.rscnrm", text="Restore", icon="MESH_ICOSPHERE")
- col = split.column(align=True)
- col.operator("scene.bvln", text="Bv | |", icon="EDGESEL")
- col = split.column(align=True)
- col.operator("scene.bvlntwo", text="Bv ==", icon="EDGESEL")
- col = split.column(align=True)
- col.operator("scene.dissol", text="DS", icon="SNAP_VERTEX")
- col = split.column(align=True)
- col.operator("scene.bup", text="BUP", icon="MOD_BEVEL")
- #-----> """End"""
- def register():
- bpy.utils.register_class(SDUP)
- bpy.utils.register_class(Crlwo)
- bpy.utils.register_class(Robject)
- bpy.utils.register_class(TEST)
- bpy.utils.register_class(kurs)
- bpy.utils.register_class(AUTPanel)
- bpy.utils.register_class(SculptMyDint)
- bpy.utils.register_class(OpsRenderLrs)
- bpy.utils.register_class(GruopForNameItems)
- bpy.utils.register_class(App_NmLink_ToEmpty)
- bpy.utils.register_class(Sacle_Nrml)
- bpy.utils.register_class(BVLn2)
- bpy.utils.register_class(normshow)
- bpy.utils.register_class(AplyJion)
- bpy.utils.register_class(dissol)
- bpy.utils.register_class(changobj)
- bpy.utils.register_class(BVLnSingl)
- bpy.utils.register_class(B_UP)
- def unregister():
- bpy.utils.unregister_class(B_UP)
- bpy.utils.unregister_class(BVLnSingl)
- bpy.utils.unregister_class(changobj)
- bpy.utils.unregister_class(dissol)
- bpy.utils.unregister_class(AplyJion)
- bpy.utils.unregister_class(normshow)
- bpy.utils.unregister_class(BVLn2)
- bpy.utils.unregister_class(Sacle_Nrml)
- bpy.utils.unregister_class(App_NmLink_ToEmpty)
- bpy.utils.unregister_class(GruopForNameItems)
- bpy.utils.unregister_class(OpsRenderLrs)
- bpy.utils.unregister_class(SculptMyDint)
- bpy.utils.unregister_class(AUTPanel)
- bpy.utils.unregister_class(kurs)
- bpy.utils.unregister_class(TEST)
- bpy.utils.unregister_class(Robject)
- bpy.utils.unregister_class(Crlwo)
- bpy.utils.unregister_class(SDUP)
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement