Strange, in C# ScriptComponents the following code works fine ("if (obj is Box)") but not in Visual Studio. Why is that? Inspection shows that I have a valid obejct of the right type, but the code doesn’t enter the if-block:
if (obj is Box)
{
bbox = (Box)obj;
...
}
else if (obj is Brep)
{
brep = (Brep)obj;
...
It seems I cannot read either Box or Brep with the same input (as generic object or Brep) and then cast it to either. But in the ScriptComponent this code was no problem (with input hint set to System.Object). Can you @DavidRutten (or someone else) shed some ligth on this?
Also note that a Box could be an Extrusion object. Grasshopper usually casts these to Breps automatically since it has no internal support for extrusions.