Detect execution from rhino or terminal

Hi there, compas noob here

The question isn’t actually about compas directly.
I was wondering if there was a way to do something like this

# detect if file is run from rhino or terminal
from_rhino = False

if from_rhino:
    Artist.clear()

else:
    from compas_view2.app import App

    viewer = App()
    viewer.show()

The goal is to have a single file that can be run in both softs, removing the need to be duplicated when migrating to rhino for example.
I’ve tested couple of thing with os and sys library but nothing so far…

If that’s a terrible idea, please let me know too :smiley:
Cheers,
Antoine

hi antoine,

no, that is not a terrible idea :slight_smile:

you could do something like this…

if compas.RHINO or compas.BLENDER:
    # stuff for Rhino or Blender
else:
    # other stuff

best,
tom
1 Like

That easy !
Thanks !