Create viewport from wrapped view

HI
I’m trying to use the tool.PlaceViewOnSheet node, with no success so far.
The problem is with the views input which come wrapped in the Dynamo object “Revit.Elements.Views.FloorPlanView”.
When I’m trying to run viewport.create() I get an error because the create() doesn’t except the wrapped view object, and when the object is unwrapped, I get an error the ViewPlan doesn’t have an Id attribute…

Any suggestions?
NewPlaceViewsOnSheets.dyf (12.5 KB)

tbh i don’t see u unwrap anything except a point which is not necessary.

sheet_inputs = UnwrapElement(IN[0]) # unwrap
view_inputs = UnwrapElement(IN[1]) # unwrap
point = point_input.ToXyz() # point = UnwrapElement(point_input).ToXyz() ??

import traceback # u import traceback like three times, one will suffice

The error is not from the unwrapping function. I just mentioned the unwrapping because I get two different errors, depends whether the view is unwrapped or not. When the view is unwrapped, the following error occurs:
v2: Error1 placing view on sheet
v2: Traceback (most recent call last):
File “<string>”, line 62, in <module>
AttributeError: ‘ViewPlan’ object has no attribute ‘Id’

when not unwrapping the view, this error rises:
v2: Error1 placing view on sheet
v2: Traceback (most recent call last):
File “<string>”, line 62, in <module>
AttributeError: type object ‘Viewport’ has no attribute ‘Create’

line 62 is the line where the viewport Create() called:
vp = Viewport.Create(doc, sheets.Id, view_groups.Id, XYZ(0,0,0))

Regarding the traceback import, it is more efficient code to import traceback just in case of an error

here is one i use for cpyhon 3 and should work for views, legend, schedules could probably help


sheet.dyn (14.5 KB)

When the view is unwrapped, the following error occurs:
v2: Error1 placing view on sheet
v2: Traceback (most recent call last):
File “”, line 62, in
AttributeError: ‘ViewPlan’ object has no attribute ‘Id’

aite, i’d like to see a solution as well. ur first if branch works fine on my machine, no exception thrown or anything.

1 Like

which revit are in ? i havent use steamnodes for years as i guess @leeUT3Y6 code come from…that package havent been updated since 2018 :wink:

rvt 26.1.0.35 to be specific.

thanks…thats great…there i think we just have been lucky with that node, which python engine are you using ?

oh cpython3. i did try iron2 but it throws a syntax error, well..

1 Like

Thanks
I tried to use your script but I get the following error:
type object ‘Viewport’ has no attribute ‘CanAddViewToSheet’
Is it a data corruption thing?
It starts to look odd :confused:

1 Like

hmmm…which revit are you in ? i can try go deeper into that but first tomorrow, will be in waste of time "BIM coordinates meeting rest of the day, so i will only be online :wink: :wink: :wink:

ps just for test, try OOTB viewport create node and test if that works, not sure if that node first come in 25, or try rhythms viewport create node

I’m working with Revit 25.
I reinstalled the archilab package and problem solved :upside_down_face:
I upgraded Revit recently, so maybe some files were dragged from the old version…

It also seems to work only once. To make it work again it I need to restart Dynamo… :man_shrugging: