Exporting .wrl files with specific parameters

Hi! I am trying to export some blocks from rhino using python into .wrl format.
I know that I can supress the diaglog box in Rhino by doing -_Export and then I can enter my parameters through a script in python. What I am confused about though is that the parameters I can access through python are not the same as those I can access through the user interface.
Accessing the interface through python I can only access the parameters for .wrl exporting that you see in my script below but if you do the process out by hand on the user interface on the polygon mesh options dialog box, if you click “detailed controls” there is the option for simple planes. How can I access this “check box” from a python script like I access the other parameters.

Thank you!!

My script (which works to export the .wrl file) is as follows

import rhinoscriptsyntax as rs
# iterates through layers


# select all in current layer
rs.Command("-_SelAll ")

directory = 'C:\\Users\\Rebecca Napolitano\\Documents\\datafiles\\Romanbondingcourses\\2017_10_25_experiments\\'

filename = 'test'
filetype = '.wrl'

# make cmdstr, include layer if there are multiple layers
path = "\"" + directory + filename + filetype + "\""
cmdstr = "-_Export " + path
if filetype == ".wrl":
cmdstr += " Enter"
cmdstr += " Angle 0.0 AspectRatio 0.0 Distance 0.0 Density 0.0 Grid 0.0 "
cmdstr += " Enter "
        
#cmdstr += " Enter Enter"

# execute command
cmd = rs.Command(cmdstr)
if not(cmd):
success = False

rs.Command("-_SelNone")

Here are the options I can script:
scripting

Here is the parameter I need to access:
interface

Hi @Rebecca_Napolitano,

its seems to be missing in the command options of the wrl export. One workaround would be to script the _Mesh command first, select the resulting meshes and export them as wrl, then just delete the meshes. The _Mesh command has the missing option:

_
c.

1 Like

This worked! Thank you very much @clement !!
In case anyone else ever needs this, it is code that loops through your layers, meshes what is in there, grabs only the mesh, and exports it with its layer name to a file location as a .wrl file with simple planes.

import rhinoscriptsyntax as rs
# iterates through layers
layers = rs.LayerNames() 
for layer in layers:
    
    if layer != 'concrete':
    
        # select layer
        rs.Command("-_SelLayer " + layer)
        
        rs.Command("-_Mesh DetailedOptions SimplePlane=Yes Enter")
           
        directory = 'C:\\Users\\Rebecca Napolitano\\Documents\\datafiles\\Romanbondingcourses\\2017_10_26_experiments\\'
        
        filename = 'test'
        filetype = '.wrl'
        
        # make cmdstr, include layer if there are multiple layers
        if len(layers) > 1:
            path = "\"" + directory + filename + "_" + layer + filetype + "\""
        else:
            path = "\"" + directory + filename + filetype + "\""
        
        rs.Command("-_SelNone ")
        rs.Command("-_SelLayer " + layer)
        rs.Command("-_Invert ")
        rs.Command("Hide Enter")
        rs.Command("-_SelMesh ")
        cmdstr = "-_Export " + path
        if filetype == ".wrl":
            cmdstr += " Enter Enter"
        
        # execute command
        cmd = rs.Command(cmdstr)
        if not(cmd):
            success = False
            
        rs.Command("-_SelNone" )
        rs.Command("Show" )

@Rebecca_Napolitano,

good ! Note that you’ll need to enclose a layer name into quotes if you pass it to the command line. Otherwise, if the layer name has spaces in it, Rhino’s commandline will interpret that space as Enter. Eg. if you have two layers one is named “Concrete 1” and the other “Concrete” and you do this:

layer = "Concrete 1"
rs.Command("-_SelLayer " + layer)

Rhino will try to select the objects on the layer named “Concrete” not “Concrete 1”. If you do it like this:

layer = chr(34) + "Concrete 1" + chr(34)
rs.Command("-_SelLayer " + layer)

it will select the objects on layer “Concrete 1” because the layer is enclosed in quotes and interpreted as one word.

_
c.

1 Like