Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing pipe direction

3 REPLIES 3
Reply
Message 1 of 4
neerav.mehta
1747 Views, 3 Replies

Changing pipe direction

I am trying to place a pipe precisely between two points: intersectionPoint and intersectionPoint + perpendicularDirection. I am using the following statement to move the pipe:

 

Pipe dummyPipe = doc.GetElement(ElementTransformUtils.CopyElement(doc, branchPipe.Id, XYZ.Zero).First()) as Pipe;
(dummyPipe.Location as LocationCurve).Curve = Line.CreateBound(intersectionPoint, intersectionPoint + 1.0 * perpendicularDirection);

With the above placement, I would expect the pipe's curve's direction to be exactly equal to perpendicularDirection. But that's not the case. As an example, if perpendicularDirection is set to {(-0.016831296, 0.968685013, -0.052781984)}, the direction of the pipe comes out to be {(-0.017347059, 0.998368562, -0.054399389)}. Note that there is a slight difference in the direction and as a result, I am not able to connect this pipe to a Tee fitting as per Insert T-connection.

 

BTW the same issue happens even if I create a new pipe between two points.

 

Any idea how to fix this issue?

3 REPLIES 3
Message 2 of 4
jeremytammik
in reply to: neerav.mehta

In most cases, you do not need to specify an exact pipe direction to create a pipe between fittings, not an exact fitting location to insert a fitting between existing pipes.

 

Revit will automatically adjust the newly created element appropriately to connect with the existing elements.

 

I discovered this and explored it in some detail in my research series on creating a rolling offset:

 

http://thebuildingcoder.typepad.com/blog/2014/01/final-rolling-offset-using-pipecreate.html

 

Please study the different approaches presented in that research series.

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4
neerav.mehta
in reply to: jeremytammik

@jeremytammik The problem was because of inaccuracy in the cross product. I was deriving the pipe direction by doing two cross-products of unit-norm vectors. In other words, pipeDirection = X.CrossProduct(Y).CrossProduct(X). If X and Y are of unit-norm, I would expect pipeDirection to be unit-norm, but that wasn't the case. I was getting about 0.971 instead of 1.000. I thought that Revit uses doubles and not floats, but may be that's not the case. Once I normalize pipeDirection, it worked fine.

 

BTW Your rolling offset post only deals with inserting elbows, which works pretty well. In my case, I am inserting T connection and that API is a horrible mess. Here are the issues:

 

  1. CreateTeeFitting() works only when the connection is 90 degrees so you have to use the workaround mentioned in Tee Fitting with no right-angle.
  2. The above workaround works only when the base pipe is placed in a way that's acceptable to Revit. As an example, adding a Tee connection works if the two pipes are placed along X axis and the branch pipe is along the Y-axis. But if I rotate the three pipes slightly, for e.g. by 0.1 degrees, the CreateTeeFitting() function fails.
  3. So now I have to do another workaround, i.e. create dummy pipes in a position that the Revit likes and create a 90 degree T connection. Then delete all the dummy pipes and the fittings that were automatically created except the T connection. Now rotate the T fitting to what I want, for e.g. by 0.1 degrees. Then change the angle of the branch connector to something other than 90 degrees.

 

This issue along with Line based family location don't update Origin after change has taken me about a week to create a T connection at the right place and orientation instead of probably an hour if the API had worked in the first place.

Message 4 of 4
jeremytammik
in reply to: neerav.mehta

Thank you very much for your research, solution, and pointers to the other issues.

 

Sorry to hear that it cost you so much time to resolve these issues.

 

I am glad to hear that you succeeded in the end. Congratulations!

 

This all seems very useful to me, so I'll summarise it on The Building Coder for future reference.

 

One little clarification:

 

If X and Y are both unit length, their cross product will still NOT be unit length unless they are exactly perpendicular.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community