Hi, I am looking for a way to instantiate and use the ConverterRevit on my own (without the connector). Right now I am getting some null reference exceptions from it. Probably because I am not initializing it correctly?
I wish it was that easy
var collector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StructuralColumns);
var columns = collector.ToElements();
var converter = new ConverterRevit();
var speckleObjects = converter.ConvertToSpeckle(columns);
Hey there, sorry you’re having some trouble with this. We’re chatting internally but can you post a call sack in the meantime and show us the NRE you’re experiencing?
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Objects.Converter.Revit2023
StackTrace:
at Objects.Converter.Revit.ConverterRevit.ParameterToSpeckle(Parameter rp, String paramInternalName, Boolean isTypeParameter, String unitsOverride)
at Objects.Converter.Revit.ConverterRevit.AddElementParamsToDict(Element element, Dictionary2 paramDict, Boolean isTypeParameter, List1 exclusions)
at Objects.Converter.Revit.ConverterRevit.GetAllRevitParamsAndIds(Base speckleElement, Element revitElement, List`1 exclusions)
at Objects.Converter.Revit.ConverterRevit.ElementTypeToSpeckle(ElementType revitType)
at Objects.Converter.Revit.ConverterRevit.ConvertToSpeckle(Object object)
at Ark.Revit.Core.Main(IDesignAutomationData data) in C:\Dev\ark\Ark.Revit\Core.cs:line 54
Most of these classes live in the RevitSharedResources20XX nuget packages, so you may want to add that to your project with the right version for your Revit target.
If you look at the SetDocumentContext implementation, it will expect multiple inputs specially important on send is the RevitDocumentAggregateCache, for receive you may need to set some extra ones.
Just did a quick search of how we’re using this on send/receive, I suggest you mimic this on your side.