Skip to content
Snippets Groups Projects
Commit 83210611 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Uniformize blender plugin

parent 3e364f4e
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
INCLUDE_DIRECTORIES(SYSTEM ${EIGEN3_INCLUDE_DIRS})
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(blender)
ADD_SUBDIRECTORY(examples EXCLUDE_FROM_ALL)
SETUP_PROJECT_FINALIZE()
# Copyright (c) 2015 CNRS
# Author: Joseph Mirabel
#
# This file is part of gepetto-viewer-corba.
# gepetto-viewer-corba is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# gepetto-viewer-corba 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 Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# gepetto-viewer-corba. If not, see
# <http://www.gnu.org/licenses/>.
# INSTALL (gepettoimport.py DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/python3/site-packages/gepettoimport)
INSTALL (PROGRAMS urdf_to_blender.py DESTINATION bin)
......@@ -67,9 +67,10 @@ gui.captureTransformOnRefresh(false)
Blender is using python 3, so you may encounter some problems of you do not set `PYTHONPATH` environment properly.
Two options:
Three options:
- ```blender --python <source-folder>/gepetto-viewer-corba/blender/gepettoimport.py```
- Install it as an addon (https://www.blender.org/manual/advanced/scripting/python/add_ons.html) - save the user preferences
- Manually load the plugin by running the script `blender/gepettoimport.py`
_Switch to the script view in blender (menu on the top the screen) the python script that you can find in the gepetto-viewer under `blender/gepettoimport.py` and press `Run script`_
......
......@@ -22,6 +22,19 @@
# https://github.com/jmirabel/gepetto-viewer-corba/tree/devel/blender
###
bl_info = {
"author": "Joseph Mirabel",
"name" : "Gepetto Viewer Blender Addon",
"category": "Import-Export",
"blender": (2,75,0),
"description": "Add functionality to import files generated using the Gepetto Viewer software",
"location": "SpaceBar Search > YAML Gepetto or URDF blender",
"wiki_url": "https://github.com/jmirabel/gepetto-viewer-corba/tree/master/blender#readme",
"warning" : "Not heavily tested, feel free to report bug on github.",
"version" : (0,0),
"support" : "COMMUNITY"
}
import bpy
import bpy_extras.io_utils
import re
......@@ -77,7 +90,7 @@ class YamlPathImport (bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
class UrdfToBlendImport (bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
bl_idname = "import.urdf_to_blendimport"
bl_label = "Import a script generated with urdf_to_blend.py"
bl_label = "Import a URDF blender script"
filepath = bpy.props.StringProperty(subtype="FILE_PATH")
......@@ -90,5 +103,13 @@ class UrdfToBlendImport (bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
bpy.utils.register_class(YamlPathImport)
bpy.utils.register_class(UrdfToBlendImport)
def register():
bpy.utils.register_class(YamlPathImport)
bpy.utils.register_class(UrdfToBlendImport)
def unregister():
bpy.utils.unregister_class(YamlPathImport)
bpy.utils.unregister_class(UrdfToBlendImport)
if __name__ == "__main__":
register()
......@@ -10,10 +10,11 @@ import inspect
import urdf_parser_py.urdf as urdf
def usage ():
print (sys.argv[0] + " -p <prefix> -i <urdf-file> -o <blender-script>")
print ("urdf-file is mandatory")
print ("blender-script is mandatory")
print ("prefix is optional")
print (os.path.basename(sys.argv[0]) + " -p <prefix> -i <urdf-file> -o <blender-script>\n")
print ("Arguments:")
print ("\turdf-file \t[mandatory]\tinput URDF file")
print ("\tblender-script\t[mandatory]\toutput blender script")
print ("\tprefix \t[optional] \tprefix of object names")
try:
opts, args = getopt.getopt (sys.argv[1:], "p:i:o:", ["prefix=", "in=", "out="])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment