I think the only solution will be to run the script via a different context (via RevitDynamoModel class) from an addin or a macro some examples