Revit Objects to Base Using SpecklePy

Dear Speckle team.

Is it possible to serialize Revit geometries to turn them into Speckle Base Objects using SpecklePy within Revit (using PyRevit, for instance)?

I guess I would have to access the Revit converter… can it be done? Is there an example perhaps?

I’d love to know more about your use-case here. :heart_eyes:

The SpeckleRevit Converter is in the core speckle-sharp SDK (with Objects Kit). It does not have an equivalent in SpecklePy to use in PyRevit.

The only overlaps between the c# and python SDKs are with the server Client, Core and the base Objects classes.

All our converters code is available open-sourced, you could translate the specific conversions you needed to python and then handle with specklepy… though it is a few years since I used PyRevit to measure how much success/heartache lise down that road.

1 Like

thanks @jonathon! And sorry for the late reply. I wish I could share more about the specific use case but my client is very protective of their workflows. The main idea is to come up with a way to carry metadata from Revit to GH and back with minimal UI and without any documents involved in the process.

I’m currently evaluating options between many of how to go about this… Would there be anyone in the team that can give a hint of how much heartache would this particular path produce for us in the form of a high level roadmap? @izzylys perhaps?

Izzy is now on to pastures new.

My strongest recommendation would be to use Speckle OOTB. You have a dedicated and passionate team to keep fidelity up for both ends of that workflow and access to the unlocked data in the middle.

1 Like

AFAIK, you can still load SpeckleCore.dll (i.e. Speckle.Core) in pyRevit since it uses IronPython.

The steps described to get it done in a Grasshopper script should also be valid in a pyRevit script.

This will expose the exact same functionality that our Revit Connector uses, including getting access to the Revit converter, making API calls… etc.

Hope that helps!

Full disclaimer: I have never tried to do this before :sweat_smile: so I’m not really sure what would work and what not, but happy to help if you bump into troubles!

EDIT:

If you follow that guide, do note one of the paths points to the location of Core in the Grasshopper connector.

clr.AddReferenceToFileAndPath("C:\\Users\\USERNAME\\AppData\\Roaming\\Grasshopper\\Libraries\\SpeckleGrasshopper2\\SpeckleCore2.dll")

For revit, you’ll find it here:

%appdata%\Autodesk\Revit\Addins\REVIT_YEAR_VERSION

3 Likes

Thanks you both for the prompt reply! What @AlanRynne suggests sounds promising and probably worth giving a try. I’ll dig into to it and keep you posted. thanks again!

3 Likes