Is it possible to add objects to the document from within a cluster?
This code adds the ValueList object to the cluster document, but I would like to add the ValueList to the “main” document.
Is this possible?
This code adds a ValueList with the elements in the preset list.
preset = ["test1", "test"]
vl = gh.Kernel.Special.GH_ValueList()
vl.CreateAttributes()
vl.ListItems.Clear()
for preset in presets:
preset_str = '"{}"'.format(preset)
vl.ListItems.Add(gh.Kernel.Special.GH_ValueListItem(preset_str, preset_str))
x, y = ghenv.Component.Attributes.Bounds.X, ghenv.Component.Attributes.Bounds.Y
vl.Attributes.Pivot = PointF(x, y)
vl.Attributes.ExpireLayout()
vl.Attributes.PerformLayout()
ghdoc = ghenv.Component.OnPingDocument()
ghdoc.AddObject(vl, False)
Thanks for your help and suggestions!