Retrieve window width and height

Retrieve window width and height

Anonymous
Not applicable
2,150 Views
4 Replies
Message 1 of 5

Retrieve window width and height

Anonymous
Not applicable

Hello,

 

Can somebody help me retrieve a window's width and height?

 

This compiles but does not work unfortunately, because it returns "False":

window.get_Parameter(BuiltInParameter.WINDOW_WIDTH).HasValue;

When I cast the parameter with AsDouble() I get 0. The variable "window" is of type "Element".

Accepted solutions (1)
2,151 Views
4 Replies
Replies (4)
Message 2 of 5

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @Anonymous ,

try using the below code

Element Window;
                FamilyInstance fi = Window as FamilyInstance;
                FamilySymbol fs = fi.Symbol;

                double height = fs.get_Parameter(BuiltInParameter.WINDOW_WIDTH).AsDouble();
                double width = fs.get_Parameter(BuiltInParameter.WINDOW_HEIGHT).AsDouble();

I hope this helps

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 5

Anonymous
Not applicable

Thank you so much, this finally works! Maybe you could fix the indentation (if it isn't by design) and swap the width/height variable names, so others who find this thread aren't confused 🙂

0 Likes
Message 4 of 5

Anonymous
Not applicable

What does Element Window get? Because in my case he is saying that the variable window was never used.

0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

If you have not defined the variable `window` then it will not exist and indeed cannot be used.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes