Python libraries for geometry

I have a question for everyone who uses PyRevit for geometry generation/analysis.

I recently started to work with generating geometry and collecting data from point clouds through Revit API & PyRevit. I know that many computional designers prefer to use PyRevit for document- and family- related tasks and Dynamo for geometry. However, when working with such heavy things as point clouds, I find PyRevit way better than Dynamo in terms of basically everything - performance, level of control, deployment for the team, being able to use reliable third party libraries.

Speaking of libraries, there are many great and reliable ones for the computional-heavy tasks - like numpy, opencv for edge detection, open3D. It’s practically impossible not to use them because thanks to their lower-level optimizations, they do a lot of things many times faster than plain python.

But what I also often do is just simple geometric operations, like measuring a distance between two points, or between a point and a line, or angle between vectors etc. I’ve noticed that many of them repeat themselves very often in my code so I started thinking about using a library for that too. I tried to search for some existing ones on the web but surprisingly, didn’t find many. And the ones I found don’t really suit my needs and don’t seem reliable in terms of long term support. I think the closest one to what I’m thinking about are maybe Compas, or Shapely? But they don’t fully cover what I would like them to.

Because my scripts generally run headless until they deliver their final output in Revit, sometimes I print some outputs from the code while testing to paste it to Dynamo and visualize. So what I would expect from such library would be being able to control output I get from some operations, like for example a set of 2D lines can be described in many of different ways: 4 lists containing their start and end point x and y coordinates, or tuples etc. And it would be great to have these outputs standarized for testing purposes. I was thinking about some custom classes that would have optional outputs.

So here’s the question: do you have any Python geometry libraries to recommend? Or maybe someone has tried to write their own library for that? I’m thinking about it myself, but I don’t know if it’s a good idea - I don’t want to reinvent the wheel. Maybe joining some open-source project could be the solution? I’m still pretty new to programming so I could be missing something :smiley:

2 Likes