ConvertToNative() not returning a valid converted Revit object

@clrkng after following this discussion and implementing your sample code I’m having trouble getting ConvertToNative() to return a valid Revit object. The original SpeckleBase object was a furniture element sent from a Revit Model to Speckle via the desktop manager. I’m trying to pull it into a new Revit model.

I successfully get a valid Speckle RevitInstance object, which I pass into converter.ConvertToNative(). But it doesn’t return a valid converted object. Why?

I tried two methods for getting the converter but both failed; one using
var converter = kit.LoadConverter(Objects.Converter.Revit.ConverterRevit.RevitAppName) and another using
var converter = new ConverterRevit();

Converter.CanConvertToNative() returns true for the RevitInstance object I am having trouble converting.

Oddly, the converter.Report doesn’t even register that a conversion was tried and failed.

22/08/24 14:09:59 Using converter: ConverterRevit v2.20.1.16204
22/08/24 14:09:59 Using document: C:\Program Files\Autodesk\Revit 2023\Samples\RAC_basic_sample_project.rvt
22/08/24 14:09:59 Using units: mm

Any thoughts on what is going wrong? thank you for your help.

Okay, after a lot of trial and error, we were able to get it working by using the ConvertToNativeDisplayable instead of ConvertToNative! We are going to look into when to use which one, but a lot of our Revit objects that get pushed to Speckle are pretty complex, so that is maybe a cause of our troubles.

We are making a webapp that can place objects into Revit and place them based on a set of rules, so this core logic was something we needed before we can implement the placement rules. Once we have a small PoC, we will try to share via the Showcase category.

2 Likes

Hi @cscox , sorry for not getting back sooner!

It’s hard to say why the RevitInstance was failing to convert without more information: you could try inspecting the appObj log property for more clues.

In general, the logic flow in our connectors can utilize 2 bindings:

  1. Direct Conversion using .ConvertToNative() , meaning the loaded converter will try to convert an object directly into a native object if CanConvertToNative = true
  2. Fallback Conversion using .ConvertToNativeDisplayable(), meaning the loaded converter will try to convert any geometry objects found in the displayValue property of the input object.

The second binding is used in two cases: (1) when CanConvertToNative = false, or (2) when ConvertToNative failed (as in your case above)

Hope this provides some more context for you in how our connectors handle conversions!

1 Like