调整代码
This commit is contained in:
@@ -23,150 +23,8 @@ internal class ModifySystemTypeCmd : IExternalCommand
|
||||
//当前视图
|
||||
var view = doc.ActiveView;
|
||||
|
||||
//var views = doc.OfClass<View>().Cast<View>().Where(v => !v.IsTemplate);
|
||||
//foreach (var v in views)
|
||||
//{
|
||||
// if (v.GetParameter("子视图分类")?.AsString() == "01 平面")
|
||||
// {
|
||||
// MessageBox.Show(v.Id.ToString());
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
#region RegionName
|
||||
//var ins = doc.OfClass<FamilyInstance>().Cast<FamilyInstance>();
|
||||
//var pipes = doc.OfClass<Pipe>().Cast<Pipe>();
|
||||
|
||||
//using (var trans = new Transaction(doc, nameof(ModifySystemTypeCmd)))
|
||||
//{
|
||||
// trans.Start();
|
||||
// var level = doc.OfClass<Level>().Cast<Level>().FirstOrDefault(l => l.Name == "站厅层");
|
||||
// foreach (var pipe in pipes)
|
||||
// {
|
||||
// if (pipe.ReferenceLevel.Name == "站厅层.")
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// pipe.ReferenceLevel = doc.GetElement(level.Id) as Level;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// MessageBox.Show(pipe.Name);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// foreach (var instance in ins)
|
||||
// {
|
||||
|
||||
// var e = doc.GetElement(instance.LevelId);
|
||||
// if (e != null && e.Name == "站厅层.")
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// instance.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM)?.Set(level.Id);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// MessageBox.Show(e.Name);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// trans.Commit();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
//var templates = doc.OfClass<View>().Cast<View>().Where(v => v.IsTemplate);
|
||||
//foreach (var template in templates)
|
||||
//{
|
||||
// var filters = template.GetFilters();
|
||||
// foreach (var id in filters)
|
||||
// {
|
||||
// var filterElement = doc.GetElement(id);
|
||||
// if (filterElement is ParameterFilterElement filter)
|
||||
// {
|
||||
// if (filter.Name.Contains("生产生活给水系统"))
|
||||
// {
|
||||
// var ogs = new OverrideGraphicSettings();
|
||||
// ogs.SetProjectionLineColor(new Color(0, 255, 0));
|
||||
// ogs.SetProjectionLineColor(new Color(0, 255, 0));
|
||||
// ogs.SetProjectionLineColor(new Color(0, 255, 0));
|
||||
// ogs.SetProjectionLineColor(new Color(0, 255, 0));
|
||||
// template.SetFilterOverrides(id, ogs);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//var maps = doc.ParameterBindings;
|
||||
//var li = maps.ForwardIterator();
|
||||
//try
|
||||
//{
|
||||
// using (var trans = new Transaction(doc, "修改"))
|
||||
// {
|
||||
// trans.Start();
|
||||
// var pipeCate = Category.GetCategory(doc, BuiltInCategory.OST_PipeCurves);
|
||||
// var cabtrayCate = Category.GetCategory(doc, BuiltInCategory.OST_CableTray);
|
||||
// var conduitCate = Category.GetCategory(doc, BuiltInCategory.OST_Conduit);
|
||||
|
||||
// while (li.MoveNext())
|
||||
// {
|
||||
// var k = li.Key;
|
||||
// if (Regex.IsMatch(k.Name, @"^[A-Z][A-Z](-)\d(00-)"))
|
||||
// {
|
||||
// if (li.Current is InstanceBinding binding && binding.Categories.Contains(pipeCate))
|
||||
// {
|
||||
// //binding.Categories.Insert(cabtrayCate);
|
||||
// //binding.Categories.Insert(conduitCate);
|
||||
// //binding.Categories.Erase(pipeCate);
|
||||
// doc.ParameterBindings.ReInsert(k, binding, BuiltInParameterGroup.PG_ADSK_MODEL_PROPERTIES);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// trans.Commit();
|
||||
// }
|
||||
//}
|
||||
//catch (Exception)
|
||||
//{
|
||||
|
||||
// throw;
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
//var r = uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element);
|
||||
var ids = uidoc.Selection.GetElementIds();
|
||||
foreach (var id in ids)
|
||||
{
|
||||
var elem = doc.GetElement(id);
|
||||
if (elem is not Pipe)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var systemType = new FilteredElementCollector(doc).OfClass(typeof(PipingSystemType))
|
||||
.FirstOrDefault(p => p.Name == "气体灭火管网系统") as PipingSystemType;
|
||||
using (var trans = new Transaction(doc, nameof(ModifySystemTypeCmd)))
|
||||
{
|
||||
|
||||
trans.Start();
|
||||
elem.get_Parameter(BuiltInParameter.RBS_PIPING_SYSTEM_TYPE_PARAM).Set(systemType.Id);
|
||||
|
||||
//foreach (var id in uidoc.Selection.GetElementIds())
|
||||
//{
|
||||
// var elem = doc.GetElement(id);
|
||||
// elem.ChangeTypeId(systemType.Id);
|
||||
//}
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return Result.Succeeded;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user