Hi everyone,
I am trying to create a Python component capable of exporting geometries directly from GH to CAD without baking them into Rhino canvas.
I found this useful script on the forum made by Djordje Spasic some years ago, however instead of using geometries as input it uses object names baked on rhino canvas. Would it be possible to modify the code to use Geometries?
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def exportObjectsByName(fileType, filePath, names):
# check the input data
if fileType:
if fileType.startswith("."):
pass
else:
fileType = "." + fileType
supportedFileTypes = [".3dm", ".3ds", ".sat", ".ai", ".dwg", ".dxf", ".dae", ".cd", ".x", ".emf", ".gf", ".pm", ".kmz", ".gts", ".igs", ".iges", ".udo", ".fbx", ".obj", ".csv", ".x_t", ".pdf", ".ply", ".txt", ".pov", ".raw", ".rib", ".skp", ".step", ".stl", ".tsm", ".tss", ".vda", ".wrl", ".vmrl", ".gdf", ".wmf", ".x3dv", ".xaml", ".xgl", ".zpr"]
if fileType in supportedFileTypes:
pass
else:
print "File type %s is not supported" % fileType
return
else:
print "Please input fileType_"
return
if filePath:
if filePath.endswith("\\"):
pass
else:
filePath = filePath + "\\"
else:
print "Please input filePath_"
return
if names:
pass
else:
print "Please input names_"
return
sc.doc = Rhino.RhinoDoc.ActiveDoc
allObjsIds = rs.AllObjects()
rs.UnselectObjects(allObjsIds)
sc.doc = ghdoc
for name in names:
fileNameAndType = name + fileType
finalPath = chr(34) + filePath + fileNameAndType + chr(34)
commandString = "_-Export " + "_-SelName " + name + " _Enter " + finalPath + " _Enter _Enter _Enter"
echo = True
done = rs.Command(commandString, echo)
if done:
print "%s file successfully exported to: %s" % (fileNameAndType, filePath)
else:
print "Something went wrong. Export terminated"
rs.Command("_-SelNone ")
return
if _export:
exportObjectsByName(_fileType, _filePath, _names)
Thanks in advance