Sketch lines with floors

Sketch lines with floors

Anonymous
Not applicable
2,078 Views
7 Replies
Message 1 of 8

Sketch lines with floors

Anonymous
Not applicable

Good morning,

 

We have a doubt with Revit API, we wanted to relate the floors with their sketch lines, it means, when we get the ID of the lines that make up the floor we want to know the relation that has with the ID of that floor.

How could we do this?

 

Thank you,

 

We are looking forward to your response.

 

 

0 Likes
Accepted solutions (1)
2,079 Views
7 Replies
Replies (7)
Message 2 of 8

Revitalizer
Advisor
Advisor

Hi,

 

there is another thread about the relationship between an element and its sketch:

https://forums.autodesk.com/t5/revit-api-forum/filled-region-line-styles/m-p/5837481/highlight/true#...

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 8

Anonymous
Not applicable

Thank you so much

0 Likes
Message 4 of 8

Anonymous
Not applicable

Thank you so much. We have been checking this code but it has not been useful for us. We are not able to relate the sketch lines with the appropiate floor.

 

If anyone can help us, we would be very grateful.

 

Thank you so much

0 Likes
Message 5 of 8

FAIR59
Advisor
Advisor

you can find the sketchlines with the TTT  (temporary transaction trick)

 

            StringBuilder sb = new StringBuilder();
            Dictionary<Floor, List<ModelCurve>> dict_SketchLines = new Dictionary<Floor, List<ModelCurve>>();

            Document doc = revit.Application.ActiveUIDocument.Document;
            List<Element> _floors = new FilteredElementCollector(doc)
            .OfClass(typeof(Floor))
            .ToList();
            foreach (Element e in _floors)
            {
                Floor f = e as Floor;
                List<ElementId> _deleted = null;
                using (Transaction t = new Transaction(doc, "temp"))
                {
                    t.Start();
                    _deleted = doc.Delete(e.Id).ToList();
                    t.RollBack();
                }
                bool SketchLinesFound = false;
                List<ModelCurve> _sketchCurves = new List<ModelCurve>();
                foreach (var id in _deleted)
                {
                    // find modelcurves. these are the lines in the bounderysketch
                    ModelCurve mc = doc.GetElement(id) as ModelCurve;
                    if (mc != null)
                    {
                        _sketchCurves.Add(mc);
                        SketchLinesFound = true;
                    }
                    else
                    {
                        if (SketchLinesFound) break;
                    }
                }
                dict_SketchLines.Add(f, _sketchCurves);
            }
            foreach (Floor key in dict_SketchLines.Keys)
            {
                List<ModelCurve> _curves = dict_SketchLines[key];
                sb.AppendLine(string.Format("floor {0} has sketchlines:", key.Id));
                foreach (ModelCurve mc in _curves)
                {
                    sb.AppendLine(string.Format("    {0}  <{1}>", mc.GetType(), mc.Id));
                    sb.AppendLine(string.Format("       <{0}  --  {1}>", mc.GeometryCurve.GetEndPoint(0), mc.GeometryCurve.GetEndPoint(1)));
                }
                sb.AppendLine();
            }
            TaskDialog.Show("debug", sb.ToString());
Message 6 of 8

Anonymous
Not applicable

Thank you so much for your answer.

 

We are able to get the floor's ID and the sketch lines' ID. We want to know how do we relate those IDs with the floor ID.

 

Thank you and we are grateful for your answers.

 

 

0 Likes
Message 7 of 8

FAIR59
Advisor
Advisor
Accepted solution

there isn't a fixed relation between the ElementId of the floor and ElementId of the SketchLine.

If you need to find the floor from a SketchLine, then you'd have to fill your own Dictionary<Elementid  of SketchLine, ElementId of Floor> in the second foreach -loop in my code.

Message 8 of 8

Anonymous
Not applicable

Thank you so much for your answer.

 

We can already relate the ID of the floor's with the sketch lines' ID.

0 Likes