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:
- all Revit API calls should happen inside the "API context"
- this "API context" lives in a special thread
- you are probably accessing the API from another thread
- this often happens when you make a
and call into the API from one of the events (Form
)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):
- polling for jobs inside the
eventIdling
- using an
ExternalEvent
Since you mentioned RevitPythonShell in the tags, why don't you check out how I used external events in my web server example.
- create an
IExternalEventHandler
- implement its
methodExecute
- (the
method runs in the Revit API context)Execute
- create an
(using the event handler just created)ExternalEvent
- when you need to do something in the Revit API context, notify the external event (
)my_external_event.Raise()