As a followup to this thread:
Trying to group using dynamo but I get an empty list - Revit - Dynamo
Did anyone find a solution, either in form of a custom package or simply a Python code to be able to create model groups via Dynamo in the Family Editor?
Just to give a little context I have over 500 families which have a preview in our platform via Speckle, but the Speckle API does not allow you to set the preview angle. So many of the families are facing backwards in the preview. The only solution seemed to be if we rotate them 180 deg. in the Revit Family environment. But this only works if group them first as otherwise some components will rotate weirdly.
If you have alternative ideas to my problem than grouping, it is more than welcome 
Cheers,
Boti
Hey,
I don’t think there are nodes, but you could try this… You’ll need to sequentially run it on each family, and you’ll need to run the code inside a family environment…
Mark
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from System.Collections.Generic import List
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
elements = UnwrapElement(IN[0])
elements = elements if isinstance(elements, list) else [elements]
myCollection = List[ElementId]()
TransactionManager.Instance.EnsureInTransaction(doc)
for i in elements:
myCollection.Add(i.Id)
groups = doc.FamilyCreate.NewGroup(myCollection)
TransactionManager.Instance.TransactionTaskDone()
OUT = groups
@botond.gazda I’d say you just adjust the camera, then zoom to fit.
ori = ViewOrientation3D(XYZ.Zero, XYZ.BasisZ, XYZ.BasisY)
doc.ActiveView.SetOrientation(ori)
fam_view = next(filter(lambda x: x.ViewId == uidoc.ActiveGraphicalView.Id, uidoc.GetOpenUIViews()), None)
fam_view.ZoomToFit()
Or just don’t do anything at all, print the views and cache them for html then match them with frontend js, but I’m not sure if this is an option.
1 Like