Grasshopper

algorithmic modeling for Rhino

Hello,

I have a custom component that sets properties for a class I have in my code.

It would be elegant if I could re-set these properties when the data is disconnected.

(My alternative is to set a toggle that clears the data, but feel that it is a little un-intuitive).

Is this possible?

TL;DR - Execute code on data that is being disconnected

Views: 741

Replies to This Discussion

Have tried this (function called when an input Boolean = true) but doesn't seem to be working...

public void ReCalcAll()
        {
            GH_Document GHDOC = new GH_Document();
            GHDOC.NewSolution(true);
        }

It doesn't work because you're creating a new document and then solving that. You need to solve the document you're in. If your code is running from within a parameter or component, then do this:

GH_Document doc = OnPingDocument();

if (doc != null)

  doc.NewSolution(true);

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service