data = receive(objectId, transport)
#returns Base object from GH
# convert Speckle Base to Revit Geometry
kit = Kits.KitManager.GetDefaultKit()
converter = kit.LoadConverter(Objects.Converter.Revit.ConverterRevit.RevitAppName)
converter.SetContextDocument(doc)
directShape = converter.ConvertToNative(data)
#returns none
All works well, except that after using the ConvertToNative method I get None.
As a test, I tried receiving a geometry that I send straight from Revit using the same piece of code, and that actually works, implementing the necessary transactions.
Is there a missing step to convert Base objects received from Grasshopper to a Revit Object? Can you guys please point me to what I might be doing wrong?
A snippet of code, even if in C# would be extremelly helpful. @AlanRynne
Hi @AlanRynne. Sorry, I understand that I have explained myself quite poorly. Let me try again:
I am in the context of a Revit Plugin. Taking from this sample that you provided, I’ve created this piece of code:
var streamId = "51d8c73c9d"; //obviously using my own stream here
var branchName = "main";
var defaultAccount = AccountManager.GetDefaultAccount();
var client = new Client(defaultAccount);
var branch = client.BranchGet(streamId, "main", 1).Result;
var hash = branch.commits.items[0].referencedObject;
var transport = new ServerTransport(defaultAccount, streamId);
var receivedBase = Operations.Receive(hash, transport).Result;
At this point, I have a Speckle Base object in receivedBase , which is a DirectShape that is currently in the server (such as the one on the screenshot of the previous post).
Additionally, I load Object.Revit.Coverter2024.dll and create a converter:
var kit = Speckle.Core.Kits.KitManager.GetDefaultKit();
var converter = kit.LoadConverter(Objects.Converter.Revit.ConverterRevit.RevitAppName);
converter.SetContextDocument(doc); // doc is the Revit doc
now, I try to convert the Base object to a Revit obj with the following code:
Hi @janx , you’ll have to traverse the receivedBase first before converting the resulting objects: refer to our traversal docs for more info.
For traversal in Revit specifically, you can use our default revit traversal functionDefaltTraversal.CreateRevitTraversalFunc(converter) which should return your DirectShape object
thank you for your answer @clrkng. I have a few following questions:
Was this concept added recently? I was able to use ConvertToNative as it was a couple of months ago without this
Since I’m only interested in getting the DirectShapes and their parameters, would flattening work in my case?
Could I ask you to please provide a small example of how CreateRevitTraversalFunc work in in the Revit context in order to get the DirectShape? I’m still learning about these concepts and can’t find any other reference anywhere. It would be super helpful
Hmm your traversal implementation doesn’t seem to be the problem, there may be a few possible reasons for the exception including recent changes to our DirectShape conversion, needing to instance the converter properly, or a Settings variable not being instantiated or handled correctly on our end.
I can take a closer look on Monday after we get back from our company retreat, unless @AlanRynne gets around to it first!
Unfortunately, there is no quick fix for accessing our default Update receive mode functionality, so if you’d like your received revit elements to replace existing ones in the document you’ll have to handle that behavior in your plugin after receiving.