I wanted to have all my family content to have previews set as 3D view. (15K + files.)
I was doing research on this for the past months and it was not easy to achieve due to the fact that I am C# rookie.
I came back to dynamo and started look to get at least 1 family done automatically and the attached image is how far I got. (Yeah, at this point, I am looking into doing it one by one unfortunately.)
My goal is that 1. renames the 3D view as the company catalog standard view, 2. sets the view in correct orientation and 3. save the file with the updated catalog view. (I got #1 working!)
Could you give me some hints on how to achieve this in Dynamo? I believe I combed through all commands and do not see any “save as” nodes.
This is done in C# above and is just an example. If you wanted that in a Dynamo node, you could always create your own or I could roll this in to my package or another package. If you wanted to swap to Python or something, knock yourself out.
From the one graph above, you would have to do the SaveAs “node” if it was created before terminating the application.
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
#Preparing input from dynamo to revit
targetView = UnwrapElement(IN[0])
saveAsOptions = SaveAsOptions()
process = False
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
if doc.IsFamilyDocument :
previewSetting = doc.GetDocumentPreviewSettings()
if previewSetting.IsViewIdValidForPreview(targetView.Id):
previewSetting.PreviewViewId = targetView.Id
saveAsOptions.PreviewViewId = targetView.Id
previewSetting.ForceViewUpdate(True)
process = True
TransactionManager.Instance.TransactionTaskDone()
TransactionManager.Instance.ForceCloseTransaction()
doc.Save()
OUT = process
*Note: * it is better to create a new topic rather than dig up an old one
Built up a full graph with some modified python to iterate over a list of documents found in a directory - this should add a thumbnail to every document in a given directory. As always, use at your own risk (ie: back up your stuff first). Add thumbnail to all families in given directory.dyn (14.7 KB)