“Element.Location.Curve.Length” will retreive the length of the element.
Element have Location property but Location class doesn’t have curve property. So how this code is retrieving the curve?
What type of element ate you getting the Location for? Things like Walls “Location” is a curve because they are line based elements.
http://www.revitapidocs.com/2019/c17263d3-481f-ff41-6657-55064d3a629d.htm
“The Location property returns an object that can be used to find the location of an object within the project. An object may have a point location, such as a table or may have a line location. A wall is an example of an element that has a line location.” from RevitDocs.
That means you’ll get a LocationCurve and you’ll have to look in the LocationCurve Class instead.
With the LocationCurve you can get the Curve (Curve class) and from there you can retrieve the length.
Edit: @SeanP was faster than me.
Location class is the base class of LocationPoint and LocationCurve.
When you obtain the location of a valid element using the Element.Location it returns the base class object. You then need to downcast it to the appropriate sub class to access the location Curve or Point. A wall for example has a LocationCurve as its curve-based, so casting to this class (as opposed to LocationPoint) would be successful and LocationCurve has the Curve property you mentioned, which enables access.
To answer you question then, the syntax you posted in your OP works thanks to Python - it dynamically casts for you enabling the compiler to locate the Curve property in the LocationCurve subclass. Python ‘syntactic sugar’.
For comparison, it’s probably worth mentioning the same syntax would fail in C# as you would need to downcast explicitly (to LocationCurve) before you could access the Curve property.
To learn more you should look into inheritance as it will help you to understand the mechanics at play here.
i was trying to get the location of duct element.