By Aaron Lu
I’ve gotten a strange problem for Revit 2015, in the project file created from a rte file sent from a customer, there is no PipeScheduleType at all,
which means all PipeType.Class is null, even if there are a lot of pipe segments in the document.
After communicating with developer, we confirmed it is a defect caused by file upgrading.
The only solution now is to create a pipe segment by manual, which is not accessible via API because PipeSegment.Create method requires a PipeScheduleId. After the pipe segment is created, a pipe schedule type will be created automatically. To make it work, we should then change pipe segment of pipe type to the new one. Like this:
However, after doing that, PipeType.Class is still null! What’s going on?
Again, developer helped us: PipeType.Class property will be moved to Pipe, so we can use Pipe’s Parameter to get the schedule type, below is how:
Autodesk.Revit.DB.Plumbing.Pipe pipe = null;
var pipeClass = pipe.get_Parameter(BuiltInParameter.RBS_PIPE_CLASS_PARAM);
var pipeScheduleTypeId = pipeClass.AsElementId();
But how to change PipeSegment of PipeType via API? Here it is:
ElementId theSegmentId = new ElementId(1803995);
PipeType pipeType = doc.GetElement(new ElementId(1660690)) as PipeType;
var rpm = pipeType.RoutingPreferenceManager;
var groupType = RoutingPreferenceRuleGroupType.Segments;
RoutingPreferenceRule rule = new RoutingPreferenceRule(theSegmentId, "description");
using (Transaction transaction = new Transaction(RevitDoc))
{
transaction.Start("Change pipe segment");
rpm.AddRule(groupType, rule);
transaction.Commit();
}
- First, get RoutingPreferenceManager from PipeType.RoutingPreferenceManager
- Then create a new RoutingPreferenceRule
- Last, Add the rule using AddRule method



Leave a Reply