Exporting to STP through python rhino 7

I am having a an issue in exporting a closed polysurfaces as STP file through python.
the script was working in previous rhino but now in rhino 7 exports only empty STP files (0 kb)

Snip of the code:

    rs.SelectObject(nowObj)
    print nowObj
    nowName = str(nowLayer)
    nowName = nowName.replace(":", "-")
    nowName = nowName.replace(" ", "_")
    exportPath = filePath + nowName + ".stp"

    Rhino.RhinoApp.RunScript("-_Export " + str(exportPath)+ " Schema=AP214AutomotiveDesign " + " ExportParameterSpaceCurves=No" + " LetImportingApplicationSetColorForBlackObjects=Yes" +" Enter", False)
        Rhino.RhinoApp.RunScript("-_SelNone", False)
        rs.DeleteObject(nowObj)

print output for example is (are closed object polysurfaces) :
ff6af33c-bdf2-46cd-bb4e-d6ecbab7a080
33cde126-d2ba-4b76-b6a7-07984b5b81fc

so they are objects but they don’t get to be exported in the STL file, any idea why?

Hi @revink,

What happens when you run the script? Do you get an error? Can you post a file and the full script so we can try to repeat it?

– Dale

Hi @dale no error, the object gets exported but the resulting file is a 0 kb empty stp.

See below and attached
export stp.py (519 Bytes) teststp.3dm (28.7 KB)

import rhinoscriptsyntax as rs
import Rhino

obj = rs.GetObject("object", 8+16)


Rhino.RhinoApp.RunScript("-_SelNone", False)
filePath = r'C:\Users\firstname.secondname\Desktop'
fileName = '/testobj.stp'
exportPath = filePath+fileName
rs.SelectObject(obj)

Rhino.RhinoApp.RunScript("-_Export " + str(exportPath)+ " Schema=AP214AutomotiveDesign " + " ExportParameterSpaceCurves=No" + " LetImportingApplicationSetColorForBlackObjects=Yes" +" Enter", False)
Rhino.RhinoApp.RunScript("-_SelNone", False)

Hi @revink,

Does this work any better?

import rhinoscriptsyntax as rs
import System

def test_export_step():
    
    filter = rs.filter.surface + rs.filter.polysurface
    object_id = rs.GetObject('Select surface or polysurface to export', filter, False, True)
    if not object_id:
        return
    
    path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop)
    filename = System.IO.Path.Combine(path, "test_export_step.stp");

    # Surround string with double-quotes (in case it contains spaces)
    filename = chr(34)+ filename + chr(34)
    
    script = '_-Export ' + filename + ' _Enter'
    rs.Command(script, False)

if __name__ == "__main__":
    test_export_step()

– Dale

1 Like

Dale

I am interested in exporting .stp and/or Sketches from Rhino to our Cam software (I am new to Rhino, as in a few days recent, but have 40+ years experience in s/w development for Cam (CNC) products). Could the above script be modified to add the option of selection of 2D sketches and launch of Cam software with the name oif the resultant exported file as command line arguments ?

thanks.

michael

So are these curves that are planar to the world xy plane?

– Dale

Initially the sketches will be on the XY plane, from prismatic part models. Eventually sketches will be exported from non XY planes but this is for the future. Full models will also be exported as .stp or .igs files.
I am working my way through docs at the moment, progress so far is that I have installed Rhino Visual Studio Templates for C# and VB and should be able to build plug-in projects now.