Create New Sheet Each Run

Hello all,

I have created a script to generate a new sheet and place standard views on it. If I need to create another new sheet though it just renumbers the first one. Closing Dynamo does not work a full close of Revit must be done. I know this problem has been around for some time now and I was looking for some advice or a point in the right direction.

I read this post from today but I cannot seem to get it to work. This is my attempt at using the code block per @Donald’s recommendation. I also read http://dynamobim.org/cbns-for-dummies/ but I seam to be lost. How does one go about calling out a node with a code block?

Hi @Steven_Hansen,

This topic was discussed here also…

Circumvent Revit Object "replacement"

It seems to be common issue. But, I can see a very good reason why Dynamo should keep track of elements it creates (Element Binding). There are ways to get around it however, Python works for me as the Element Binding does not happen, so a solution is to either code your own, or use another 3rd party package (like clockwork or rhythm etc - I do not know if they have a node that you are after, just saying that if they did then they would work, have a look, if you can’t find one, post back and maybe one of us Python guys will knock one up real quick :wink:)

As for code blocks, this is interesting that you can circumvent Element Binding this way, pretty useful to know. Have you tried creating the script out of the Nodes first then selecting them, right clicking and selecting the “Node to Code” feature. This will convert the nodes to Code Blocks all ported correctly and ready to run.

Also, just for completeness, when you have those yellow errors, could you specify what it is saying, my eyesight is terrible :expressionless:

Cheers,
Dan

1 Like

Hello Daniel,

Thank you once again for the help. Element Binding is very helpful some times and sometimes not so much. To the best of my knowledge the only package with a sheet crater is Konrad_K_Sobon’s Archi-lab; however it only creates placeholder sheets.

I was able to use the Node to Code option (forgot that was in dynamo) to convert the standard block to a code block but that did not seem have any effect.

Personally I do not know how to write code. Tried to learn one time but got nowhere. @Joseph_Peel posted a code he wrote in this post. however I cannot get it to work properly. I feed it a string for the sheet name and number but it breaks them up into individual letters.
Exsample:
Strings I feed - A-105 / Floor Plan
The sheets created in the project (should only be one)
A / F

  • / l
    1 / o
    0 / o
    5 / r

Here is the code he posted.
#Make Sheets
import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager




doc = DocumentManager.Instance.CurrentDBDocument
sheetnames = IN[0]
sheetnumbers = IN[1]
titleblock = UnwrapElement(IN[2]) #unwrapped titleblock
sheetlist = list()



TransactionManager.Instance.EnsureInTransaction(doc) # you need an active transaction as you will create elements
 

for number in range(len(sheetnumbers)):
	newsheet = ViewSheet.Create(doc,titleblock.Id)# create a new sheet where titleblock.Id is the id of the titleblock
	newsheet.Name = sheetnames[number]
	newsheet.SheetNumber = sheetnumbers[number]
	sheetlist.append(newsheet.ToDSType(False))

	
TransactionManager.Instance.TransactionTaskDone()
OUT = sheetlist

Thanks for any help you are able to provide.

Hi @Steven_Hansen,

I had a quick look at the code you are using. The inputs haven’t been wrapped in a list so the len(sheetnumbers) is literally iterating through each character. I have written my own below …

import clr

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

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

def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

sheetNumbers = tolist(IN[0])
sheetNames = tolist(IN[1])
tBlock = tolist(IN[2])

outList = []

i = 0
if len(sheetNumbers) == len(sheetNames):
	while i < len(sheetNumbers):
		TransactionManager.Instance.EnsureInTransaction(doc)
		newSheet = ViewSheet.Create(doc, UnwrapElement(tBlock[0]).Id)
		newSheet.SheetNumber = sheetNumbers[i]
		newSheet.Name = sheetNames[i]
		outList.append(newSheet)
		TransactionManager.Instance.TransactionTaskDone()
		i = i+1

	OUT = outList
else:
	OUT = "Sheet Number Count and Sheet Name Count does not match" 

Hope this helps

Cheers,
Dan

1 Like

Amazing Dan Thank you very much. It works perfectly.

One last thing that is Element Binding. I am using Clockworks FamilyInstance.ByPointInView. It uses a python code but the element I place moves when I create another sheet. Does the code need to be altered with Einar_Raknes comment in the post you linked?

Here is the code used in Clockworks FamilyInstance.ByPointInView

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
points = UnwrapElement(IN[0])
famtype = UnwrapElement(IN[1])
lvl = UnwrapElement(IN[2])
elementlist = list()
counter = 0

TransactionManager.Instance.EnsureInTransaction(doc)
# make sure familysymbol is active
if famtype.IsActive == False:
	famtype.Activate()
	doc.Regenerate()
for point in points:
	newobj = doc.Create.NewFamilyInstance(point.ToXyz(),famtype,lvl)
	elementlist.append(newobj.ToDSType(False))
TransactionManager.Instance.TransactionTaskDone()
OUT = elementlist

I changed that line and it works. Amazing what one line can change. Dan Thank you for all of your help.

You’re welcome @Steven_Hansen! Glad you got it working. :wink:

Hi @Steven_Hansen

Could you drop your final solution here so that it will be useful to others with the similar issue. Thanks :slight_smile:

I was just about to do that. Very sorry should have done it the first go around.

The only change I made was to line 29 (third from last).

Was: elementlist.append(newobj.ToDSType(False))
Changed to: “elementlist.append(newobj.ToDSType(True))”
This node was modified from Clockwork for Dynamo 1.x

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
points = UnwrapElement(IN[0])
famtype = UnwrapElement(IN[1])
lvl = UnwrapElement(IN[2])
elementlist = list()
counter = 0

TransactionManager.Instance.EnsureInTransaction(doc)
# make sure familysymbol is active
if famtype.IsActive == False:
	famtype.Activate()
	doc.Regenerate()
for point in points:
	newobj = doc.Create.NewFamilyInstance(point.ToXyz(),famtype,lvl)
	elementlist.append(newobj.ToDSType(True))
TransactionManager.Instance.TransactionTaskDone()
OUT = elementlist
1 Like