Hello.
I often work in Rhino_8 and Rhino_5 at the same time.
Unfortunately, it is impossible to paste objects to Rhino5 from the clipboard Rhino8.
Therefore I have to Export or Save as Rhino 5.
For convenience, I use this script by Mitch:
"""
Exports selected objects as Rhino version V5. Any SubD objects are converted
to NURBS for export. Script by Mitch Heynick 11.01.22
"""
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def ConvertSubDToNurbs(subd_obj):
subd=rs.coercegeometry(subd_obj)
brep=subd.ToBrep(Rhino.Geometry.SubDToBrepOptions.DefaultPacked)
return brep
def ExportAsV5ConvPackedSubD():
msg="Select objects to export as V5"
obj_ids=rs.GetObjects(msg,preselect=True,select=True)
if not obj_ids: return
rs.EnableRedraw(False)
subd_count=0
subd_exp_error=0
subd_obj_ids=[]
conv_brep_objs=[]
for obj_id in obj_ids:
if rs.ObjectType(obj_id)==262144:
#object is a sub-d
brep=ConvertSubDToNurbs(obj_id)
if brep:
subd_obj_ids.append(obj_id)
rs.UnselectObject(obj_id)
conv_brep_obj=sc.doc.Objects.AddBrep(brep)
conv_brep_objs.append(conv_brep_obj)
rs.SelectObject(conv_brep_obj)
subd_count+=1
else:
subd_exp_error+=1
filename=rs.SaveFileName("Save V5 file","Rhino Files|.3dm||")
if filename:
export_count=len(rs.SelectedObjects())
comm_str='_-Export _Version=5 "{}"'.format(filename)
rs.Command(comm_str)
if conv_brep_objs: rs.DeleteObjects(conv_brep_objs)
if subd_obj_ids: rs.SelectObjects(subd_obj_ids)
msg="{} objects exported as V5".format(export_count)
if subd_count:
msg+=" including {} SubD objects".format(subd_count)
if subd_exp_error:
msg+=". {} SubD objects unable to be exported".format(subd_exp_error)
msg+="."
print msg
ExportAsV5ConvPackedSubD()
Is it possible when Export done, copy the path and file name to clipboard in the text from Rhino8, to quickly find it in Rhino_5 and import this file without question?
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
import_path = rs.OpenFileName("file to import")
if import_path:
FileReadOptions = Rhino.FileIO.FileReadOptions()
FileReadOptions.ScaleGeometry = True
FileData = Rhino.RhinoDoc.ReadFile(import_path, FileReadOptions)
Something like that. Copy to clipboard Path and DocumentName.
import rhinoscriptsyntax as rs
import os
filepath=rs.DocumentPath()
if filepath:
fullpath=os.path.join(filepath,rs.DocumentName())
rs.ClipboardText(fullpath)
print ("File path+name copied to clipboard")
else:
print ("File has not been saved, no document path available")
Thanks.
5 posts - 3 participants