Help with phyton to rhino button


(Amilanese) #1

Hi , all . I’m very not experienced in this kind of things . I’ve tried to get a script working helping me to export models from my workflow with some basic checks before to export them .

Some how difficult to explain but it should be easy to understand the script :slight_smile:

import rhinoscriptsyntax as rs

# seleziona l'insieme dellegeometrie da esportare

modello = rs.GetObjects ( " seleziona il modello " , select=True )

#isola la selezione

if modello : 
   rs.Command ("_hide")


geometrie = rs.Command ("_selall")

if geometrie : 
  rs.Command("_hideswap")

if not geometrie : 
   rs.Command ("_show")


modellofinale = rs.Command( "_SelAll" )

if modellofinale :
    rs.Command("_selall _ShrinkTrimmedSrf ")

# verifica che le poli e le srf siano chiuse


solidi = rs.GetObjects(" verifico i solidi " , preselect=True)

if solidi : 
 rs.Command( " _SelOpenPolySrf ")


verificapoly = rs.SelectedObjects()
if verificapoly:
    msg = "ci sono polisuperfici aperte"
    rs.Command(" _SelOpenPolysrf")
    print msg
if not verificapoly :
    rs.Command (" _SelOpenSrf ")
    verificasrf = rs.SelectedObjects()

if verificasrf:
   msg = "ci sono superfici aperte"
   rs.Command(" _SelOpenSrf")
   print msg
if not verificasrf :
    rs.Command (" _SelDup ")
    duplicati = rs.SelectedObjects()

#verifica presenza di duplicati

if duplicati:
    msg = "ci sono duplicati"
    rs.Command(" _Seldup")
    print msg
if not duplicati :

#esporta la selezione

    rs.Command (" _selall _-Export _Pause _Version=5 _Browse" )
    print "tutto bene"

Basically , let’s say you get 5 groups of 10 solids . I want to export one group and check if any of the geometry is open and if any duplicate .

If I run the script on the debug it does what it should … stop me each time any issue is found and drop a message of what the issue is .

If I run it in a rhino command , Including the script in ! _-RunPythonScript ( … )
it still find the issue but it doesn’t show me the right issue message but all of them .

Seems like it should be forced to stop once each time a ‘msg’ is printed

Anyone knows how to fix it ??

thanks :slight_smile:


#2

Well, first, I think there are simpler /more efficient methods to do what you want using various rhinoscriptsyntax native functions instead of calling rhino commands with rs.Command().

To answer your basic question however, a ‘print’ statement does not stop a script, it just prints something to the command line. If you want to stop the script and wait for an OK from the user, use rs.MessageBox() instead of print, that will throw up a dialog on the screen and wait for an OK to be clicked (or Cancel if you program that option). See the rhinoscriptsyntax help for the options on rs.MessageBox().


(Amilanese) #3

thanks a lot … will try asap

also I’ll consider to go with the rhinoscriptsyntax … even if it’s a big world to discover to me :sweat_smile: