Pipe Fitting Rotation Around Pipe

You could try replacing the value for inc (which is 304.8) by 1. That way it will use imperial units.

So line 31 of the python script will look like this:

Kulkul’s code made me a little curious so I snooped around in the SDK a bit and came up with an alternative that will rotate the fititng around its primary connector. Here’s the code:

import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit

clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import *
import math

doc = DocumentManager.Instance.CurrentDBDocument

clr.ImportExtensions(Revit.GeometryConversion)

inn = UnwrapElement(IN[0])
if not isinstance(inn, list): 
	 inn = [inn]

angle = (IN[1]*math.pi)/180
TransactionManager.Instance.EnsureInTransaction(doc)

for i in inn:
	connectors = i.MEPModel.ConnectorManager.Connectors
	for x in connectors:
		if x.GetMEPConnectorInfo().IsPrimary:
			primary = x
			break
		primary = x
	loc = i.Location
	trans = primary.CoordinateSystem
	line = Autodesk.Revit.DB.Line.CreateUnbound(primary.Origin,trans.BasisZ)
	loc.Rotate(line,angle)

TransactionManager.Instance.TransactionTaskDone()

OUT =  IN[0]
2 Likes

Thanks for the help T_Pover. Initial testing seems to work just fine. Now if I can just figure out how to rotate the branch with the fitting.

Couldn’t help myself :slight_smile: but I don’t know if it’s of any use to you, guess it depends on the rest of your script.

Rotate PipeFitting and pipe.dyn (4.6 KB)

4 Likes

@T_Pover - This is exactly what I was hoping to achieve. It seems to work well. Thank you for helping.

@Kulkul - I wanted to give you one final shoot out and thank you for your efforts on working toward a solution.

Attached is more or less the final graph I was trying to work toward. It use some nodes from Rhythm Package in conjunction with the Python Script provided by T_Pover . The graph allows for the use of Dynamo Player. The user will be prompted to first enter a rotation angle, then the first element pick will be the pipe followed by a second element pick of the fitting. Thank you everyone for your help. I feel this was an effective collaboration that produced as simple yet effective tool. RotateFitting&Branch_Custom Angle.dyn (6.0 KB)

2 Likes

Love it! You guys are MEP life savers! I showed this to a couple of fellow BIM Managers and they’re drooling to this kind of “simple yet effective tool”!

3 Likes

Sorry I am very new to this.
My question is why I am not getting a prompt from Revit 2018 /Dynamo on the angle to rotate…

OKAY SO I got this working now, I am using the Revit player and a a slider which allows for input through the player itself .

This version is working for me using Revit 2018 on Dynamo 1.3.1

Rotate PipeFitting - RVT2018 - WORKING.dyn (4.8 KB)

2 Likes