How to find plane on pipe center line?

How to find plane on pipe center line?

pochao
Contributor Contributor
1,658 Views
10 Replies
Message 1 of 11

How to find plane on pipe center line?

pochao
Contributor
Contributor

How to find plane on pipe center line?

未命名.png

0 Likes
Accepted solutions (2)
1,659 Views
10 Replies
Replies (10)
Message 2 of 11

Kevin.Lawson.PE
Advocate
Advocate

 

Autodesk.Revit.DB.Plumbing.Pipe pipe = Autodesk.Revit.DB.Plumbing.Pipe.Create(doc, pipeTypeId, levelId, startConnector, downstreamConnector);//whatever pipe you want the plane on 
ConnectorSet pipeConnectorSet = pipe.MEPSystem.ConnectorManager.Connectors;
List<Connector> pipeConnectorList = new List<Connector>();

foreach(Connector connector in pipeConnectorSet)
{
  pipeConnectorList.Add(connector);
}

Plane plane = Plane.CreateByThreePoints(pipeConnectorList[0].Origin, pipeConnectorList[1].Origin, new XYZ(pipeConnectorList[0].Origin.X, pipeConnectorList[0].Origin.Y + 10, pipeConnectorList[0].Origin.Z));

 

-Kevin Lawson, PE
www.rippleengineeringsoftware.com
Revit heating and cooling load calculations in one click!
0 Likes
Message 3 of 11

pochao
Contributor
Contributor

Thanks for your response

 

Does this case apply? ( Sloped, none vertical, none horizontal)

 

 

Snipaste_2020-08-12_08-45-16.png

0 Likes
Message 4 of 11

Kevin.Lawson.PE
Advocate
Advocate

Maybe, I'm not sure what your exact requirements are.  I was just giving you something to get started working the problem yourself. 

-Kevin Lawson, PE
www.rippleengineeringsoftware.com
Revit heating and cooling load calculations in one click!
0 Likes
Message 5 of 11

pochao
Contributor
Contributor

horizontal pipe:

connector.Origin.Y + 10

 

vertical pipe:

connector.Origin.X + 10

 

Others:

I can't find the third point

0 Likes
Message 6 of 11

Kevin.Lawson.PE
Advocate
Advocate

The pipe has two connectors, one at each end, which I'm accessing with 

pipeConnectorList[0].Origin, pipeConnectorList[1].Origin,

The third point can be something off of that, as you said in the x, y, or z direction.  

-Kevin Lawson, PE
www.rippleengineeringsoftware.com
Revit heating and cooling load calculations in one click!
0 Likes
Message 7 of 11

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

why not

 

Plane plane = Plane.CreateByNormalAndOrigin(pipeConnectorList[0].CoordinateSystem.BasisY, pipeConnectorList[0].CoordinateSystem.Origin);

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 8 of 11

pochao
Contributor
Contributor
Accepted solution

Finally, I find this solution.

 

Dim pipeDirection As XYZ = conn0.Origin - conn1.Origin
Dim normal As XYZ = XYZ.BasisZ.CrossProduct(pipeDirection).Normalize
Dim translation As XYZ = normal.Multiply(10)
Dim thirdPoint As XYZ = conn1.Origin.Add(translation)

0 Likes
Message 9 of 11

Revitalizer
Advisor
Advisor

Hi,

 

if the Pipe is vertical and pipeDirection equals XYZ.BasisZ (or minus XYZ.BasisZ), the cross product doesn't make sense.

 

You solution doesn't cover all possible cases.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 10 of 11

pochao
Contributor
Contributor

Sorry, only in xy plane.

 

Snipaste_2020-08-12_15-16-20.png

0 Likes
Message 11 of 11

Revitalizer
Advisor
Advisor

Hi,

 

no need to implement different case scenarios.

 

All vectors you need are already present in the connector's CoordinateSystem property:

 

https://thebuildingcoder.typepad.com/blog/2012/05/connector-orientation.html

 

So, the Pipe's orientation doesn't matter at all.

 

Just see my previous answer.

 

 

Revitalizer

 

 




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes