animation_animall: return to release: T68332 T63750 e6a1dfbe53be
[blender-addons.git] / mesh_tiny_cad / CFG.py
blob9eb02a2979527cf522883cbf630926c7e90769dc
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 # <pep8 compliant>
22 import os
23 import bpy
25 ICONS = 'BIX CCEN V2X VTX XALL E2F'.split(' ')
26 icon_collection = {}
29 class TinyCADProperties(bpy.types.PropertyGroup):
31 num_verts: bpy.props.IntProperty(
32 min=3, max=60, default=12)
34 rescale: bpy.props.FloatProperty(
35 default=1.0,
36 precision=4,
37 min=0.0001)
40 class VIEW3D_MT_edit_mesh_tinycad(bpy.types.Menu):
41 bl_label = "TinyCAD"
43 @classmethod
44 def poll(cls, context):
45 return bool(context.object)
47 def draw(self, context):
49 pcoll = icon_collection["main"]
51 def cicon(name):
52 return pcoll[name].icon_id
54 op = self.layout.operator
55 op('tinycad.autovtx', text='VTX | AUTO', icon_value=cicon('VTX'))
56 op('tinycad.vertintersect', text='V2X | Vertex at intersection', icon_value=cicon('V2X'))
57 op('tinycad.intersectall', text='XALL | Intersect selected edges', icon_value=cicon('XALL'))
58 op('tinycad.linetobisect', text='BIX | Bisector of 2 planar edges', icon_value=cicon('BIX'))
59 op('tinycad.circlecenter', text='CCEN | Resurrect circle center', icon_value=cicon('CCEN'))
60 op('tinycad.edge_to_face', text='E2F | Extend Edge to Face', icon_value=cicon('E2F'))
63 def register_icons():
64 import bpy.utils.previews
65 pcoll = bpy.utils.previews.new()
66 icons_dir = os.path.join(os.path.dirname(__file__), "icons")
67 for icon_name in ICONS:
68 pcoll.load(icon_name, os.path.join(icons_dir, icon_name + '.png'), 'IMAGE')
70 icon_collection["main"] = pcoll
73 def unregister_icons():
74 for pcoll in icon_collection.values():
75 bpy.utils.previews.remove(pcoll)
76 icon_collection.clear()