Export Script

Hi all,

I am new in programming and I would like to make this procedure automatic.
My goal is to write a script to export a group of surfaces (in iges) with their layer names and colour.
Do anyone have any suggestion please?

Cheers
Gabriele

Hi Gabriele,

Can you elaborate a little or maybe send an example file and desired output.

My interpretation:
you want to select some surfaces and export as iges, but what I do not understand:

  • should each surface be a single iges?
  • what will the filename be?

I have a script setup that could help you get started, but if you let me know exactly what you want, I can set it up already to make it work the way you want

-Willem

@Willem

Hi Willem,

sorry but I didn’t recive any alert about your answer.
I would like to have a script to export the surfaces contained inside the rhino file into a single generic iges.
I will define the filename in the futere it is not a big issue at the moment.
If it is possible I would like to call this script in batch.
Please find attached a file testcube-export.3dm (37.2 KB)

Please let me known if I can use your script as starting point and I will try to implement it with my necessity.

Cheers
Gabriele

Hi Gabriele,

The script below allows you to set an export folder and export the selected objects as iges
Does this help?

import rhinoscriptsyntax as rs

def export_iges(file_name,object_ids,EXPORTPATH):
    
    FILEPATH = EXPORTPATH +'\\'+ file_name + '.igs'

    rs.UnselectAllObjects()
    rs.SelectObjects(object_ids)
    
    #export with default scheme
    rs.Command('_-Export "{}" Default _Enter'.format(FILEPATH),echo=True)

def export_selected_as_iges():
    
    #get folder to save iges to
    EXPORTPATH = rs.BrowseForFolder( message ='select iges folder')
    if not EXPORTPATH : return
    
    # ask user to select (poly)surfaces for export
    object_ids = rs.GetObjects('Select (poly)surfaces to export as iges',filter = 8+16)
    if not object_ids : return 

    file_name = 'my_name'
    export_iges(file_name,object_ids,EXPORTPATH)
        
        
export_selected_as_iges()

-Willem

1 Like

@Willem

Hi Willem,
It is working quite well, thank you.
I will try to customise the script on my necessity but I will let you know if I have any doubt.

Thanks again
Gabriele

1 Like

Hello,

How would you change the default scheme options? For example I want to export to .sat files but I don’t find how to do it (sorry it’s my first script in Rhino).

Thanks in advance :slight_smile:

Hi,

What happens if you substitute .igs for .sat?

You might want to check what command line input sat exports need by running the command -Export (note the hyphen in front)

The instructions after rs.Command are similar to a macro where you feed strings to the command line.

Does this help?

-Willem

1 Like

Oh! Sorry, I removed the “.igs” part and I did not realize!

Of course it helps, now I know how to customize everything! Thanks a lot!!! :slight_smile:

1 Like