Grasshopper

algorithmic modeling for Rhino

Hi everyone,

does anyone happen to know how to disable/enable components using VB?

Kind regards, Pieter

Views: 1806

Replies to This Discussion

For Each Obj As igh_DocumentObject In GrasshopperDocument.Objects
  If (Obj.NickName = "LockMe") Then
    Dim comp As gh_activeObject = DirectCast(obj, gh_activeObject)
    comp.Locked = Not comp.Locked
  End If
Next

This does not work (only with some componentes/params). Error:

"An object expired during a solution".

D'oh!

Oh yeah, I got that too, but figured I would find out what to do about that next.

Hello! how to solve this problem "An object expired during a solution". thank you!

Attachments:

Thanks for the fast and accurate replies Marcus and Dani:)  
Have I understood correctly if I say I need to cast to GH_ActiveObject (or GH_Component or - indeed Marcus - System.Object) to get access to the components Locked property?
Thanks!

Hello! how to solve this problem "An object expired during a solution". thank you!

Thanks for the  replies! There is no way to solve the problem?   can you help me! thank you

You cannot change the state of the document while a solution is being computed. You need to make your changes after or before a solution runs. One way to do this is to put your logic inside a menu or window (the mouseclicks won't be handled until after a solution is done) or to schedule a solution on the document and use the callback method to trigger your changes. There are also events associated with the beginning and ends of solution you can subscribe to.

 thank you !  maybe myability of  c#  is not enough , after your guidance, i also don't know how to do it ,i am sorry! thank you for your help ! my english is pool ,no offense.

Hi Jerryyang

 I hope this help you! ————NARUTO

hi NARUTO !  i do it as your way ,but when i first time open this gh file after rhino start  ,it will also  have "An object expired during a solution".

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service