Sometimes is useful to make corrections to the mesh inside Blender. To go back and forward between these two applications. And for this, thx to Rhino developers, I use just a button scripts.
Now lates version on GitHub
If you wish to improve it, it is now on GitHub
Here it is the Rhino Export command script to be added to a button. It will export to Blender:
! -_Export _GeometryOnly=_Yes _SaveTextures=_No _SaveNotes=_No _SaveSmall=_Yes
"X:\DoNotMove\Rhino-Blender-mesh.obj"
VertexWelding=Unmodified YUp=Yes enter enter
And the Rhino Import by clicking the right button. It will import from Blender:
! -_Import
"X:\DoNotMove\Rhino-Blender-mesh.obj"
MapYtoZ=Yes
enter
Then in Blender, you can use python
Rhino Blender Mesh Bridge Python V0.1 beta
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~ Alan Mattano 2020 SoaringStars lab
# ~~~~~~
# ~~~~~~ Blender Rhino Bridge
# ~~~~~~
# ~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import os
import bpy
def main1(context):
print("Importing...")
full_path_to_file = "X:\DoNotMove\Rhino-Blender-mesh.obj"
# bpy.ops.import_scene.obj(filepath=full_path_to_file)
bpy.ops.import_scene.obj(filepath=full_path_to_file, axis_forward='-Z', axis_up='Y', filter_glob="*.obj;*.mtl")
def main2(context):
print("Exporting...")
full_path_to_file = "X:\DoNotMove\Rhino-Blender-mesh.obj"
bpy.ops.export_scene.obj(filepath=full_path_to_file, use_selection=True)
class ImportOBJMesh(bpy.types.Operator):
"""Tooltip Import"""
bl_idname = "myops.import_rhino_add_obj"
bl_label = "Import Rhino OBJ Mesh"
def execute(self, context):
main1(context)
return {'FINISHED'}
class ExportOBJMesh(bpy.types.Operator):
"""Tooltip Export"""
bl_idname = "myops.export_rhino_selected_obj"
bl_label = "Export OBJ Mesh to Rhino"
def execute(self, context):
main2(context)
return {'FINISHED'}
# ~~~ end Import Export ~~~~~~~~~
class AMrhinoBridgeButton(bpy.types.Panel):
"""A Alan Mattano Custom Panel in the top bar viewport for importing and exporting files fast to Rhino"""
ui_tabTitle ="------> Rhino Bridge <--------"
ui_topHeader = "Rhino Import and Export tool"
declare_filepath = "X:\DoNotMove\Rhino-Blender-mesh.obj"
bl_label = ui_tabTitle
# internal blender name
bl_idname = "OBJECT_PT_rhinobridge"
# place where will be the panle
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
layout = self.layout
# new line \n
row = layout.row()
row.label(text="Bridge", icon='MESH_CYLINDER')
# new line \n
row = layout.row()
# BUTTON DELETE
row.operator("object.delete", text="Delete Selected")
# BUTTON IMPORT OBJ
op = row.operator("myops.import_rhino_add_obj", text="IMPORT MESH")
# BUTTON EXPORT OBJ
op = row.operator("myops.export_rhino_selected_obj", text="EXPORT MESH To Rhino")
# ~~~ end Rhino Bridge Button ~~~~~~
def register():
bpy.utils.register_class(AMrhinoBridgeButton)
bpy.utils.register_class(ImportOBJMesh)
bpy.utils.register_class(ExportOBJMesh)
def unregister():
bpy.utils.unregister_class(AMrhinoBridgeButton)
bpy.utils.unregister_class(ImportOBJMesh)
bpy.utils.unregister_class(ExportOBJMesh)
if __name__ == "__main__":
register()
This script will create an Import and Export button in the Object Properties section. To activate this button you need to select an object and then go to Object Properties. There you will find Import and Export buttons. There is extra code that is not needed. You can clean it. I will be creating a better version (plugin).