Tap Disconnecting when splitting pipe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
when i split a pipe the tap is disconnecting. i tried some methods but it didn't works.
while splitting i disconnect the tap, deleting it and reconnecting back by using rolling offset method
(doc.create.NewTakeoffFitting(PipeConnector,PipeCure). it works. but in some cases i have multiple back to back fitting directing connected to tap (like two elbows). in that case it didn't work. because the two pipes are not perpendicular to each other. and in some case i have only fittings and valves attached to tap, no pipes.
this is my spliting code
*
* Created by SharpDevelop.
* User: ShibuC
* Date: 6/25/2019
* Time: 10:16 AM
*
*/
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB.Plumbing;
namespace SplitPipe
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("F7C70D87-D69A-4229-BA65-DC7CD459BF0F")]
public partial class ThisDocument
{
private void Module_Startup(object sender, EventArgs e)
{
}
private void Module_Shutdown(object sender, EventArgs e)
{
}
#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
public void InsertCoupling()
{
UIDocument uiDoc = new UIDocument(this.Document);
Pipe pipe = this.Document.GetElement(uiDoc.Selection.PickObject(ObjectType.Element)) as Pipe;
ElementId _pipeMEP = new ElementId(pipe.MEPSystem.GetTypeId().IntegerValue);
ElementId _pipeType = new ElementId(pipe.PipeType.Id.IntegerValue);
ElementId _pipeLvl = new ElementId(pipe.ReferenceLevel.Id.IntegerValue);
using (Transaction t = new Transaction(this.Document, "Split Pipe"))
{
t.Start();
LocationCurve lc = pipe.Location as LocationCurve;
Curve cu = lc.Curve;
var ptStart = cu.GetEndPoint(0);
var ptEnd = cu.GetEndPoint(1);
double len = pipe.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
var midPoint = cu.Evaluate(len / 2, false);
var midPoint2 = midPoint.Multiply(1.001);
Pipe newpipe = Pipe.Create(this.Document, _pipeMEP, _pipeType, _pipeLvl, ptStart, midPoint);
Pipe newpipe2 = Pipe.Create(this.Document, _pipeMEP, _pipeType, _pipeLvl, midPoint2, ptEnd);
Connector connector2 = null;
Connector connector3 = null;
foreach (Connector connectduct1 in newpipe.ConnectorManager.Connectors)
{
if (connectduct1.Origin.IsAlmostEqualTo(midPoint))
{
connector2 = connectduct1;
break;
}
}
foreach (Connector connectduct2 in newpipe2.ConnectorManager.Connectors)
{
if (connectduct2.Origin.IsAlmostEqualTo(midPoint2))
{
connector3 = connectduct2;
break;
}
}
FamilyInstance Union = this.Document.Create.NewUnionFitting(connector2, connector3);
this.Document.Delete(pipe.Id);
t.Commit();
}
}
}
}