Tap Disconnecting when splitting pipe

Tap Disconnecting when splitting pipe

shibuchellappan
Participant Participant
1,152 Views
4 Replies
Message 1 of 5

Tap Disconnecting when splitting pipe

shibuchellappan
Participant
Participant

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 / 2false);
                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();
            }
    }
}
    }

0 Likes
1,153 Views
4 Replies
Replies (4)
Message 2 of 5

ollikat
Collaborator
Collaborator

In order to have generic approach which will work in all scenarios, quite significant amount of functionality is required. We have done working implementation but unfortunately I cannot provide too much code here, because it includes so much proprietary code i.e. none Revi API specific code so that it wouldn't help you so much. But if I give some specific keywords/tips here so that you can proceed.

So I think the following is what you need to do...pretty much in that order also:

  • Loop trough all the curve connectors of the target pipe (See the Connector.ConnectorType Property) and for each...
    • Find out the neighboring pipe connector of the corresponding tap element.
    • Store this connector as a pair with the FamilySymbol of the corresponding tap element. You can use System.Tuple<Connector, FamilySymbol> for this purpose
    • Disconnect tap
    • Delete tap element
  • Replace the target pipe with the two pipes according to split position
  • It's time to reconnect the disconnected pipes
    • Loop trough a list of connector - FamilySymbol pairs stored earlier and for each...
      • Check which pipe to connect. Projection point should be found inside the corresponding pipe
      • In order to reconnect with correct tap, you must set the FamiySymbol as the active fitting type for the disconnected pipe's junction type. In Revit API this is a concept called "Routing Preferences"
      • Connect using NewTakeoffFitting

Hope this helps

0 Likes
Message 3 of 5

shibuchellappan
Participant
Participant

Thank you very much ollikat, 

it works perfect if the tap is connected to a pipe. but if we have back to back fittings connected directly in a tap like, a coupling and elbows. or if the tap is directly connected to a valve. it fails to get a pipe connector. in that case there is only fittings connected to the tap. Please see the sample2 png. So is there any option without deleting the tap and reconnect it back. Thanks a lot for your kind approach. really appreciable.

Shibu C

0 Likes
Message 4 of 5

ollikat
Collaborator
Collaborator

Hi

Sorry for late respond due to my vacation period.

To me it simply seems like an issue where additional logic is required. So, if there's possibility that the neighbor element is not a pipe, then you need to accept connectors from those also.

I must say that I'm not aware of a way to do all this without removing the taps. This is because in ANY CASE, you need to disconnect the taps. Which of course mean you need to reconnect after the operation. But I'm not aware of any reliable way of connecting existing taps to pipe with curve connectors. That's why we have ended up totally removing the taps, and reconnecting with NewTakeoffFitting(). That being said, I also don't know for sure, whether that one works with i.e. valve elements you mentioned (the given connector host element would be a valve, rather than a pipe).

So there's still something you to research but I have a feeling that it is doable what you are trying to achieve.

0 Likes
Message 5 of 5

shibuchellappan
Participant
Participant

Thanks for your Reply Mr. ollikat.

I reported this issue to ADN and they given me a reply. I will paste below. I need to disconnect the tap. because I am splitting the pipe, when it's splitting  the tap was deleting. so I disconnect the tap and store the information and trying to re insert the tap. the issue is when I try to insert tap using a connector from elbow, coupling, or valve it's not accepting. thanks for your support.

 

Dear Shibu Chellappan,

 

Please accept our sincere apologies for the delay. After checking our engineering team, I got the confirmation that Newtakeofffittings supports connectors of pipe(flex pipe) or duct only since currently, connections to taps will only be maintained for pipes. 



Therefore, I submitted a wishlist item REVIT-165310 [Add API support for connecting the fitting (e.g., valve, coupling, or elbow) to pipe with a tap as Dcoument#NewTakeoffFittings does] on your behalf for the API you request, as this wishlist item requires exploration and possibly a modification to our software. Please make a note of this number for future reference.