Trouble using Speckle.Objects.Objects.BuiltElements

Objective
Access Speckle.Objects.Objects.BuildElements namespace in a Rhino8 Grasshopper C# component.

Issue
I was struggling to access the Speckle.Objects namespaces in the Grasshopper C# component. Specifically the BuiltElements namespace. I solved it, but am sharing here for others.

Solution
import the specific nuget package version you expect (in my case 2.21.3)

The Problem
I want to access all of these namespaces, as shown on the speckle-sharp github

I am able to import both Speckle.Core and Speckle.Object nuget packages but the using statements confused me.

In my ASP.NET application (which used 2.21.3), my using statements look like this:

But in Grasshopper, rather than Objects.NameSpace I need write Speckle.Objects.NameSpace. This doesn’t match the Speckle\Objects\Objects... structure shown on github.
image

What is really odd is that some of the child namespaces work, but not all:

As you can see below, I am able to use those namespaces that import.

The clue that tipped me off to the package issue: I had to include the z and units when creating a point, but on github these are listed as optional. Perhaps I am using an older version of the nuget package?


Once I specified the specific package version I expected, the using statements worked as expected and I could access all namespaces.


Hi @LelandCurtis_BMcD

Are you sure you’re using 2.21.3 in grasshopper? I suspect you’re actually using some 3.x version (which, won’t be compatible with Speckle.Core)

The namespaces you’re showing (e.g. Objects.Structural, Objects.GIS, etc..) only exist in the 2.x.x versions of Speckle.Objects, where all objects are namespaced Objects.

In the 3.x.x versions of Speckle.Objects, all object models are namespaced under Speckle.Objects., and many of the namespaces you’re showing no longer exist since we’ve switched to a DataObject based design.

(see this topic for discussion on this change)


You should either use 2.21 everywhere, and reference everything via using Objects. namespaces etc…, and enjoy all of the v2 object models.
OR
Remove your reference to Speckle.Core, and reference only v3 of Speckle.Objects, referencing everything via using Speckle.Objects. namespaces, where you will find a much leaner set of object models to match the data sent from our next gen (i.e. v3) connectors.

Thanks Jedd. Yes, seems my confusion was that I was familiar with v2, but was importing v3.

As you point out, I should also be importing the specific version of Speckle.Core that I want to ensure it is v2, not v3.

Thanks for the clarification.

1 Like

Perfect, sounds like you’ve made some progress.

To simplify things, It should be possible to only reference the Speckle.Objects nuget.
Speckle.Core (v2) or Speckle.Sdk (v3) should be pulled in automatically as dependencies of Speckle.Objects.

Unless you’re planning on loading Speckle.Objects dynamically (e.g. using v2’s Kits feature), there’s no real reason to reference Speckle.Core directly (although, assuming you have the versions aligned, no real harm either)


For v2, just reference the latest 2.x Speckle.Objects, e.g. 2.21.3
For v3, just reference the latest 3.x Speckle.Objects, e.g. 3.2.0

Oh, I didn’t realize that. That helps clean things up.

1 Like