Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5871

Export file from Python command

$
0
0

@sdaitzman wrote:

Hi!!

I'm writing my first Rhino command! I'd like to be able to run a command, select some objects, and have them open directly in Sketch for Mac. I've got every aspect of this figured out and most of the code written, but I can't for the life of me figure out how to script the file export! I'd like to export the selected objects (I scripted selecting them) as an Adobe Illustrator file, which I'll then convert to SVG for import into Sketch. How do I write a one-line export command, one that I can put in the line that reads rs.Command("! _-Export") so that the selected objects will be exported as a .ai file with no pause to input parameters each time? Or is calling rs.Command the wrong way to go about this?

Any help would be much appreciated!!

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

__commandname__ = "Diagram"

def RunCommand( is_interactive ):
    obj = rs.GetObjects(filter=4)
    if obj:
        rs.SelectObjects(obj)
        print "Exporting..."
        rs.Command("! _-Export")
    else:
        print "Error: no objects selected"

Thanks so much,
Sam

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5871

Trending Articles