Launch an application/external script with GhPython

Hi,

I have just started using GhPython, so the question might be very easy to answer.

I have created an external python script and I would like to run it from my GhPython script. If I want to do it in python the script would be:

import os

os.system("C:\Users\Stavroula\Desktop\test.py")

and it would execute the python script. When I use the same commands in GhPython it says that "Execution completed successfully" but it doesn't really execute the script.

Is there maybe another way to run external scripts-applications in GhPython?

Thank you for your time!

  • up

    Stavroula Schoina

    Hi again,

    in the end I think that the command is not the problem. I have tried to run Ansys in batch mode and even though it seems that it is opening the batch file in the end it is not calculating anything. It gives an error.

    If I run the .bat file outside grasshopper then I have no problem.

    So, i guess that the launching of applications from grasshopper is blocked. 

    Does anyone know how to solve this issue?

    Thank you!

    Stavroula

    2
    • up

      筑梦NARUTO

      You can upload your file?

      1
      • up

        Henrik Leander Evers

        Hi Stavroula

        I would import the .py script as a python module. This means you can access the functions within the .py script.

        I upload a modified .py script and gh script. You should make sure to change the sys.path.append('C:') to the place where you put your .py file. 

        The output file will end up in c: as well. this can be changed in the .py file. 

        I hope this helps

        Henrik

        1