# Get the view in Python

**URL:** <https://forum.dynamobim.com/t/get-the-view-in-python/51406>\
**Category:** Developers\
**Created:** [June 4, 2020, 1:55pm UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406 "2020-06-04T13:55:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![laurin.ernstMA6Q3](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@laurin.ernstMA6Q3](https://forum.dynamobim.com/u/laurin.ernstMA6Q3)\
**Post date:** [June 4, 2020, 1:55pm UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/1 "2020-06-04T13:55:04Z")

</div>

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](https://forum.dynamobim.com/t/presentation-options-rebar-set/13282/2) 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.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/1/c186984cb5387f87fba2ad413580adf683c9e22d.png)

I get the warning:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/4/54576dedcca186eefeca058d2768dac804860f9d.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [June 4, 2020, 2:10pm UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/2 "2020-06-04T14:10:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![laurin.ernstMA6Q3](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@laurin.ernstMA6Q3](https://forum.dynamobim.com/u/laurin.ernstMA6Q3)\
**Post date:** [June 4, 2020, 2:23pm UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/3 "2020-06-04T14:23:11Z")

</div>

Hey @Nick_Boyts,

i tried the method from this post: [Call View to Open](https://forum.dynamobim.com/t/call-view-to-open/17903/4)  
Looking like:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/5/f560bd434dc9633d25f096ec726827bcd0e6dc5b.png)  
Unfortunately not working, can you help or give me a link to the right post?  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/3/23d273508e58503cc999e7c7b46e7ce6f114a851.png)

Thanks!

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [June 4, 2020, 2:36pm UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/4 "2020-06-04T14:36:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![habdirad](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@habdirad](https://forum.dynamobim.com/u/habdirad)\
**Post date:** [June 4, 2020, 4:23pm UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/5 "2020-06-04T16:23:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![laurin.ernstMA6Q3](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@laurin.ernstMA6Q3](https://forum.dynamobim.com/u/laurin.ernstMA6Q3)\
**Post date:** [June 5, 2020, 6:16am UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/6 "2020-06-05T06:16:05Z")

</div>

@habdirad thanks, now i have this warning:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/3/634b98bf1ccf82b873f678cf8bd255fc17019f7c.png)

If you want to have a look at it (.rvt + .dyn):  
[https://uibkacat-my.sharepoint.com/:f:/g/personal/laurin\_ernst\_student\_uibk\_ac\_at/EnyRCxhdObJGlUbFE33vUk8BSx3w-e70oiPjfFJXxXBsag?e=Kh3hqn](https://uibkacat-my.sharepoint.com/:f:/g/personal/laurin_ernst_student_uibk_ac_at/EnyRCxhdObJGlUbFE33vUk8BSx3w-e70oiPjfFJXxXBsag?e=Kh3hqn)

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

---

<div class="post-metadata">

**Author:** ![habdirad](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@habdirad](https://forum.dynamobim.com/u/habdirad)\
**Post date:** [June 5, 2020, 6:37am UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/7 "2020-06-05T06:37:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![laurin.ernstMA6Q3](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@laurin.ernstMA6Q3](https://forum.dynamobim.com/u/laurin.ernstMA6Q3)\
**Post date:** [June 5, 2020, 9:14am UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/8 "2020-06-05T09:14:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![habdirad](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@habdirad](https://forum.dynamobim.com/u/habdirad)\
**Post date:** [June 5, 2020, 4:11pm UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/9 "2020-06-05T16:11:13Z")

</div>

Congrats 🙂

---

<div class="post-metadata">

**Author:** ![jonathan.laurent](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jonathan.laurent](https://forum.dynamobim.com/u/jonathan.laurent)\
**Post date:** [March 28, 2021, 6:00pm UTC](https://forum.dynamobim.com/t/get-the-view-in-python/51406/10 "2021-03-28T18:00:40Z")

</div>

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