Message 1 of 12
Draw Space Separation Lines

Not applicable
02-03-2016
05:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everybody!
I am working on a macro to synchronize all Room or Spaces beteween models.
It seems quite easy (get element insertion points from the linked model --> create a space in the same point in the current model).
As you know, when the rooms/spaces depend on any space separator line, my tool should also get all the separator lines and replicate them in the current model... Here is the issue.
As per shown in the code below, i have nanaged to create a model line where a space separation is. But, now, I do not know how to convert it to a Space separator line 😞
Has anyone any experience with creating this kind of lines?
any idea is welcome!!
public void repSpaces() { UIDocument uiDoc = this.ActiveUIDocument; Document doc = this.ActiveUIDocument.Document; Selection sel = uiDoc.Selection; #region Select the linked model //---------------------------------------------------------------------------------------- Reference r = sel.PickObject(ObjectType.Element, "Select Linked Model"); Element slctdLnk = doc.GetElement(r); //---------------------------------------------------------------------------------------- // // #endregion #region Collect all Rvt Links //---------------------------------------------------------------------------------------- FilteredElementCollector collector = new FilteredElementCollector(doc); IList<Element> elems = collector.OfCategory(BuiltInCategory.OST_RvtLinks).OfClass(typeof(RevitLinkType)).ToElements(); //---------------------------------------------------------------------------------------- // // #endregion #region Find the Linked document that matches with the selected linked model //---------------------------------------------------------------------------------------- foreach (Element elem in elems) { RevitLinkType lnkTyp = elem as RevitLinkType; foreach (Document lnkDoc in this.Application.Documents) { if (lnkDoc.Title.Equals(lnkTyp.Name) && slctdLnk.Name.StartsWith(lnkDoc.Title)) // // { #endregion #region Get Room separation lines and draw space sepatation lines in current model //---------------------------------------------------------------------------------------- FilteredElementCollector lineColl = new FilteredElementCollector(lnkDoc); lineColl.OfCategory(BuiltInCategory.OST_RoomSeparationLines); using (Transaction t = new Transaction(doc)) { t.Start("Add Space Shared Parameters"); foreach (ModelLine l in lineColl) { LocationCurve loc = l.Location as LocationCurve; XYZ stPoint = loc.Curve.GetEndPoint(0); XYZ enPoint = loc.Curve.GetEndPoint(1); Level level = l.Document.GetElement(l.LevelId) as Level; string levelName = level.Name.ToString(); FilteredElementCollector collLev = new FilteredElementCollector(doc); IList<Element> levels = collLev.OfClass(typeof(Level)).ToElements(); foreach (Element e in levels) { if (e.Name == levelName) level = e as Level; } SketchPlane skP = SketchPlane.Create(doc,level.Id); Line line = Line.CreateBound(stPoint,enPoint); ModelLine mline = doc.Create.NewModelCurve(line,skP) as ModelLine; } t.Commit(); } } } }