Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sketch lines with floors

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
nerea.albeniz
1539 Views, 7 Replies

Sketch lines with floors

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.

 

 

7 REPLIES 7
Message 2 of 8
Revitalizer
in reply to: nerea.albeniz

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
nerea.albeniz
in reply to: Revitalizer

Thank you so much

Message 4 of 8
nerea.albeniz
in reply to: Revitalizer

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

Message 5 of 8
FAIR59
in reply to: nerea.albeniz

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
nerea.albeniz
in reply to: FAIR59

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.

 

 

Message 7 of 8
FAIR59
in reply to: nerea.albeniz

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
nerea.albeniz
in reply to: FAIR59

Thank you so much for your answer.

 

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community