Python code for ViewType in CPython3

Hi,

Can someone tell me how to change to code for CPython3? Both nodes contain the same code, but gives another output. I need the same output as in Ironpython but then for Python3. So I need the type as output and not a number.

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

views = UnwrapElement(IN[0])
elementlist = list()

for view in views:
        elementlist.append(str(view.ViewType))
OUT = elementlist

Thanks in advance.

@Lazy_BIM ,

it is more fast forwart - just view

import sys
import System
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

views = UnwrapElement(IN[0])
elementlist = list()

for view in views:
	elementlist.append(view)

OUT = elementlist


KR
Andreas

Hi @Draxl_Andreas ,

I need exactly the same output as the IronPython gives me. I already got the views and now i need the ViewType. For example, view.Name works properly, but view.ViewType gives me a predefined number or something like that.

Offhand I think that the number is an element ID; what do you get if you use it to as such to select an element in the document?

When it’s an element ID it should be unique right? Maybe my print screen will make more clear? with the python part written in the first post.

Unique to the view type ‘floor plan’, after all items are synched with the central. Feed in a section view and see if you get something else.

FYI, here are all the numbers that you will get with each view.

image

1 Like

hello, still too complicated for me
If that can help you
but there is node made for that, I do not understand everything

edit

found here I think numbering sticks with

Cordially
christian.stan

2 Likes

Thanks for all replies, I think I found my solution in the Archilab package for now.

along with import System

this works with just a single input

OUT = System.Enum.GetName(ViewType, elementlist)

4 Likes

Hello and thank you, I understand

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import System
views = UnwrapElement(IN[0])
OUT = [System.Enum.GetName(ViewType,x.ViewType) for x in views]

Cordially
christian.stan

6 Likes

You are the man! I was trying to utilize the GetNames procedure to work with multiple elements.

image

I definitely have a lot more learning to do.

2 Likes

the little white pebbles helped me a lot :+1:

still in the learning phase :wink:
back to my late copy package
Have a good evening
Cordially
christian.stan

2 Likes