Create DirectShape with dynamo geometry in python

Hi all,

I have been trying out Dynamo for a little while and started to learn Revit API and python script as I saw more flexibilities in them.

I have managed to create a solid square with this script:

box_size = 1.0

box = Cuboid.ByLengths(Point.ByCoordinates(0, 0, 0), box_size, box_size, box_size)

I am wondering if anyone would know how to turn this into DirectShape object in Revit?

@henrykTRACD ,

i found this… but it works only smooth for small project.

KR

Andreas

Hi,

Thanks for the reply!!

but I am afraid this video only shows how to create DirectShape with Dynamo node…

Would there be a way to do the same thing with python script??

Springs allows you to see the code that makes up the “Springs.DirectShape.ByGeometry” node. Just make sure to give credit back to the author if you use their code on a thread. Otherwise, you will need to reference the Revit API and build your own.

image

Thanks Stalyor,

I will start digging into the script with Chat GTP~

Considering that the training data for GPT 3 and GPT 4 return results like ‘I am afraid I can’t do that Dave’, you should consider reviewing other learning resources like the Dynamo Python primer. Remember the training data for all large language models is the internet. The overwhelming majority of the code on the internet is for another environment than Revit. And further still most of the code is either incorrect (why it was posted to stack overflow) or incomplete (the answer on stack overflow), and so the LLM is trained mostly on stuff which won’t work for you, or will be interpreted incorrectly.

At some point we’ll have Jarvis for this stuff, but for now learning how things work is recommended.

Edit: One more observation from an absolute legend of a technologist.

3 Likes

I’ve been attempting to focus LLMs to work better with programming Revit. See: https://chat.openai.com/g/g-7gcy5wueV-bim-coding-coach and its repository GitHub - truevis/BIM-Coding-Coach: GPT to be Expert in programming BIM software

The problem with LLMs today is you need to train the models yourself for current tooling to apply, as the current public data set data is either too old (Revit 2021) or train on too many non-Revit related datasets.

Custom curating the dataset can resolve this, but that requires a someone with understanding of LLMs and the Revit API and it’s various on each release. Keep in mind that we are ~5 months away from another set of such changes, which will likely have more impact than usual due to the .net changes which are planned for this release.

I wish you luck on this, and hope that it winds up not being too much work for you. But others with no coding skill or Revit API experience should be cautious that there will often be a large learning curve due to the nature of the responses which LLMs will produce.

2 Likes