Freeze 3D View to Drafting View

Hi all,

hope you re doing fine.

So, last week on Revit forum I found an interesting add in which was available in 2018. It could “freeze” 3D view and make drafting view out of it. I did a little research and found an article related to topic:

["Freeze" Drawings with Dynamo • ATG USA • %%primary_category%%]

The script involves certain amount of Python knowledge, however, I decided just to recreate it and then maybe have a better understanding of processes involved. However, even though I did everything which is stated in the article, I could not make it work, and my troubleshooting capabilities are not so strong, especially with Python code.

If somebody can give a quick look and maybe point out a direction, it would help greatly

Freeze_Drawing_RVT_20.dyn (89.9 KB)

@Marcelo.Rak You made some error while typing the Python code. Try replacing your code with this:

# Copyright(c) 2016, Konrad Sobon
# @arch_laboratory, http://archi-lab.net

# Import ToDSType(bool) extension method
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

from System.Collections.Generic import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

viewports = []
sheets = []
directory = IN[2]
#Used for import/export of DWG
exportOptions = DWGExportOptions()
importOptions = DWGImportOptions()
vFamTypeIds = []
OUT = []

# IN[0] = Views
# IN[1] = Sheets
# IN[2] = Folder
# IN[3] = Parallel Array w/ Names
# IN[4] = all ViewFamily Types with 'Detail' as name

for famType in IN[4]:
	vFamTypeIds.append(UnwrapElement(famType).Id)
	
TransactionManager.Instance.EnsureInTransaction(doc)
for index, view in enumerate(IN[0]):
	currView = UnwrapElement(view)
	#vset= View Set
	sheet = UnwrapElement(IN[1][index])
	sheets.append(sheet)
	#vSet.Insert(currView)
	vPort = Viewport.Create(doc, sheet.Id, currView.Id, XYZ(0, 0, 0))
	viewports.append(vPort)
	iList=List [ElementId](sheet.Id.IntegerValue)
	iList.Add(sheet.Id)
	sheetName = IN[3][index]
	#Export the sheet with newly created viewport on it
	doc.Export(directory, sheetName, iList, exportOptions)
	length = len(vFamTypeIds)
	for index, id in enumerate(vFamTypeIds):
		try:
			vDraft = ViewDrafting.Create(doc, id)
			vDraft.Name = SheetName
			break
		except:
			if index == length - 1:
				OUT.append("ViewFamilyTypeError")
			else:
				pass
	#Bring the DWG back in as link
	doc.Link(str(directory) + "\\" + str(sheetName) + ".dwg", importOptions, vDraft)
TransactionManager.Instance.TransactionTaskDone()
OUT.append(viewports)

I only had 2 3D views in the model so removed the filtering.


Freeze_Drawing_RVT_20.dyn (40.6 KB)

1 Like

Hi,

thanks for checking out. However, it still gives some sort of error when I try with your script.

image

When I try with mine, and with your code it gives this error

image

@Marcelo.Rak

Try restarting Dynamo and relaunch the graph.
.
.

I get this error when incorrect Detail is selected in the Rhythm_ViewFamilyTypes node.
For me the 1st Detail throws error but the 2nd one works.
Try switching between the two and see if it works.
image

1 Like

@AmolShah Works like a charm. Many many thanks.

However, I am puzzled with behavior of drafting view. I drew few ducts and then ran the script, and I am not sure what kind of drawings are on those views. They are more close to a screenshot than a drafting view.

Initially I was hoping that the view will be consisted of lines which can be manipulated later on. Is that even possible? I suppose i got the wrong idea behind the script.

Nonetheless, thank you for support in this matter.

Have you tried placing your 3d view on a sheet and then exporting it as a .dwg? Then you could import the .dwg and explode it. You can probably automate the exporting and importing process.

1 Like