Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert a number back into the corresponding enum? #12761

Closed
Wouter0 opened this issue Apr 1, 2022 · 2 comments
Closed

How to convert a number back into the corresponding enum? #12761

Wouter0 opened this issue Apr 1, 2022 · 2 comments

Comments

@Wouter0
Copy link

Wouter0 commented Apr 1, 2022

Dynamo version

Dynamo Core: 2.10.1.3976
Dynamo for Revit: 2.10.1.4002

Operating system

Windows 11 x64

Im converting a script from ironpython 2.7 to 3. In 2.7 everything works fine but in 3 it seems that some Revit API methods are behaving different. The aim is to create colums. The error is: instance of a level based family cannot be created without a valid revit level`
It seems that the XYZ is in the correct place, also the level is right (see below prinscreen), but the column is placed on the level below. This generates the error, but I dont really understand why it is placing the column below the level. The blue line is the column which is placed below the level it should be (level 1). If I turn the detail level on fine the column is not showing. It only seems visible on coarse detail level.

According to members on the dynamo forum where this issue was mentioned before, the problem could be caused by the way cpython handles enums. Im a beginner and am not familiar with this. On github is mentioned that a number can be converted back to the corresponding enum. Im just curious if this could solve the issue.

Below the code that generates the issue:

`TransactionManager.Instance.EnsureInTransaction(doc)

TEMP.append([Level_Rvt])

Kolom = doc.Create.NewFamilyInstance(XYZ(Punt.X/304.8,Punt.Y/304.8,Punt.Z/304.8), Kolom_Rvt, Level_Rvt, Structure.StructuralType.Column)

TransactionManager.Instance.TransactionTaskDone()`

As I understand correctly Structure.StructuralType.Column generates an integer. The question is true how it can be converted back to the corresponing enum?

@Amoursol
Copy link
Contributor

Amoursol commented Apr 5, 2022

Hello @Wouter0, this kind of question is probably best for the Dynamo Forum under the developer category. Have you tried there yet?

@mjkkirschner
Copy link
Member

mjkkirschner commented Apr 6, 2022

see this question:
pythonnet/pythonnet#935
please reopen if this does not help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants