Placing views on sheets by coordinates

Hi,

Please see the script I have created so far. It creates and places sheets, but not in the location I would like.

I am wondering if there is a way to specify a coordinate location to place a view on a sheet, or any other way of defining the precise location of the view.

Thanks.

1 Like

hay ,
did you find the soloution i have the same problem like your problem

Hi @mbnbrs.

Here is an example using Python to place views on sheet at specific locations (Note: I have only allowed for one sheet at a time)…

PlaceViewsOnSheetByLocation.dyn (31.6 KB)

I have also added a way to visualise View Placement before actually placing in Revit.

I hope this helps.

Cheers,
Dan

17 Likes

Fantastic, thanks @Daniel_Woodcock1
Being able to visualise the placement is really useful.

Ha, you’re welcome @mbnbrs, I threw in the Pre-Visualisation as it can be a headache trying to place them without context.

Glad it helped! :slight_smile:

Cheers,
Dan

That’s pretty awesome man!
would adding a for loop for the Sheets in the python script allow placement for more than one at a time ? ( am still a beginner in python )

Hi @Mohammadz,

Yup, I have revised the code as shown below, just switch the code out in the Python node with this instead…

################### Import References ###################
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 *
################### Definitions ###################
def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]
################### Inputs ###################
#get the bool in port IN[0]...
r = tolist(IN[0])
r = r[0]
#get the sheet in port IN[1] and UnwrapElement if not already...
sheets = tolist(UnwrapElement(IN[1]))
#get the views in port IN[1] and UnwrapElement if not already...
views = tolist(UnwrapElement(IN[2]))
#get the points in port IN[2] (no need to unwrap as these are Dynamo Points)...
locs = tolist(IN[3])

################### Outputs ###################
outList = []

################### Script ###################
if r:
	if len(views) == len(locs):
		for sht,v,l in zip(sheets, views, locs):
			TransactionManager.Instance.EnsureInTransaction(doc)
			try:
				if Viewport.CanAddViewToSheet(doc,sht.Id,v.Id):
					vp = Viewport.Create(doc,sht.Id,v.Id,l.ToXyz())
					outList.append(vp)
			except Exception, e:
				outList.append(e.message)
			TransactionManager.Instance.TransactionTaskDone()
		OUT = outList
	else:
		OUT = "Number of Views must match the number of Locations"
else:
	OUT = "Set Run to True"

Let me know if you have any trouble.

Cheers,
Dan

9 Likes

Hi Dan,

Hope you keeping well.

I tried your new pyhton code above but i cannot get it to work on the following scenario.

I have 5 sheets that i want to add 3 different exisitng views (15 views) so each sheet has 3 different views with 3 different location on each sheet.

It only do it on the first sheet it does not loop.

Are you sure the new python do loop? For each sheet add 3 different views.

Thanks a lot

Try making sure all your lists are the same length and same structure. If three views go on each sheet, make sure you input that sheet three times.

1 Like

@Nick_Boyts
Thats how i did to make it work. I count the views and cycle the sheet id 3 times so sheet, views and location matches. What i cannot do is to loop to the next sheet and do same but to the new sheet, new 3 different views and same 3 locations.
thanks

There shouldn’t be any looping. You need to cycle the points too. If you have 5 sheets with 3 views each you should have 15 sheets with 15 views at 15 points.

I think thats already what i did.

Sheet 1…i cycle the sheet id 3 times…so 3 sheets, 3 views , 3 locations

My issue is how do i go to the next sheet…

Sheet 2…??..wont now apply the same concept above even if i have 3 views and 3 locations…i cannot find a way to cycle Sheet 2 (3 times).

Maybe i am missing or misunderstanding you…apologies.

Can you show me what you have so far?

Thanks a lot. I will post tomorrow. I will tidy it a bit as its in a mess now coz i am playing with it. I will also add some notes as per above so it will be clear for you. Thanks a lot for you time.

Hi…i got it now…you are correct…

I just need to cycle and list.create to get 15 sheet id’s…

Dan, apologies its ok now…thanks nick.there is no problem actually…just need fresh eyes…or fresh brain in my case…cells are fried…

Hi @4bimfercesp/@Nick_Boyts ,

Was just about to have a look and seems it’s solved already which is great as I have as many cells this week as an amoeba! Glad you guys got it working. :wink:

Hi @Daniel_Woodcock1 / @4bimfercesp,

First @Daniel_Woodcock1 thanks for the python script it’s awesome, managed to get single views on single sheets to work!

Happy to start a new topic as this has been solved but wondered if you could help, either by showing a graph that shows it working for multiple sheets/views?

Heres a graph that im working on. Any help much appreciated.

Kotey

Hi. Can you post your dyn and the dyf so i can adjust it and repost. If not the answer is that you need to have the same number of sheet ids. views. locations. I can see you have mismatch…you have 18 locations 6 views and 2 sheets. They do not match on numbers. Also views should not be duplicated on sheets as it will not work. Maybe it will be good to start a new topic. I or Dan i think will be happy ti help. For me its just the weekend so i can answer you with graphs and dyn next week. Or others in the forum may be able to.

1 Like

Hi all,

Sorry I haven’t got to this sooner, I have been exceptionally busy. With that said, I have updated the nodes in this thread in the thread below to handle multiple sheets - raised by @Kotey.Nikoi

There is a new preview node too so you can visualize all the sheets and view locations easily (it creates a tiled array in the Dynamo viewport - handles multiple sheet sizes too).

Move on over to the thread in this post for any new updates/comments as I think this thread has got to it’s end. :smile:

Cheers,
Dan

6 Likes

@Daniel_Woodcock1 you are awesome! Thanks for sharing!!!

2 Likes