增加保温层和整理管线的功能,修复自动保存功能等修复多个bug

This commit is contained in:
GG Z
2024-10-27 00:19:48 +08:00
parent b6647218be
commit 77655c9ef5
67 changed files with 3159 additions and 731 deletions

View File

@@ -24,7 +24,7 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
var elemIds = UiDocument.Selection.GetElementIds();
if (elemIds.Count == 0)
{
var reference = UiDocument.Selection.PickObject(ObjectType.Element, new GenericFilter<FamilyInstance>(), "请选择族实例");
var reference = UiDocument.Selection.PickObject(ObjectType.Element, new FuncFilter(e => e is FamilyInstance ins && ins.MEPModel.ConnectorManager != null), "请选择族实例");
elemIds.Add(Document.GetElement(reference).Id);
}
@@ -35,9 +35,9 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
var conduitTypeId = Document.OfClass<ConduitType>().FirstElementId();
var filteredElementCollector = Document.OfClass<DuctType>();
var roundTypeId = ElementId.InvalidElementId;
var rectangleTypeId = ElementId.InvalidElementId;
var ovalTypeId = ElementId.InvalidElementId;
var roundDuctTypeId = ElementId.InvalidElementId;
var rectangleDuctTypeId = ElementId.InvalidElementId;
var ovalDuctTypeId = ElementId.InvalidElementId;
foreach (var element2 in filteredElementCollector)
{
@@ -45,15 +45,15 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
if (ductType.FamilyName == "圆形风管" || ductType.FamilyName.Contains("Round Duct"))
{
roundTypeId = ductType.Id;
roundDuctTypeId = ductType.Id;
}
else if (ductType.FamilyName == "矩形风管" || ductType.FamilyName.Contains("Rectangular Duct"))
{
rectangleTypeId = ductType.Id;
rectangleDuctTypeId = ductType.Id;
}
else if (ductType.FamilyName == "椭圆形风管" || ductType.FamilyName.Contains("Oval Duct"))
{
ovalTypeId = ductType.Id;
ovalDuctTypeId = ductType.Id;
}
}
var fabricationConfiguration = FabricationConfiguration.GetFabricationConfiguration(Document);
@@ -63,6 +63,8 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
{
continue;
}
CableTray referCabTray = null;
Conduit referConduit = null;
//拿到连接的管线的类型
foreach (Connector conn in elem.GetConnectors())
{
@@ -84,13 +86,13 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
case ConnectorProfileType.Invalid:
break;
case ConnectorProfileType.Round:
roundTypeId = connector.Owner.GetTypeId();
roundDuctTypeId = connector.Owner.GetTypeId();
break;
case ConnectorProfileType.Rectangular:
rectangleTypeId = connector.Owner.GetTypeId();
rectangleDuctTypeId = connector.Owner.GetTypeId();
break;
case ConnectorProfileType.Oval:
ovalTypeId = connector.Owner.GetTypeId();
ovalDuctTypeId = connector.Owner.GetTypeId();
break;
default:
break;
@@ -100,10 +102,12 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
{
if (connector.Owner is CableTray cableTray)
{
referCabTray = cableTray;
cableTrayTypeId = cableTray.GetTypeId();
}
else if (connector.Owner is Conduit conduit)
{
referConduit = conduit;
conduitTypeId = conduit.GetTypeId();
}
}
@@ -239,7 +243,7 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
element = Duct.Create(
Document,
mechanicalSystem.Id,
roundTypeId,
roundDuctTypeId,
levelId,
origin,
xyz2
@@ -253,7 +257,7 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
element = Duct.Create(
Document,
mechanicalSystem.Id,
rectangleTypeId,
rectangleDuctTypeId,
levelId,
origin,
xyz2
@@ -264,7 +268,7 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
break;
case ConnectorProfileType.Oval:
element = Duct.Create(Document, mechanicalSystem.Id, ovalTypeId, levelId, origin, xyz2);
element = Duct.Create(Document, mechanicalSystem.Id, ovalDuctTypeId, levelId, origin, xyz2);
Document.Regenerate();
element.get_Parameter(BuiltInParameter.RBS_CURVE_WIDTH_PARAM).Set(connector.Width);
element.get_Parameter(BuiltInParameter.RBS_CURVE_HEIGHT_PARAM).Set(connector.Height);
@@ -274,7 +278,7 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
element = Duct.Create(
Document,
mechanicalSystem.Id,
roundTypeId,
roundDuctTypeId,
levelId,
origin,
xyz2
@@ -391,18 +395,18 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
break;
//电力
case Domain.DomainCableTrayConduit:
if (cableTrayTypeId == ElementId.InvalidElementId)
{
cableTrayTypeId = new FilteredElementCollector(Document)
.OfClass(typeof(CableTrayType))
.FirstElementId();
}
if (conduitTypeId == ElementId.InvalidElementId)
{
conduitTypeId = new FilteredElementCollector(Document)
.OfClass(typeof(ConduitType))
.FirstElementId();
}
//if (cableTrayTypeId == ElementId.InvalidElementId)
//{
// cableTrayTypeId = new FilteredElementCollector(Document)
// .OfClass(typeof(CableTrayType))
// .FirstElementId();
//}
//if (conduitTypeId == ElementId.InvalidElementId)
//{
// conduitTypeId = new FilteredElementCollector(Document)
// .OfClass(typeof(ConduitType))
// .FirstElementId();
//}
//switch (connector.ElectricalSystemType)
@@ -420,11 +424,27 @@ internal class BloomConnectorCmd : ExternalCommand //根据连接件创建一根
case ConnectorProfileType.Round:
element = Conduit.Create(Document, conduitTypeId, origin, xyz2, levelId);
element.get_Parameter(BuiltInParameter.RBS_CONDUIT_DIAMETER_PARAM).Set(connector.Radius * 2);
if (referConduit != null)
{
var value = referConduit.get_Parameter(
BuiltInParameter.RBS_CTC_SERVICE_TYPE)
.AsString();
element.get_Parameter(BuiltInParameter.RBS_CTC_SERVICE_TYPE).Set(value);
}
break;
case ConnectorProfileType.Rectangular:
element = CableTray.Create(Document, cableTrayTypeId, origin, xyz2, levelId);
element.get_Parameter(BuiltInParameter.RBS_CABLETRAY_WIDTH_PARAM).Set(connector.Width);
element.get_Parameter(BuiltInParameter.RBS_CABLETRAY_HEIGHT_PARAM).Set(connector.Height);
if (referCabTray != null)
{
var value = referCabTray.get_Parameter(
BuiltInParameter.RBS_CTC_SERVICE_TYPE)
.AsString();
element.get_Parameter(BuiltInParameter.RBS_CTC_SERVICE_TYPE).Set(value);
}
break;
case ConnectorProfileType.Oval: