Given a Brep in Grasshopper, I want to determine, using a Python component, whether it is a Referenced Brep from Rhino or a local Brep in GH. I assumed that Grasshopper.Kernel.Types.GH_Brep.IsReferencedGeometry would give me that info, but it isn’t doing so. Where am I going wrong?
Not sure exactly why this is happening, but I suspect some internal type casting is erasing the distinction.
As a hacky workaround, you can access the parameter data directly and read the descriptions.
# This gets all the data from the parameter flattened into a single list
data = ghenv.Component.Params.Input[0].VolatileData.AllData(False)
for goo in data:
brep = goo.ScriptVariable()
description = goo.ToString()
if "Referenced" in description:
# Do something
else:
# Do something else
I think it is probably that I am creating a new instance of a GH_Brep rather than referencing the pre-existing one. That leaves me not seeing a viable route from the Brep to it’s containing GH_Brep - if anyone can point one out, I will be hugely grateful…
In the meantime, thanks for the workaround. I can use that approach for the time being:
and explore getting from the Parameter to the GH_Brep to the Brep to get the full combination of data that I need in the more complex component where this problem originally arose.