SpeckleElements checking against category

For SpeckleUnity and SpeckleUnreal, I’d like to have some optional texturing assigned to some of the various values a SpeckleMesh’s “SpeckleType” could equal but it’s unclear what the range of values potentially are:

For the streams I’ve tested so far, the speckle types that have a category typically follow the pattern of “Mesh/{Category}”. Meshes from rhino seem to come back as just “Mesh” and the same seems to be true for breps. But I’m getting confused between the readme for speckle elements and the enums I found in the source code: SpeckleElements/Enums.cs at master · speckleworks/SpeckleElements · GitHub

The enums are all plurals and there’s no inclusion of “GenericElement” among them while the types I do end up seeing on my streams are singular and prefixed with the type of SpeckleObject they are.

Does anyone know where I can find a clear list of all the values a SpeckleMesh’s “SpeckleType” value could be? I need this to basically make a giant switch statement and texture columns as concrete, topology as grass and so on but I’d prefer to know the exact values without needing to make a stream with every conceivable object type and see what I end up with.

@pablothedolphin, I believe you’ve got to look in the Base.cs file. Here’s where the GenericElement is defined: SpeckleElements/Base.cs at d43ed28d8f09461beeae755261db691105081ea9 · speckleworks/SpeckleElements · GitHub

The name following the / isn’t a category so much as a subclass. Speckle Core will look for a conversion method for the right-most name, and if it can’t find it, it will fall back to the types to the left. (This is why you were able to import the SpeckleStructural geometric elements - SpeckleCore was falling back to the CoreGeometry conversion methods). @dimitrie, @teocomi - you could in theory have more than two type names, right? (If you create a sub-class from a sub-class?)

Anyhow, I think the full list of types that you are looking for are the public partial classes in Base.cs

1 Like

Yep, @daviddekoning is correct!

The type field (should) keep track of the full inheritance chain. You could have a type defined as SpeckleMesh/CustomSpecialTypeA/EvenMoreCustomTypeB. Conversion will try ToNative on EvenMoreCustomTypeB, if not present, it will fall back to CustomSpecialTypeA and ultimately SpeckleMesh (or whatever the base type actually is).

As @daviddekoning said, the full list of stuff that a SpeckleMesh acts as a “base” fallback type for can be found in the kits type defs.

Those Enums are, afaik, added by for other reasons, pertaining to the rather new DirectShape class that @teocomi added.

1 Like

Correct, enums are only for the Revit DirectShape and Revit Curve elements: SpeckleElements/DirectShape.cs at e9782022c08e80946fda92a0f3f15f52e9f21b95 · speckleworks/SpeckleElements · GitHub
We use them to automatically generate dropdowns in Grasshopper when using the SchemaBuilder component. Hope it makes sense!

1 Like