Have you ever wondered how to convert a Revit macro into an addin? You can follow Harry’s steps over at this post.
What about getting some sample code for Python and Ruby Revit projects? From AEC DevBlog:
… the code examples are hidden in the default macro projects created by macro manager, see below image, the project is the default python project, there are several “if False” statements, if you remove the line of “if False”, uncomment and unindent 4 spaces to methods below it, the methods will become available macros and appear in the macro manager, and you will see the same “if false” in Ruby projects too:
Original post: http://adndevblog.typepad.com/aec/2016/03/revitapi-how-to-find-code-examples-for-macro-of-python-or-ruby.html
You may also be interested in the Revit Python Wrapper here http://revitpythonwrapper.readthedocs.io/en/latest/
Daren Thomas started a GitBook to describe how RevitPythonShell and Revit interact, and perhaps you may find something useful that could assist with creating custom Python nodes for Dynamo…
Scripting Autodesk Revit with RevitPythonShell – GitBook
Konrad and Mostapha are working on something, and the functionality does not look shrimpy at all. Check it out:
“Mantis Shrimp is a Dynamo (Revit) and Grasshopper (Rhino) interoperability project that allows you to read Rhino’s native *.3dm file type as well as export geometry from Grasshopper. It is written in Python in form of a user objects (on Grasshopper side for exporting) and custom Python nodes (on Dynamo side for importing). It’s an OPEN SOURCE project with all of the source code available on GitHub. At the moment it’s a collaboration project between myself and Mostapha Sadeghipour.
I decided to make this project an open source for multitude of reasons but most importantly because it was written on top of Dynamo (an open source project) using OpenNurbs (an open source project) and inspired by Rhynamo (an open source project to be in December 2014), and finally I was helped along the way by Mostapha who’s almost never written anything that he didn’t like to share. I think i got the “bug” – not Ladybug – for sharing from him.
Here’s how to get started with Mantis Shrimp…”
Read the rest at:
mantis shrimp – getting started… | archi-lab
Check out the solution suggested by Andreas Dieckmann:
“I ended up using one of Python’s abilities to handle lists which is called groupby() because I did not want my head to hurt thinking about how to go about this in Dynamo… 😉
- Sort list by X values using the method Steve explains above
- Sort list by Z values
(Notice that within each group of equal Z values, the X values retain their order from the previous sort operation)
- Create a list of lists with XYZ values (sublist 0) and just Z values (sublist 1)
- Group that list of lists by the Z values (using a custom node with some Python code inside)
- Extract only the list of lists of XYZs by combining two map nodes
You will need the package Group List of Lists By Key for this to work.
(For what it’s worth, I also uploaded another package called Sort List Of Lists this week which was related to that project but isn’t needed here. But it might be worth checking out, too.)”
From the github page:
uses a python script to automatically generate Revit journal files. When run, these journal files handle opening a specified model, instigating the testing plugin, and running the specified test. This document outlines the components of the Dynamo Revit Test Framework and provides examples of how to run NUnit tests against Revit from the command line.
results file is a proper nunit results file and should be able to be parsed as such by continuous integration systems like Jenkins, etc.
… by using a very wild script from dp Stuff!
Comes with a disclaimer:
Warning! Make sure you don’t run this script on your central model – detach it from central first. Because once the views are gone – they are GONE! Don’t tell me that I didn’t warn you – use it at your own risk.
Download Revit IronPython Shell script via
dp Stuff: Remove Working Views With Python Shell and Revit API
I have previously posted about RevitPythonShell a number of times. In this post Dima Chiriacov gives a real-world example on using the shell to change the case of text.
There are quite a number of free add-ins which can easily change case too, like this one or this one (which also allows merging of text).
Read how to use RevitPythonShell at:
DP stuff: Convert Revit Text to Upper Case
Nathan Miller strikes again:
I am creating a strange ‘catenary’ surface with Kangaroo and Grasshopper. I am then feeding the information into an Excel spreadsheet and reconstructing the shape using Adaptive Components via RevitPythonShell. Note how I am also able to adjust the radius parameter of the pipe members within Revit to reflect the ‘force’ diagram created in Kangaroo.
The Proving Ground by Nathan Miller: Revit API: Divided Surfaces and Excel Interop
You can implement randomization in your scripts using the .NET Random class. For example the following code will return a random double number between 0 and 1 in the RevitPythonShell…
Read more at:
Revit API: Randomization – THE PROVING GROUND