如图所示,1是OPM CE up7自带的HVAC Round Damper,放置在Round Duct上可以自动打断,2是我自己模仿1写的,但是无法自动打断,下面是C#脚本代码
public override void Setup() { if (!this._initialized) { this._initialized = true; } base.Setup(); this.mainPort = (this._ports[0] as RoundGasPort); if (this._ports.Count > 1) { this.runPort = (this._ports[1] as RoundGasPort); } this.maindiameter = this._bmECObject.Instance["MAIN_DIAMETER"].DoubleValue; // DN this.length = this._bmECObject.Instance["LENGTH"].DoubleValue; // 长度 this.runDiameter = this.maindiameter; this.damperdiameter = this._bmECObject.Instance["DIAMETER1"].DoubleValue; // 大于DN,用于计算厚度 this.bladeDiameter = this._bmECObject.Instance["BLADE_DIAMETER"].DoubleValue; // 大于DIAMETER1,用于计算两边片的厚度 this.height = this._bmECObject.Instance["HEIGHT"].DoubleValue; this.bladeLength = this._bmECObject.Instance["BLADE_LENGTH"].DoubleValue; this.L1 = this._bmECObject.Instance["L1"].DoubleValue; this.L2 = this._bmECObject.Instance["L2"].DoubleValue; this.L3 = this._bmECObject.Instance["L3"].DoubleValue; this.L4 = this._bmECObject.Instance["L4"].DoubleValue; if (this.maindiameter > this.damperdiameter) { this._bmECObject.Instance["MAIN_DIAMETER"].DoubleValue = this.damperdiameter; this.maindiameter = this.damperdiameter; } if (this.damperdiameter > this.bladeDiameter) { this._bmECObject.Instance["BLADE_DIAMETER"].DoubleValue = this.damperdiameter; this.bladeDiameter = this.damperdiameter; } DVector3d orientation = DVector3d.FromXYZ(0.0, 0.0, 1.0); if (this.mainPort != null) { this.mainPort.LocationInMM = DPoint3d.FromXYZ(this.bladeLength, 0.0, 0.0); this.mainPort.Orientation = orientation; this.mainPort.Direction = DVector3d.FromXYZ(-1.0, 0.0, 0.0); this.mainPort.DiameterInMM = this.maindiameter; PlacementPoint placementPoint = new PlacementPoint(this.mainPort); placementPoint.IsPort = true; this._placementPoints.Add(placementPoint); } if (this.runPort != null) { this.runPort.LocationInMM = DPoint3d.FromXYZ(this.length + bladeLength, 0.0, 0.0); this.runPort.Orientation = orientation; this.runPort.Direction = DVector3d.FromXYZ(1.0, 0.0, 0.0); this.runPort.DiameterInMM = this.runDiameter; PlacementPoint placementPoint = new PlacementPoint(this.runPort); placementPoint.IsPort = true; this._placementPoints.Add(placementPoint); } } public List<ElementHolder> CreateCenterLine() { List<ElementHolder> list = new List<ElementHolder>(); list.Add(this._app.CreateLineElement(this._ports[0].LocationInMM, this._ports[1].LocationInMM)); if (list != null) { base.SetTypeAndSymbology(ref list, BMdGraphicsType.bmdGraphicsTypeCenterline); } return list; } public BMGatheredElement CreateDamperBody( double bodydiameter, double length ) { BMGatheredElement bMGatheredElement = this._app.CreateGatheredElement(); BMechEndData bMechEndData = new BMechEndData(); bMechEndData.WidthInMM = bodydiameter; bMechEndData.DepthInMM = bodydiameter; bMechEndData.Shape = BMdEndShape.bmdRound; BMechEndData bMechEndData2 = new BMechEndData(); bMechEndData2.WidthInMM = this.maindiameter; bMechEndData2.DepthInMM = this.maindiameter; bMechEndData2.Shape = BMdEndShape.bmdRound; bMGatheredElement.Cursor.Initialize(); if (bodydiameter != this.maindiameter) { bMGatheredElement.AddDifference(bMechEndData, bMechEndData2, DPoint3d.Zero, BMdComponentType.bmdComponentTypeBody, BMdGraphicsType.bmdGraphicsTypeEdge); } bMGatheredElement.AddSurface(bMechEndData2, bMechEndData2, DPoint3d.Zero, BMdGraphicsType.bmdGraphicsTypeEdge, BMdComponentType.bmdComponentTypeBody, length, (bodydiameter - this.maindiameter) / 2); return bMGatheredElement; } public override List<ElementHolder> Create3DElements() { List<ElementHolder> list = new List<ElementHolder>(); try { this.Setup(); BMGatheredElement bMGatheredElement = this.CreateDamperBody(this.bladeDiameter, this.bladeLength); list.Add(bMGatheredElement.Create()); BMGatheredElement bMGatheredElement2 = this.CreateDamperBody(this.damperdiameter, this.length + this.bladeLength); list.Add(bMGatheredElement2.Create()); BMGatheredElement bMGatheredElement3 = this.CreateDamperBody(this.bladeDiameter, this.bladeLength); ElementHolder elementHolder = bMGatheredElement3.Create(); DTransform3d transform = DTransform3d.Identity; EulerAngles euler = EulerAngles.FromDegrees(0, 0, 0); transform.Matrix = DMatrix3d.FromEulerAngles(euler); transform.Translation = new DVector3d(this.length + this.bladeLength, 0, 0); elementHolder.Transform(transform, false); list.Add(elementHolder); base.SetTypeAndSymbology(ref list, BMdGraphicsType.bmdGraphicsTypeEdge); list.AddRange(base.CreateHvacEndPreps()); list.AddRange(this.CreateCenterLine()); } catch (Exception) { } return list; }
ecclass配置
补充:放置命令使用的是mechaddin place MYROUNDDAMPER DSC=HVAC
试试这个PlacementTool
您好,Invalid Element Identified: HVAC_ROUND_DUCT
抱歉,截错图了,应该是还用原来那个PlacementTool
建议您直接修改Hvac Round Damper调用您的脚本:
如果行为一致的话,说明是您的Schema设置有问题,检查Schema
如果行为不一致的话,说明是您的脚本有问题,再检查脚本
Answer Verified By: Liaoyuan Zhang
已解决