弯头相关信息的取得,及设置
//待设置的类型
FamilySymbol selFamilySymbol = doc.GetElement(new ElementId(536208)) as FamilySymbol;
Reference selRef = uiDoc.Selection.PickObject(ObjectType.Element, new CurveFilter(), "select Pipe | Duct");
Element selElem = doc.GetElement(selRef);
Pipe selPipe = selElem as Pipe;
if (selPipe == null)
{
MessageBox.Show("Not Pipe !!");
return Result.Failed;
}
RoutingPreferenceManager routing = selPipe.PipeType.RoutingPreferenceManager;
//获取弯头设置
RoutingPreferenceRule routingRule = routing.GetRule(RoutingPreferenceRuleGroupType.Elbows, 0);
FamilySymbol elbowFamilySymbol = doc.GetElement(routingRule.MEPPartId) as FamilySymbol;
if(elbowFamilySymbol != null)
{
PrimarySizeCriterion psc = routingRule.GetCriterion(0) as PrimarySizeCriterion;
MessageBox.Show("minSize: " + psc.MinimumSize + Environment.NewLine + "maxSize:" + psc.MaximumSize);
}
else //设置 弯头类型:
{
using (Transaction trans = new Transaction(doc))
{
trans.Start("Set Symbol");
PrimarySizeCriterion sizeCriterion = new PrimarySizeCriterion(80 / 304.8, 1200 / 304.8);
RoutingPreferenceRule rpr = new RoutingPreferenceRule(selFamilySymbol.Id, "newSymbol");
rpr.AddCriterion(sizeCriterion);
routing.AddRule(RoutingPreferenceRuleGroupType.Elbows, rpr, 0);
trans.Commit();
}
}