Hi,
I am trying to filter categories by level, and name then export these to an FBX through Dynamo. Can the FBX export be called in Dynamo through python?
The OUT in the attached image is what needs to be exported to FBX
Thanks,
Hi,
I am trying to filter categories by level, and name then export these to an FBX through Dynamo. Can the FBX export be called in Dynamo through python?
The OUT in the attached image is what needs to be exported to FBX
Thanks,
Hi @faisalB ,
There is a node in data-shapes package to export views to fbx. You could do the filtering in a revit view through “VV” menu then use “export view to fbx” node .
Thanks @Mostafa_El_Ayoubi
I am trying to automate the filtering process by level instead of having to create views and “VV” each view. This is to export big files as smaller FBXs, then automate an import/assembly in 3DS Max(given that is possible there…).
I was checking your python code, it seemsthat the doc.Export requires a “view” param/input. Probably it has to do with how Revit exports “views” rather than selected objects
Sorry for the late reply @faisalB ,
indeed the export to FBX method only works with viewsets :
you can still automate the creation of the views to export and the filtering of the elements they contain before you export !
This is what I am trying at the moment, duplicate the 3D view, Set the visibility to certain categories ,then export. The python API doc is not the best ( there seems to be differences between the pythonshell and that in Dynamo…)…
Any Help would be appreciated
Oooh. Thanks Mustafa!
One last thing, in your FBX python code, do you need to change the t.start(), to start the transaction to : TransactionManager.Instance.EnsureInTransaction(doc)
and the t.commit() to : TransactionManager.Instance.TransactionTaskDone() ?
Thanks Again!!!
t.start and t.commit work the same , to my knowledge, they just allow to name the transaction .
I just tried the export and it works fine but I realized that the input description was very bad, and the code was trying to get one directory path per view to export, which doesnt make a lot of sens… it’s a rather old node … I changed it, you can download the latest version of the package :
or use this code:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
t = Transaction(doc,'export')
t.Start()
folder = IN[0]
name = IN[1]
views = IN[2]
result = []
vset = ViewSet()
for n,v in zip(name,views):
vset.Insert(UnwrapElement(v))
result.append(doc.Export(folder,n,vset,FBXExportOptions()))
t.Commit()
OUT = 'You Have successfully exported %d 3D views to FBX format' %(result.count(True))
. I tried the FBX code, it didn’t run until I changed the transaction as mentioned above.
This is mentioned in the GitHub Wiki
Check the transaction section.
And it Work!!
Thanks Again Mustafa
Hey @Mostafa_El_Ayoubi , did some adjustments to your code (visibility of certain category by view, so that each category can be exported to a separate FBX. This is given that the visibility of all Categories is of in the initial 3D view).
Just wanted to share
import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import*
clr.AddReference(‘RevitServices’)
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import System
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
folder = IN[0]
name = IN[1]
views = UnwrapElement( IN[2])
categories = UnwrapElement(IN[3])
result =
for n,v,category in zip(name,views,categories):
v.SetVisibility(category,System.Boolean(True))
vset = ViewSet()
vset.Insert(v)
result.append(doc.Export(folder,n,vset,FBXExportOptions()))
TransactionManager.Instance.EnsureInTransaction(doc)
OUT =‘You Have successfully exported %d 3D views to FBX format’ %(result.count(True))
Hello Mostafa,
I am new to Dynamo. I want to convert several revit family models (.rfa files) (more than 30) to .fbx through dynamo. Is it possible or Is there a script already made?