多项功能优化
This commit is contained in:
@@ -21,7 +21,7 @@ public static class ConnectorAssist
|
||||
return null;
|
||||
}
|
||||
var document = first.Owner.Document;
|
||||
var isUnion = false; //活接头
|
||||
var isSameSize = false; //相同规格、尺寸
|
||||
if (first.Domain != second.Domain)
|
||||
{
|
||||
throw new ArgumentException("无法连接不同类型的管线");
|
||||
@@ -35,14 +35,14 @@ public static class ConnectorAssist
|
||||
{
|
||||
var shape = first.Shape;
|
||||
//判断管径是否一致
|
||||
isUnion = shape is ConnectorProfileType.Oval or ConnectorProfileType.Rectangular
|
||||
isSameSize = shape is ConnectorProfileType.Oval or ConnectorProfileType.Rectangular
|
||||
? Math.Abs(first.Width - second.Width) < 0.0001 && Math.Abs(first.Height - second.Height) < 0.0001
|
||||
: Math.Abs(first.Radius - second.Radius) < 0.0001;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Domain.DomainPiping:
|
||||
isUnion = Math.Abs(first.Radius - second.Radius) < 0.0001;
|
||||
isSameSize = Math.Abs(first.Radius - second.Radius) < 0.0001;
|
||||
break;
|
||||
case Domain.DomainCableTrayConduit:
|
||||
{
|
||||
@@ -50,11 +50,11 @@ public static class ConnectorAssist
|
||||
{
|
||||
if (second.Owner is Conduit)
|
||||
{
|
||||
isUnion = Math.Abs(first.Radius - second.Radius) < 0.0001;
|
||||
isSameSize = Math.Abs(first.Radius - second.Radius) < 0.0001;
|
||||
}
|
||||
if (second.Owner is CableTray)
|
||||
{
|
||||
isUnion = Math.Abs(first.Width - second.Width) < 0.0001 && Math.Abs(first.Height - second.Height) < 0.0001;
|
||||
isSameSize = Math.Abs(first.Width - second.Width) < 0.0001 && Math.Abs(first.Height - second.Height) < 0.0001;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -62,11 +62,11 @@ public static class ConnectorAssist
|
||||
}
|
||||
try
|
||||
{
|
||||
//平行创建过渡件和活接头
|
||||
//平行时,创建过渡件和活接头
|
||||
if (first.CoordinateSystem.BasisZ.IsParallelTo(second.CoordinateSystem.BasisZ))
|
||||
{
|
||||
//活接头创建
|
||||
if (isUnion) //管径一致时
|
||||
//管径一致时,根据情况创建活接头
|
||||
if (isSameSize)
|
||||
{
|
||||
//有一个是族的时候,始终直接连接,不创建活接头
|
||||
if (first.Owner is MEPCurve ^ second.Owner is MEPCurve)
|
||||
@@ -75,29 +75,40 @@ public static class ConnectorAssist
|
||||
{
|
||||
first.ConnectTo(second);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (first.Owner is MEPCurve && second.Owner is MEPCurve) //都是管线
|
||||
//都是管线
|
||||
if (first.Owner is MEPCurve && second.Owner is MEPCurve)
|
||||
{
|
||||
return document.Create.NewUnionFitting(first, second);
|
||||
}
|
||||
|
||||
//都是族的连接件
|
||||
if (first.Owner is FamilyInstance && second.Owner is FamilyInstance)
|
||||
{
|
||||
first.ConnectTo(second);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//过渡件,管径不一致时
|
||||
if (first.Owner is MEPCurve)
|
||||
else
|
||||
{
|
||||
return document.Create.NewTransitionFitting(first, second);
|
||||
}
|
||||
if (second.Owner is MEPCurve)
|
||||
{
|
||||
return document.Create.NewTransitionFitting(second, first);
|
||||
//管径不一致时,创建过渡件
|
||||
if (first.Owner is MEPCurve)
|
||||
{
|
||||
return document.Create.NewTransitionFitting(first, second);
|
||||
}
|
||||
if (second.Owner is MEPCurve)
|
||||
{
|
||||
return document.Create.NewTransitionFitting(second, first);
|
||||
}
|
||||
//都是族的连接件
|
||||
if (first.Owner is FamilyInstance && second.Owner is FamilyInstance)
|
||||
{
|
||||
first.ConnectTo(second);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//不平行则创建弯头
|
||||
return document.Create.NewElbowFitting(first, second);
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -130,9 +141,9 @@ public static class ConnectorAssist
|
||||
//垂直主管的分支管,为了创建默认三通
|
||||
var verticalLine = Line.CreateBound(intersect, intersect + (3.0 * vertical));
|
||||
//延长管线到交点处
|
||||
branch.Owner.SetLocationCurve((branch.Owner.GetLocCurve() as Line).ExtendLine(intersect));
|
||||
connector.Owner.SetLocationCurve((connector.Owner.GetLocCurve() as Line).ExtendLine(intersect));
|
||||
connector1.Owner.SetLocationCurve((connector1.Owner.GetLocCurve() as Line).ExtendLine(intersect));
|
||||
branch.Owner.SetLocationCurve((branch.Owner.GetCurve() as Line).ExtendLine(intersect));
|
||||
connector.Owner.SetLocationCurve((connector.Owner.GetCurve() as Line).ExtendLine(intersect));
|
||||
connector1.Owner.SetLocationCurve((connector1.Owner.GetCurve() as Line).ExtendLine(intersect));
|
||||
//复制支管创建垂直主管的管线
|
||||
var verticalMEPCurveId = ElementTransformUtils.CopyElement(document, branch.Owner.Id, XYZ.Zero).FirstOrDefault();
|
||||
var verticalMEPCurve = document.GetElement(verticalMEPCurveId) as MEPCurve;
|
||||
@@ -160,10 +171,10 @@ public static class ConnectorAssist
|
||||
document.Regenerate();
|
||||
//Connector branchFarConn = branch.Owner.GetConnectors().GetFarthestConnector(intersect);
|
||||
//Line newBranch = Line.CreateBound(branchFarConn.Origin, teeBranchConn.Origin);
|
||||
var l = branch.Owner.GetLocCurve() as Line;
|
||||
var l = branch.Owner.GetCurve() as Line;
|
||||
var newBranchLine = l.ExtendLine(teeBranchConn!.Origin);
|
||||
branch.Owner.SetLocationCurve(newBranchLine);
|
||||
//Line line = branch.Owner.GetLocCurve() as Line;
|
||||
//Line line = branch.Owner.GetCurve() as Line;
|
||||
//if (newBranch.Direction.IsAlmostEqualTo(line.Direction))
|
||||
//{
|
||||
// (branch.Owner.Location as LocationCurve).Curve = newBranch;
|
||||
@@ -302,7 +313,7 @@ public static class ConnectorAssist
|
||||
Domain.DomainHvac when connector.Shape == ConnectorProfileType.Rectangular => (connector.Width * 0.2) + (connector.Height * 0.2),
|
||||
Domain.DomainHvac when connector.Shape == ConnectorProfileType.Oval => (connector.Width * 0.2) + (connector.Height * 0.2),
|
||||
Domain.DomainHvac when connector.Shape == ConnectorProfileType.Round => connector.Radius * 0.5,
|
||||
Domain.DomainPiping => connector.Radius * 0.5,
|
||||
Domain.DomainPiping => connector.Radius * 4,
|
||||
Domain.DomainCableTrayConduit => 1,
|
||||
_ => 0.5
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user