Does anyone know if it is possible to join geometries in a Family Document with Revit API?
I have hundreds of forms created between two profiles and I would like to join them in a specific order that I will set previously. Now I am just testing the workflow for two inputs only (elementA, elementB).
I have tested several nodes from different packages so far; Hot Gear, Clockwork… and not only packages but also the OOTB Dynamo node called Element.JoinGeometry and my own Python script. For the OOTB node and my Python node, a warning shows up saying “Warning: Element.JoinGeometry operation failed. document is not a project document.”. Therefore, I assume that the JoinGeometry method can only be used in a Revit project (.rvt) file with Revit API instead of a Revit family document (.rfa).
So, is there any chance I can use the join geometry button in the Revit family document to join forms created from lofting two profiles? If I try to join two consecutive forms in the Revit family environment the software allows me to do it but as I have hundreds of forms these handy tasks are impossible to carry out.
I looked for any Class in the Revit API related to the “Form” geometries and within that drop down I could see that there are many Methods but none of them make reference to any “JoinForms” functionality.
I highlighted the inputs with watch nodes as you can see in the following image. I have also converted the inputs into .NET lists (I think I did ok as I copied it the lines from one reply marked as the solution in the forum) and lastly, I inserted the .doc.CombineElements.
Which should be called as variableNameHere = CombinableElementArray().
Now we need to add your combinable elements to the array. Checking for methods of the CombinableElementArray class, and we find this: Append Method, which allows appending combinable elements to the array. So since we have a list of items we’d want to iterate over so that all the elements are in the array, we either need a for loop or to utilize some list comprehension. Personally I prefer the list comprehension method, which goes something like this:
initialElementsList = [A,B]
[ variableNameHere.Append(i) for i in initialElementsList ]
And now that we have our combinable element array object, we can feed that into the combine elements method and see if that solves this for us. doc.CombineElements(variableNameHere)
I post the solution… it may help someone in the future…
from Autodesk.Revit.DB import *
from System.Collections.Generic import *
from Autodesk.Revit.UI import *
from System.Collections.Generic import List
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
A = UnwrapElement(IN)
elementsComb = 
initialElementsList = A
for i in initialElementsList:
elementsCombb = CombinableElementArray()
for ii in i:
lst = 
for x in elementsComb:
OUT = lst