I am too busy! Ouch! Here are just a few of today's topics:
- BIM360 Question? Join Accelerator!
- What language to choose for a Revit Add-In?
- The Building Coder samples 2021 migration
BIM360 Question? Join Accelerator!
A quick question on logging in to BIM360 from Håvard Vasshaug and Dimitar Venkov of the Bad Monkeys (not to be confused with the thriller of the same name – featuring Jane, who claims that she works for a secret organization devoted to fighting evil and that she is the operative for the Department for the Final Disposition of Irredeemable Persons, also known as Bad Monkeys):
Question: We are using Revit Batch Processor to open multiple Revit models and run a selection of Python scripts on each in order to standardise their content and settings.
One client is asking if we can build it to support BIM360.
So, we wonder:
Can we use the secure sign-on that's already present in Revit (the one that gives users access through the Revit home screen), so that we can gain access to Forge, see the projects and files shared with that user and finally read the project_Id
and model_Id
of those files?
Do you know where we should be looking and who we should talk with?
Answer: That sounds cool, and the idea sounds good to me.
However, I have avoided involvement with security and credentials as much as possible, so I don't really know.
Your best bet for getting a reliable answer is to ask through the regular Forge help channels.
Better still, another approach yet more effective would be to join a Forge accelerator and ask there.
Since they are virtual nowadays, more people can participate.
That will guarantee you both an answer to your question and ensure you have ongoing support for the proof of concept.
You might even get your whole application completed right away during the accelerator.
How does that sound to you?
Response: I will check out the accelerator program for sure.
Thank you!
What Language to choose for a Revit Add-In?
Question: What language would you recommend me to start learning to program with Revit API? Is Python fully functional by itself or does it need pyRevit installed to work? Can you program independent Applications with Python?
Answer: Here are my off-hand answers:
> What language would you recommend me to start learning to program with Revit API?
Pick the one you like best. It must support .NET.
> Is Python fully functional by itself?
No, because it does not support .NET out of the box. Therefore, you need some kind of .NET support for it to interact with Revit API.
> Does it need pyRevit installed to work?
No, not necessarily. That is one possible way to go. Another is the RevitPythonShell. Another is IronPython.
> Can you program independent Applications with Python?
Yes, by including the .NET support in one way or another.
Anyway, what is 'independent'?
Every Revit add-in needs Revit to execute.
Depending on how your code is packaged, you may need Revit-plus-something.
I do all my work in C#, because then I am completely independent of all the complexities mentioned above.
However, I also sometimes like the flexibility of a Python command line.
The RevitPythonShell gives me that when I really need to dig deeper interactively.
By the way, you can also start off by writing macros instead of stand-alone add-ins.
The Revit macro environment supports both C# and Python right out of the box.
Addendum – C# versus Python
Sean Page adds: I would second what Jeremy stated. I myself am exclusively C# when it comes to add-in or ZT nodes for Dynamo. I just prefer the ease of it just working, and the vast resources openly available for it. I would also say in terms of the Revit API, forcing yourself to use C# and explicitly define everything is a great way to learn, but may be a little slow at first because some things are a little more convoluted than they need to be.
Steve R adds: I would also recommend C#, just because you will find the most examples in C#, and probably the most help from others if you use C#.
I'm still a beginner at this programming stuff, but the comment about Python needing another program to work with .NET confuses me. Both the SharpDevelop built-in macro editor and Microsoft Visual Studio provide the options for either C# or Python. I was under the impression that using either would basically create the same DLL file.
Am I completely misunderstanding, or maybe things have changed and Python no longer has the same limitations it once had?
Richard Thomas adds: Also worth mentioning that Python can be used to extend Dynamo and that is interesting given the possibilities that Dynamo is now offering to those starting out their path to automation, e.g., generative design, rapid generation of geometry, linking different programs etc. Although you can also develop custom nodes in Dynamo with C# but inherently Dynamo is extended with Python code blocks.
Having said that I would choose C# over Python since it is one of the languages explicitly written for .NET. IronPython is a .NET implementation of Python.
If you choose Python at an earlier stage in life then IronPython is how you would write a .NET application with it.
If you choose C at an earlier stage of life then C# would be your choice.
If you are only just making the choice you would choose either C# or VB.Net since they have the best IDE support in VS. Your Tab and BackSpace keys will also thank you, less work for them.
Many thanks for your contributions and clarifications!
Python and .NET
Some ruminations in response to Steve's question above:
Hmm. I am not aware of any possibility to reference .NET assemblies in Python in Visual Studio out of the box.
Yes, Revit's SharpDevelop built-in macro IDE includes support for Python. I believe that uses IronPython internally to hook up the Python code with .NET.
I looked at the overview of Python tools for Visual Studio and found a note saying, Visual Studio also supports IPython/Jupyter in the REPL, including inline plots, .NET, and Windows Presentation Foundation (WPF), but nothing else hinting at .NET support for Python in that environment.
Maybe Visual Studio can be combined with IronPython, as hinted at in the discussion on IronPython – Visual Studio 2010 or SharpDevelop?.
However, I also see this unanswered StackOverflow question on using Python for .NET for Python 3.4 in Visual Studio that seems to indicate it is not supported out of the box.
Actually, if you look directly at the IronPython site and its .NET integration documentation, it seems to be pretty straightforward in any context.
The Building Coder Samples 2021 Migration
I quickly completed the flat migration of The Building Coder samples to Revit 2021, producing release 2021.0.148.0.
The only changes involve the .NET target framework and the Revit API assembly references, cf. the diff to the previous version.
The result of this flat migration generates 162 warnings, all associated with obsolete and deprecated methods and enumerations caused by the Units API changes.