Exporting Views as DWF/X WITH Properties


#1

I am in need some basic scripting help, I’ve been undergoing some trial by fire, but learning python is quickly moving up my list of things to do…
I need some 3d views exported to Navisworks, and they need to include the object properties. When I export through Revit, the properties come through, but the node that I’ve been using (Tool.ExportDWF) doesn’t include the properties. My few rudimentary attempts at incorporating the DWF(x)ExportOptions ExportObjectData have been a . How can I incorporate this into the Tool.ExportDWF script?
Thanks!

#python nodes in dynamo 1.0
#proposed by Julien Benoit @jbenoit44 
#http://aecuandme.wordpress.com/
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

views = []
for i in IN[0]:
	views.append(UnwrapElement(i))
	
folder=UnwrapElement(IN[1])
name=UnwrapElement(IN[2])

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

a=ViewSet()
for v in views:
	b= a.Insert(v)
	
t=DWFExportOptions()
t.ExportObjectData = IN[4]
u=DWFExportOptions()
u.MergedViews = IN[3]
v=DWFXExportOptions()
v.MergedViews = IN[3]
w=DWFXExportOptions()
w.ExportObjectData = IN[4]
if IN[5]==True:
	c=doc.Export(folder,name,a,v,w)
else:
	c=doc.Export(folder,name,a,u,t)



# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT=c

Here is the original:

#python nodes in dynamo 1.0
#proposed by Julien Benoit @jbenoit44 
#http://aecuandme.wordpress.com/
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

views = []
for i in IN[0]:
	views.append(UnwrapElement(i))
	
folder=UnwrapElement(IN[1])
name=UnwrapElement(IN[2])

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

a=ViewSet()
for v in views:
	b= a.Insert(v)
	
x=DWFExportOptions()
x.MergedViews = IN[3]
y=DWFXExportOptions()
y.MergedViews = IN[3]
if IN[4]==True:
	c=doc.Export(folder,name,a,y)
else:
	c=doc.Export(folder,name,a,x)



# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT=c

.


#2

Hi @bnydam42,

You have to many DWFExportOptions() in your script.
You can simplify like this :

#python nodes in dynamo 1.0
#proposed by Julien Benoit @jbenoit44 
#http://aecuandme.wordpress.com/
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

views = []
for i in IN[0]:
	views.append(UnwrapElement(i))
	
folder=UnwrapElement(IN[1])
name=UnwrapElement(IN[2])

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

a=ViewSet()
for v in views:
	b= a.Insert(v)
	
x=DWFExportOptions()
x.MergedViews = IN[3]
x.ExportObjectData = IN[4]
y=DWFXExportOptions()
y.MergedViews = IN[3]
y.ExportObjectData = IN[4]
if IN[5]==True:
	c=doc.Export(folder,name,a,y)
else:
	c=doc.Export(folder,name,a,x)



# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT=c

#3

Thank you! The script works now…but it still doesn’t put out the properties. Any ideas why or how I can get the properties via dynamo? Do I need to collect the properties somehow before I can export them?


#4

@bnydam42,

It works perfectly for me. I have all the object data exported.


#5

The only properties that seem to get attached are ‘Item’ and ‘Timeliner’. If I export via the Revit DWF exporter (with object properties enabled) I get all the rest of the properties. I had assumed that the problem was with the script, but if it’s working for you I’m not sure. Do you get all the properties returned with the script or are there more available if you export via the Revit exporter?
Merci



#6

In Design review, the files are the same with DWF Revit Exporter and the Python script.
I didn’t test with Naviswork.


#7

Just tried the online Design Review viewer, and it seems to recognize even fewer properties than Navisworks. This is the same file exported via Revit DWF export that showed all the properties:


#8

I doubled back and rechecked my code to find a spelling mistake. It Works!


#9

Great.
Well done !


#10

SO, this script has been working great, but I had some time to look at the new and improved (???) Dynamo 2.0. This promptly broke the script. I now get a TypeError: expected str, got List[object] when it tries to run the export.
> “Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
> Traceback (most recent call last):
> File “”, line 57, in
> TypeError: expected str, got List[object]”

Is this a result of the new lacing changes?

So far I have tried getting around the error by attempting to pull the view names from the IN[0], and I can pull list of view names using view.viewname, but all of the files are named with the first view name in the list. I don’t fully understand how

a=ViewSet()
for view in viewlist:
b= a.Insert(view)

forces the script to iterate through all the views in the list, but I was trying to figure out how to pull the current view name from the view being inserted into the current viewset, but was unsuccessful.

Any ideas how I can
a) get the correct view name to the doc.Export(folder,name,a,y), or
b) pull the view name from the viewset portion of the script.

#python nodes in dynamo 1.0
#proposed by Julien Benoit @jbenoit44
#http://aecuandme.wordpress.com/
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

output = []

folder=UnwrapElement(IN[0])
name=UnwrapElement(IN[5])
viewlist = []
for i in IN[1]:
viewlist.append(UnwrapElement(i))

#name = []
#for view in viewlist:
# name.append(view.ViewName)

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

a=ViewSet()
for view in viewlist:
b= a.Insert(view)
# for view in viewlist:
# name=view.viewname

x=DWFExportOptions()
x.MergedViews = IN[2]
x.ExportObjectData = IN[4]
y=DWFXExportOptions()
y.MergedViews = IN[2]
y.ExportObjectData = IN[4]
if IN[3]==True:
c=doc.Export(folder,name,a,y)
else:
c=doc.Export(folder,name,a,x)

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT=c

#11

Figured out a solution to this node not handling a list of names.
Modified it so that when MergeViews is not selected, it will pull the view name from the list of views, and use that for the file name.

#python nodes in dynamo 1.0
#proposed by Julien Benoit @jbenoit44 
#http://aecuandme.wordpress.com/
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument


folder=UnwrapElement(IN[0])

viewlist = []
for v in IN[1]:
	viewlist.append(UnwrapElement(v))

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

if IN[2]==False:
	
	for i,v in enumerate(viewlist):
		a = ViewSet()
		b = a.Insert(viewlist[i])
		name = viewlist[i].get_Parameter(BuiltInParameter.VIEW_NAME).AsString()
	
		x=DWFExportOptions()
		x.MergedViews = IN[2]
		x.ExportObjectData = IN[4]
		y=DWFXExportOptions()
		y.MergedViews = IN[2]
		y.ExportObjectData = IN[5]
		if IN[4]==True:
			c=doc.Export(folder,name,a,y)
		else:
			c=doc.Export(folder,name,a,x)
else:
	a=ViewSet()
	for v in views:
		b= a.Insert(v)
		
	x=DWFExportOptions()
	x.MergedViews = IN[4]
	x.ExportObjectData = IN[5]
	y=DWFXExportOptions()
	y.MergedViews = IN[4]
	y.ExportObjectData = IN[5]
	if IN[4]==True:
		c=doc.Export(folder,name,a,y)
	else:
		c=doc.Export(folder,name,a,x)

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT=c