Skip to content
This repository was archived by the owner on Jan 6, 2021. It is now read-only.
This repository was archived by the owner on Jan 6, 2021. It is now read-only.

Access/Overwrite the code inside the GHPython from another GHPython component #54

Closed

Description

@mostaphaRoudsari

I wonder if there is a way that I can can access the code inside the GHPython components on canvas and modify/overwrite them from a GHPython component.

I'm thinking to use this method to update the components that I share with others as user objects. I want to iterate through the components, read the code, check if it is old (in my case there is a line that indicates the version) and overwrite the code with a newer version in case there is a newer version.

Thanks,
Mostapha

Activity

  1. piac commented on Nov 7, 2013

    @piac
    Member

    Hi Mostapha

    this shows how to achieve an update of the code from another Python component. I made this into a working example, so you can choose the way you would like this to work: either manually, one by one (this is not possible with the usual upgrader), or all components at once.

    updater

    https://github.com/mcneel/ghpython/blob/master/Samples/quickUpdater.gh

    Giulio

    Giulio Piacentino
    for Robert McNeel & Associates
    giulio@mcneel.com

  2. piac commented on Nov 8, 2013

    @piac
    Member

    @mostaphaRoudsari: please let me know if this helps -- otherwise, please feel free to open this issue again. Thanks!

  3. mostaphaRoudsari commented on Nov 12, 2013

    @mostaphaRoudsari
    Author

    @piac Thanks for the reply. It gives me the error below when I try to open the file. Seems to be an issue with the ghx file. I tried to fix the file but I couldn't get it to work.

    updatescript

  4. piac commented on Nov 12, 2013

    @piac
    Member

    @mostaphaRoudsari I've changed the sample to .gh to have it more easily downloadable

  5. mostaphaRoudsari commented on Nov 13, 2013

    @mostaphaRoudsari
    Author

    Hi @piac, Thank you for the new file. I can't still open the file. I asked a friend to test it and he wasn't able to open the file either. Do you have a guess why this is happening? What if you just share the code inside the component?

  6. piac commented on Nov 14, 2013

    @piac
    Member

    This is just a file on Git -- you can download the whole source, which you already did once, and it will be there. Otherwise, follow the link. Then you'll see the "raw view" link. That is the file that you are supposed to save...
    I just tried and it worked well. If this does not work, there are some issues on GitHub...

  7. mostaphaRoudsari commented on Nov 14, 2013

    @mostaphaRoudsari
    Author

    Hi Guilio, I will try it on more systems and will let you know if I could open it. Thanks.

  8. mostaphaRoudsari commented on Nov 14, 2013

    @mostaphaRoudsari
    Author

    We tried on another system and now it is working fine. Exactly what I was looking for. This is a great help. Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions