What's the API to connect a Pressure Pipe to a Pressure Fitting?

What's the API to connect a Pressure Pipe to a Pressure Fitting?

soonhui
Advisor Advisor
931 Views
7 Replies
Message 1 of 8

What's the API to connect a Pressure Pipe to a Pressure Fitting?

soonhui
Advisor
Advisor

In normal Pipe I can connect to a structure at end points via the API:

 

   var fromId = ACADDatabase.GetObjectId(false, handle, 0);
   Pipe.ConnectToStructure(ConnectorPositionType.Start, fromId, true);

 

 

But is there an equivalent API for Pressure Pipe ? Civil3D 2021 has come some ways to bridge the gaps in API, but what about this one? My own search doesn't turn up anything ( only an old link that discusses the same issue, with NO RESOLUTION, of course). Is there anything that I miss?

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
932 Views
7 Replies
Replies (7)
Message 2 of 8

soonhui
Advisor
Advisor

@Tristone , any idea on this?

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 3 of 8

Jeff_M
Consultant
Consultant

Not in the API at this time.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 4 of 8

Tristone
Autodesk
Autodesk

Pipe/Fitting/Appurtenance all support ConnectToPipe() method since C3D 2022.1.
Please check

 

PressureFitting.ConnectToPipe(int portIndex, ObjectId pipeId, int pipePortIndex);

 


PressureFitting can be created through

 

PressureNetwork.AddFitting(Point3d location, PressurePartSize partSize);

 

Feel free to let me know if any other questions or problems you found.  



Tristone Hua
Software Development Manager
AEC-BID-Infrastructure
Autodesk, Inc.

Message 5 of 8

soonhui
Advisor
Advisor

For

 

 

PressureFitting.ConnectToPipe(int portIndex, ObjectId pipeId, int pipePortIndex);

 

 

What is portIndex, and what is pipePortIndex?

 

If I have a new PressurePipe created via the PressurePipeNetwork.AddlinePipe, and I want to create two new PressureFittings, and connect them to the start and the end of the pipe, how can I do it via API?

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 6 of 8

Tristone
Autodesk
Autodesk

The port index matches the index in Part.GetConnectionAt() which identify the start/end of pipie or a port of fitting/Appurtenance. 

Tristone_0-1645769673970.png

 


 
Please referred to the below documentation(also shown in online API reference). 

 

 

 

    /// <summary>
    /// Gets the number of connections for this part.
    /// Returns 2 for a pipe.
    /// Returns n for an appurtenance or a fitting, depending on the part's number of ports.
    /// </summary>
    int PressurePart.ConnectionCount


    /// <summary>
    /// Gets the connection info at the port index.
    /// For a pipe, 0 is the start, 1 is the end (also see Pipe.StartConnection, and pipe.EndConnection)
    /// For an appurtenance or a fitting, the index is the part's port.
    /// </summary>
    PressurePartConnection PressurePart.GetConnectionAt(int index);

 

In some cases, you may need to use information(location, port direction)of PressurePartConnection object to identify a port to operate.  



Tristone Hua
Software Development Manager
AEC-BID-Infrastructure
Autodesk, Inc.

Message 7 of 8

soonhui
Advisor
Advisor

@Tristone ,

 

Does it matter whether we have to connect the Pipe End to the correct port index? The order of connection might look simple from visual point of view, but it can be quite hard to tell from code; one needs to get the angles of the pipes pertaining to a pressure fitting, and you have to get a clockwise or anticlock wise order?

 

Why can't Civil3D make the Pressure Fitting connection just like Structure, whereby the orders are determined internally?

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 8 of 8

soonhui
Advisor
Advisor

@Tristone ,

 

Also, I explore the API and find it quite hard to use. 

 

  • For PressureFitting, if I want to ConnectToPipe, what parameter should I specify for PortIndex? Does that mean that I have to keep track of how many pipes are connected to the PressureFitting, and then +1?
  • What if I specify a PortIndex that is way more than current ConnectionCount?
  • If there are 2 ports in a pressure fitting, what if I confuse the order ( ie: I specify 0 in place of 1, and vice versa)? Will that be an exception?
  • There is a PressureFitting.DisconnectAt() API, what happens after I call it ( ie: disconnect a part)? If I want to Disconnect at Index 1, will that reduce the ConnectionCount by 1? And if I want to add the same Part back, do I have to remember the previous Index and ensure taht it agrees with the current Index?

I would appreciate if you can show us a sample on how to use all these APIs. For me they look quite blackbox and unintuitive, so very unlike the equivalence in Pipe Network ( structure and Pipes). 

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes