I am back from my vacation. I had a wonderful time.
Now, let's look at two important recurring topics that came up while I was away:
Before getting to those, let me mention some of the nice places and mountain tours I was blessed with in the past few weeks:
Now I am refreshed and happily back at work, so let's continue with the Revit API discussion forum and look at those Revit API issues:
This kind of question comes up on a regular basis, and is discussed in the topic group on driving Revit from outside; now Daren Thomas provided a beautifully succinct answer that says it all in the StackOverflow discussion on starting a transaction from an external application running outside of API context is not allowed:
Question: Starting a transaction from an external application running outside of API context is not allowed. Cannot start transaction.
Answer: Using my magic psychic crystal ball to guess you are asking how to avoid getting this error message in your Revit / RPS plugins, here is a short bit of extra information:
Form
and call into the API from one of the events, e.g., Button.OnClick
What you want to do is figure out how to get back into the API context to execute your code.
There are two main methods for doing this, assuming you have already left the IExternalCommand.Execute
context:
Idling
eventExternalEvent
Since you mentioned RevitPythonShell in the tags, why don't you check out how I used external events in my web server example.
ExternalEvent
(using the event handler just created)my_external_event.Raise()
As said, The Building Coder provides more details and other samples in the topic group on driving Revit from outside.
Question: How can I receive detailed error messages from failed geometry creation calls?
I'm making a call to the doc.FamilyCreate.NewSweptBlendForm method.
However, it throws an exception: Autodesk.Revit.Exceptions.InvalidOperationException.
Unfortunately, the message of the exception is "Cannot create swept blend form."
This does not provide much information, and it's difficult to debug with just this in hand.
Is there any more detailed information that I can access when a call like this fails?
Answer: Unfortunately, the answer is No, not at this moment. The API method makes a direct call to a native method in Revit core which returns an error value, which – again unfortunately – seem to be only either SUCCESS or FAILURE. Additional observation can be made by debugging the concrete case, but for the caller, there is no additional info Revit API can provide. Sorry about that.
The best approach for now might be to create model lines from the input that you are passing into the NewSweptBlendForm method and then execute the sweep in the manual user interface instead. That often provides more detailed info on what is going wrong, as explained in the discussion on debugging geometric form creation.