Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created April 24, 2014 15:56
Show Gist options
  • Save zeffii/11259754 to your computer and use it in GitHub Desktop.
Save zeffii/11259754 to your computer and use it in GitHub Desktop.
__init__.py redux
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
# and write to the Free Software Foundation, Inc., 51 Franklin Street,
# Fifth Floor, Boston, MA 02110-1301, USA..
#
# The Original Code is Copyright (C) 2013-2014 by Gorodetskiy Nikita ###
# All rights reserved.
#
# Contact: sverchok-b3d@yandex.ru ###
# Information: http://nikitron.cc.ua/sverchok.html ###
#
# The Original Code is: all of this file.
#
# Contributor(s): Nedovizin Alexander, Gorodetskiy Nikita, Linus Yng, Agustin Gimenez.
#
# ***** END GPL LICENSE BLOCK *****
#
# -*- coding: utf-8 -*-
bl_info = {
"name": "Sverchok",
"author": "Nedovizin Alexander, Gorodetskiy Nikita, Linus Yng, Agustin Jimenez, Dealga McArdle",
"version": (0, 2, 7),
"blender": (2, 6, 9),
"location": "Nodes > CustomNodesTree > Add user nodes",
"description": "Do parametric node-based geometry programming",
"warning": "requires nodes window",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Nodes/Sverchok",
"tracker_url": "http://www.blenderartists.org/forum/showthread.php?272679-Addon-WIP-Sverchok-parametric-tool-for-architects",
"category": "Node"}
import importlib
import sys, os
path = sys.path
flag = False
for item in path:
if "sverchok" in item:
flag = True
if not flag:
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'sverchok_nodes'))
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'sverchok-master'))
print("sverchok_nodes: added to phytonpath :-)")
files_to_import = [
'node_ScalarMath',
'node_CentersPolsNode',
'util',
'node_Objects',
'node_Viewer',
'node_Viewer_text',
'node_IDXview',
'Viewer_draw',
'Index_Viewer_draw',
'node_ListLevels',
'node_ListJoin2',
'node_Zip',
'node_Shift',
'node_ListSlice',
'node_ListShuffle',
'node_ListReverse',
'node_ListLength',
'node_ListFunc',
'node_ListSum',
'node_ListStartEnd',
'node_ListItem',
'node_ListRepeater',
'node_PolygonBoom',
'node_ListSort',
'node_ListMatch',
'node_DistancePP',
'node_Series',
'node_Vector',
'node_Vector_out',
'node_VectorNormal',
'node_MatrixApply',
'node_VectorDrop',
'node_RandomVector',
'node_Random',
'node_Float',
'node_Integer',
'node_Float2Int',
'node_VectorMove',
'node_VectorMath',
'node_MatrixDeform',
'node_MatrixGenerator',
'node_MatrixDestructor',
'node_MatrixShear',
'node_MatrixInterpolation',
'node_WifiOut',
'node_WifiIn',
'node_Formula',
'node_Formula2',
'node_Tools',
'node_AdaptivePolygons',
'node_CrossSection',
'node_Bisect',
'node_Solidify',
'node_Wireframe',
'node_Line',
'node_Hilbert',
'node_HilbertImage',
'node_Voronoi2D',
'node_Plane',
'node_Circle',
'node_Cylinder',
'node_Sphere',
'node_EvaluateLine',
'node_MaskList',
'node_Image',
'node_LineConnect',
'node_Area',
'node_Range',
'node_Converter',
'node_ListFlip',
'node_FrameNode',
'node_Test1',
'node_Text',
'node_Script',
'node_Pols2Edgs',
'node_Note',
'node_Bakery',
'node_VertsDelDoubles',
'node_RemoveDoubles',
'node_MeshJoin',
'node_VertSort',
'node_KDTree'
]
if "bpy" in locals():
import imp
imp.reload(node_s)
for item in files_to_import:
importlib.reload(item)
else:
import node_s
for item in files_to_import:
importlib.import_module(item)
import bpy
import nodeitems_utils
def get_drop_list():
# add files which should be not be loaded dynamically
return ['node_Voronoi']
def get_node_list():
drop_list = get_drop_list()
node_filter = lambda f: f.startswith('node_') and f.endswith(".py")
svpath = os.path.dirname(os.path.realpath(__file__))
nodes = (f[:-3] for f in next(os.walk(svpath))[2] if node_filter(f))
node_list = (f for f in nodes if not f in drop_list)
return node_list
def register():
nodes = get_node_list()
for file_to_register in nodes:
bpy.utils.register_module(file_to_register)
if 'SVERCHOK' not in nodeitems_utils._node_categories:
nodeitems_utils.register_node_categories(
"SVERCHOK", node_s.make_categories())
def unregister():
nodes = get_node_list()
for file_found in reversed(list(nodes)):
bpy.utils.unregister_module(file_found)
if 'SVERCHOK' in nodeitems_utils._node_categories:
nodeitems_utils.unregister_node_categories("SVERCHOK")
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment