Adding sheets without overwriting existing sheets in project

Hello wonderful and helpful community.

I am having an issue with a script to automate sheet creation. I have set up a working definition, however I have noticed an error which I can’t manage to work around.

Originally my intention was not to create a whole batch of sheets for the entire project in one go. But when I needed to add a sheet or group of sheets, I would copy drawing numbers and titles into a separate excel file of sheets to be added.

The problem is two fold:

  1. Each time the script is run, new views are created which overwrite the existing views already on the sheets. This is an issue as any annotations etc are deleted, as the annotated view is overwritten by a new view (see differing element ids shown below – sheet element id’s remain persistent, but view id’s are not).

(see Fig. 1 and Fig. 2)

  1. In terms of my original intention of adding to the sheets already in the project. If I replace the data in the excel file, for a new set of sheets. When the script is run again, Any sheets or views which had been previously created by the script are deleted (including the views – which don’t go into the project browser – they are completely deleted. In this case the new sheets inherit the old sheet’s id’s (but all data has been changed, the views have new id’s)

(See Fig. 3)

I had tried to ‘get all elements of sheets categories and the views on those sheets’ very early in the definition to see if getting that information into the definition upstream would help with the problem, but it doesn’t.

How can the sheets simply add to those already in the file without the sheets from the definition being the only sheets in the file. Having come from a grasshopper background it seems like the sheets and views need to be ‘baked’ into the revit file, so they become ‘native’ (for want of a better word) revit objects, rather than Dynamo objects. Also I’ve read when dealing with Python scripts, objects need to be wrapped using toDStype(True). This seems to be heading along the same lines.

I am only doing this in a test project, however in current project where many views already exist and team members have annotated and loving cared for them, as it stands the script could not be implemented as it would overwrite everybodys’ drawings. I was simply wanting to automate the tedious bit of the process of creating the new sheets, filling in titleblock info and providing a base drawing to begin work.

I hope I have explained this well enough. Thanks for any help in advance. I would post the definition but as I imagine its quite a generalised issue, I would have to go and purge out titleblock stuff, and recreate a new file without company template etc…

I don’t’ mind doing this, but if its not necessary it seems like quite a faff it this is discussed in general terms.

Many thanks

J-P

I had tried to ‘get all elements of sheets categories and the views on
those sheets’ very early in the definition to see if getting that
information into the definition upstream would help with the problem,
but it doesn’t.

But it should. You’ll need to compare your lists of existing views/sheets with what you have in your Excel sheet in order to avoid duplicates. It would surely help if you showed us how you went about comparing those lists of items.

Can i directly upload the definition?

If not, I used a python script to compare the sheets in the project and the sheets in the excel file as below :slight_smile:
#start script

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

excel_sheets = IN[0]
revit_sheets = IN[1]

new_sheets =

dif = [item for item in excel_sheets if item not in revit_sheets]
for i in dif:
new_sheets.append(i)

OUT = new_sheets
#end script

However this isnt the problem. This nicely spits out the items which are in the excel file list but not in the revit sheets.

My issue is that for instance if I start with a blank project, all sheets deleted, no views. At run#1 the sheets and views are created perfectly.

Situation 1:

A sheet is added to the excel list … The python script successfully only outputs the differing item. The dynamo script runs, however all views created from run#1 have been overwritten by newly created views (annotations / any modifications are deleted) New sheet from run#2 overwrites one of the sheets.

If the number of new views exceeds that already created, all views and sheets from run#1 are gone.

Situation 2:

If the lists are not compared and the same input list is used from run#1 and run#2. Run #1 succesfully creates sheets and views. Run #2 overwrites views on sheets.

I hope this helps and if i can post the definition it would probably help

I will see if I can export run iterations of the script having exported the workspace …

Run #1

.

Run #2

Same input list of sheets

Note the element id’s of the views have changed (in the project browser - the title of the sheets changes from L10(2) to L10(3) - the bracketed number changes every time indicating a new plan has been created

Run # 3

Comparing the lists with Python script. Only one sheet value is going through the process.

At this stage in the browser all previously created view have gone

Are you closing Dynamo at all between runs?

I also had this problem while creating section views. There was nothing I could do to break Dyanmo’s link to those element IDs, even shutting down my computer wouldn’t achieve it. I was only making 1 section at a time so the way I forced a new section to be created was by making the last created section the active view, then Dynamo was unable to edit the element and creates a new one.

I’m not sure how many views you’re trying to create per run, but if it’s only one you could try make it active on each run and see if it works for you.

Hi all, if I don’t filter the views it will overwrite.

Not sure what I’ve done, in my tinkering, filtering by Python script seems to have started to play ball. (which is strange as the tinkering was with the definition.

@jup
This workflow is not overwriting sheets. But it creates empty sheets to a revit project from excel. the only problem for me is that Revit overwrites the sheet number.

Sheet import.dyn (10.6 KB)

You must understand that dynamo process your node by stage. That’s mean when you run a dynamo node you make a transaction but that transaction not yet finish, if you want finish it you must stop dynamo connecting with revit by close your dynamo or you must make a duplicate node to run it in the next stage.

Good luck !