Get the Radius of a Circle (model line)

Get the Radius of a Circle (model line)

Anonymous
Not applicable
841 Views
2 Replies
Message 1 of 3

Get the Radius of a Circle (model line)

Anonymous
Not applicable

Hi,

I want to get the Radius of a circle. I drew this circle by using the model line.

With the following Code I can collect all model line not only the circles but what I want is only the circles and their Radiuses:

 

Document document = commandData.Application.ActiveUIDocument.Document;

UIDocument uiDocument = new UIDocument(document);

FilteredElementCollector collector = new FilteredElementCollector(uiDocument.Document);

ICollection<Element> collection = collector.OfClass(typeof(CurveElement)).ToElements();



0 Likes
842 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

Dear Habib,

Well, first of all, a curve element is a purely geometrical abstract object and will not appear in the database and therefore never be found or retrieved by the filtered element collector, so OfClass(typeof(CurveElement)) is no use.

You have to search for database objects instead, your model lines (well, they are not lines, actually, are they?), then extract the ones whose curve elements are in fact arcs, and then query each arc for its data.

So maybe this will give you what you need:

FilteredElementCollector collector
= new FilteredElementCollector(uiDocument.Document)

.OfClass(typeof(ModelArc));

There is normally no need to use ToElements, since you can iterate over the collector itself straight away.

 

Best regards,

Jeremy
--
Jeremy Tammik
Autodesk Developer Network -- http://www.autodesk.com/joinadn
The Building Coder -- http://thebuildingcoder.typepad.com




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

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you very much,

I am using now this code. It works good 



ICollection<Element> collection = collector.OfClass(typeof(CurveElement)).ToElements();


foreach (Element e in collection)
{
if (e is ModelArc)
{
LocationCurve curve = ((LocationCurve)e.Location);
Arc arc = (Arc)curve.Curve;

radius = arc.Radius;

}

}

 

With my best regard 

Habib 

0 Likes