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
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.
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?
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.
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.
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