Exporting Views as DWF/X WITH Properties

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

.

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
1 Like

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?

@bnydam42,

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

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


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

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:

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

Great.
Well done !

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

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

1 Like

Hi there @bnydam42

I have just tried your script above, but can’t make it work…?

Can you tell me, whats wrong with my attempt?

I get this error:

Hi,

You could use instead of this python script the Export DWFx in Document node of the Genius Loci package.

I would say you should use the script from Genius Loci. It’s actually written by someone who knows what they’re doing. Mine, on the other hand… :roll_eyes:

1 Like

Hi there @Alban_de_Chasteigner and @bnydam

“Problem” is, we use DWF on our project, and not DWFX, so is it possible to export to DWF instead?

Tool.ExportDWFX2.dyf (15.8 KB)


This is what I’m currently using. I’m not sure if I’ve published it or not.

DWFx is only the newest version of the DWF file format.
Anyway you just need to replace :
options = DWFXExportOptions()
by
options = DWFExportOptions()

Hi there again @Alban_de_Chasteigner

I dont know if I should open another topic instead of asking here, but its still related to this…

I run into several problems, when I try to use the DWF exporter from the Genius Loci Package for my linked files (and even the ones, in the file im in):

  • First of all, I tried to make a file naming string, for the node where it says “filename”, but for some reason it gives the files a “double” name (the files should be named what it says in the red box):

image

  • Second, after my filter from “selected sets”, there should be be 58 sheets - But when I Export the sheets, with the node. It never stops?
    When It has completed the 58 sheets, it just starts over…? Last time I stoped Revit after 220 views :stuck_out_tongue:

  • Lastly, for some reason it only exports the first sheet correctly,

All of the rest, only contains the header for the drawing…?

Can you show the inputs document, views and filenames ?
Could be a matter of lacing if you have list of lists or several documents.
The custom node must be set on longest lacing with list of lists.

There you go:

BTW, is there a place I can find/ read when to use longest and so on?