Grasshopper

algorithmic modeling for Rhino

Hi all,

I'm trying to automate the process of creating userObjects and I want to automatically set all the values for the popup menu. Name, NickName and Description will be set to Component.Name, Component.NickName and Component.Description however it is not the case for the rest of the fields. Showed in red in the image below.

Where can I change the default values for these fields? I tried to set Component.Category, Component.SubCategory, and Exposure but it doesn't change the default values.

Ideally I like not to see this window and just save the component as a userObject. For now I'm using GH_ComponentServer.NewUserObject which opens the dialog window.

Thanks,

Mostapha

Views: 1079

Replies to This Discussion

Try something like this:

Dim uo As New GH_UserObject()

uo.Icon = ....
uo.Exposure = ....
uo.BaseGuid = obj.ComponentGuid

uo.Description.Name = ....

uo.Description.Category = ....

....


uo.CreateDefaultPath(True)
uo.SetDataFromObject(obj)

uo.SaveToFile()

--

David Rutten

david@mcneel.com

Thanks!

One more quick question.

How can I access the list of the components in a Grasshopper tab, and then access the objects. I want to check the name and the message of the object before overwriting them.

Thanks again,

Mostapha

In case someone has the same question gh.GH_UserObject(filepath) does the job for the userObjects.

Hi guys, I was just doing the same thing and it seems to work. One thing though, if I set the uo.Path property the ribbon does not update once the user object has been saved to file. The ribbon updates as expected with uo.CreateDefaultPath(True) and no uo.Path set. Any ideas?

Attached both cases (with a GHPython component making a user objects of itself).

Thanks and best..

Attachments:

Hi Anders, Have you tried Grasshopper.Kernel.GH_ComponentServer.UpdateRibbonUI()? This should force updating the ribbon.

Thanks Mostapha, I hadn't tried that one yet (still digging around the GH SDK :). Afraid it doesn't seem to do much, at least how I'm calling it (see attached). If I unload/reload Grasshopper the created user object loads ok. So I wonder if there might be some other method I need to call or some property I haven't set correctly.

Attachments:

Looks the ribbon only updates if the uo.path is set to the default user objects folder. Wonder if there is some event that is triggered perhaps.

Interesting! I have never noticed this since we always create userObjects inside the default folder. Did you find a solution for this?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service