Get Level Elevation From selected windows form combobox

Get Level Elevation From selected windows form combobox

zrodgersTSSSU
Advocate Advocate
845 Views
2 Replies
Message 1 of 3

Get Level Elevation From selected windows form combobox

zrodgersTSSSU
Advocate
Advocate

So im trying to get the elevation of the level that i select in my windows form. I have it populating all the levels but now i cant figure out how to get the level elevation back.

 

 

CODE IN FORM:

zrodgersTSSSU_0-1622071756205.png

 

CODE IN SCRIPT: 

zrodgersTSSSU_1-1622071832291.png

 

i just need the elevation from the selected level. Thanks ahead of time for any help!

0 Likes
Accepted solutions (2)
846 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni
Accepted solution

You are passing in the level name as a string to the document GetElement method.

 

That will not work. GetElement expects either an ElementId or a UniqueId argument:

 

https://www.revitapidocs.com/2021.1/8760be74-50fd-6809-aec6-3cb168d03ea5.htm

 

The latter is represented by a string, so GetElement tries to interpret your level name as a string.

 

You need to store either the level element id or unique id in your combo box as well.

 

You can attach it as additional data to each combo box entry.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

zrodgersTSSSU
Advocate
Advocate
Accepted solution

Thank you for your response. This is what ended up working for me. 

FORM:

zrodgersTSSSU_0-1622112935580.png

COMMAND:

zrodgersTSSSU_1-1622113005717.png

 

 

0 Likes