How to get LocationCurve for BuiltInCategory.OST_Roofs using c# .net

How to get LocationCurve for BuiltInCategory.OST_Roofs using c# .net

nitesh.jung.thapa
Community Visitor Community Visitor
370 Views
3 Replies
Message 1 of 4

How to get LocationCurve for BuiltInCategory.OST_Roofs using c# .net

nitesh.jung.thapa
Community Visitor
Community Visitor

Hi. 
We have a Revit Addin under development that takes Revit components and converts them to SVG. We Get LocationCurve for walls, stairs, windows,and Rooms ,   Tessellate the curve and get Path for SVG from the Polylines of the tessellated curve. However for elements under BuiltInCategory.OST_Roofs,  Locationcurve is returned as Null. 
For other elements like wall if we take Element.Location as LocationCurve it works,
but for roofs same approach returns null.

FilteredElementCollector collector = new FilteredElementCollector(doc);
            ElementCategoryFilter roofFilter = new ElementCategoryFilter(BuiltInCategory.OST_Roofs);
            IList<Element> collection = collector.WherePasses(roofFilter).ToElements();

foreach(var elem in collection) {
  //here variable locationcurve is returned null. 
  LocationCurve locationCurve = elem.Location as LocationCurve; 
}

 

0 Likes
371 Views
3 Replies
  • .net
Replies (3)
Message 2 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support

HI @nitesh.jung.thapa ,

 

Please take a look at the below code

FootPrintRoof footPrintRoof;
ModelCurveArrArray modelCurveArrArray=footPrintRoof.GetProfiles();

ExtrusionRoof extrusionRoof;
ModelCurveArray modelCurveArray=extrusionRoof.GetProfile();

With the help of ModelCurveArrArray and  ModelCurveArray, you can access the location curve.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

nitesh.jung.thapa
Community Visitor
Community Visitor
Hi. Thank you for your prompt response.
I have tried using the
FootPrintRoof footPrintRoof;
ModelCurveArrArray modelCurveArrArray=footPrintRoof.GetProfiles();
but how can I get the locationcurve from ModelCurveArrArray?
I can only loop through the modelCurveArrArray , but cant get the LocationCurve .

0 Likes
Message 4 of 4

RPTHOMAS108
Mentor
Mentor

You don't get LocationCurve from a ModelCurveArrAray which is more of a sketch i.e. containing multiple curves.

 

You iterate the array of curve arrays to extract the ModelCurves then from each of those you get the geometry curve via ModelCurve.GeometryCurve. You are then using the Curve.Tesselate method as you would for LocationCurve.Curve. If that is meaningful for your purpose, I can't tell i.e. why would you consider the outline + openings of a footprint roof to be its location that says nothing about its height.

 

For roof by extrusion you deal with ModelCurveArray because it is defined by a single set of connected model lines extruded into the screen (of section/elevation) to define the roof.

For footprint roof you deal with ModelCurveArrAray i.e. outer loop and inner loops for openings defined on plan.

 

Neither of these are synonymous with LocationCurve. It is like asking for the location curve of an elephant (tusk/trunk/tail/foot prints which?).

0 Likes