andydandy74 / DynamoAutomation

Batch-processing of Revit models using the Dynamo visual programming environment
MIT License
62 stars 23 forks source link

Impossible to export families #8

Closed andydandy74 closed 9 years ago

andydandy74 commented 9 years ago

@ikeough - Probably not an issue that can be solved quickly but something worth discussing, I think.

I tried to tackle scenario C (export, modify and reload families) and started with a graph that was supposed to export selected families from a project. Unfortunately, the Revit API provides no direct way of exporting a family. Instead you have to call doc.EditFamily(famdoc), famdoc.SaveAs(fampath) and famdoc.Close(). This obviously requires a transaction which doesn't seem to sit well with Dynamo. I didn't have problems previously with transactions in Python nodes for creating or modifying Revit elements but I guess this is a special case as I am switching documents and Dynamo won't have that. The graph is here: 13c63cdaf2844dec6accfdf60f2514aaae5148f4 The error message says:

Warnung:IronPythonEvaluator.EvaluateIronPythonScript fehlgeschlagen.
Traceback (most recent call last):
  File "<string>", line 22, in <module>
Exception: The document is currently modifiable! Close the transaction before calling EditFamily.

As I said - I don't think there's a quick fix for this, but maybe I am missing something. I didn't want to create an issue on the Dynamo repo (yet) because I first wanted to discuss it with you.

ikeough commented 9 years ago

@andydandy74 This one is tough. The document manager is made to continue pointing at the open document regardless of whether you open another document. The transaction manager uses the document manager's current doc when defining a transaction. So I don't think, even if you can open a new family document, that the document and transaction managers will know anything about it.

andydandy74 commented 9 years ago

@ikeough - I suspected something like that. It would be great if the Revit API came with direct support for family export without having to open the family first, but I guess that's something for the Revit APi wishlist. So for the time being, this is not going to work - I'll just list this as one of the limitations in the class handout. I do have another use case which involves family creation based on imported SAT files created in Dynamo (think room geometries for instance) which I think would work but I'll have to weigh that against using the new DirectShape tools.