Get the view in Python

Hey everyone,

I am trying to write my first Python Code and want to set the presentation mode of my rebar set in a specific view. I copied the code from this post Presentation Options - Rebar Set but i want to change it from the active view to a specific view (IN[0]). My code is not working and i think it’s because of the view input.

I get the warning:

That’s not the method for specifying a view to set active. There are a couple threads in the forum that have already answered this. Try searching for one of them and let us know if you have any questions.

Hey @Nick_Boyts,

i tried the method from this post: Call View to Open
Looking like:

Unfortunately not working, can you help or give me a link to the right post?


Hard to tell what you’re doing without seeing your code. The error says you haven’t defined the variable used to set the view. I’m guessing you just copy/pasted the code without changing anything? MyView represents the view you’re setting as active. That would be view1 in your case.

in the code:
Lines 26 and 28 show “myview” vs “myView” (capital V), they should be consistent.

@habdirad thanks, now i have this warning:


If you want to have a look at it (.rvt + .dyn):

Packages used: Structural Design + KB (my own; the .dyf is also in the link)

This is a limitation of Dynamo that does not let you open a view while a dynamo run is in process (the only possible scenario is activating the view as the last step in a dynamo workflow).

Why do you want to have that Line 28 (change the view)? Presentation mode for rebars can be adjusted even without opening the views. I would remove Line 28.

Thanks! It worked as i wanted it to! First Python script… yaaay!

1 Like

Congrats :slightly_smiling_face:

HI, I’ve an error message " object has no attribute ‘SetPresentationMode’" and my object are rebar
Have you got an idea?