How to redirect the output of a command into a text field!

HI,

I am writing a checker for some CAD models, and I would like to use script Python that mimic the Analyze Diagnostics -> List, Check, Select Bad Objects,…etc. I can run the _List command but Rhino display the results into a dialog. It is possible to capture into a string the results the command ? I am new in Rhino, so I am wandering if some one has a Python script that implement the _List command, or knows how to implement such a command ?

Regards,

Ion

Hi Ion,

You can add the the hyphen character - to _List to choose sending results to a clipboard instead of dialog box:

import rhinoscriptsyntax as rs
import System

id = rs.GetObject("pick object up an object(s)", select = True)
rs.Command("_-List Clipboard")
clipboardText = System.Windows.Forms.Clipboard.GetText()
print clipboardText

Then further arrange the clipboardText string if you wish to extract some specific data from it.

Thank very much Steve !!

Regards,

Ion

HI Steve,

It is working !! Thanks again !! All this information that is dumped into the Clipboard can be accessed through the Python API ? I saw that the ObjectDump function is not implemented yet in Rhino…. My checker is organized per curves, edges, surfaces, mesh and solids. Rhino is using the Brep representation which generates some problems when we export the CAD models to Comsol Multiphysics for FEA. How I can see in the models which surfaces are neighbouring each other ? Is there a “topology” of the model ? I want to detect the open volumes and I don’t know how to get exactly to the topology and the geometry of the Rhino model.

Ion

Hi,
Rhino’s “What” command is the same what rhinoscriptsyntax.ObjectDump function should return. So to make it work, just replace the rs.Command("_-List Clipboard") in the upper code with rs.Command("_-What Clipboard").

You can use the rs.IsPolysurfaceClosed function to check if your brep is closed.

As for the neighbouring brefaces of the brep, you can use the BrepFace.AdjacentFaces method:

import rhinoscriptsyntax as rs

brepId = rs.GetObject("pick up your brep")
brepObj = rs.coercebrep(brepId)

face2 = brepObj.Faces[2]
face2Adjacency = list(face2.AdjacentFaces())
print face2Adjacency

Oh, and Steve is a tennis fan.
I am more interested in soccer.

Sorry… I don’t know how I get t Steve :)…

Ion