/// <summary> /// Return the first rectangular connector of the given duct element. /// </summary> static bool GetFirstRectangularConnector( Duct duct, out Connector c1) { c1 = null; ConnectorSet connectors = duct.ConnectorManager.Connectors; if (0 < connectors.Size) { foreach (Connector c in connectors) { if (ConnectorProfileType.Rectangular == c.Shape) { c1 = c; break; } else { Trace.WriteLine("Connector shape: " + c.Shape); } } } return(null != c1); }
public static MaterialComposition MaterialComposition(this Duct duct) { if (duct == null) { BH.Engine.Reflection.Compute.RecordError("Cannot query the material composition of a null duct."); return(null); } if (duct.SectionProperty == null) { Engine.Reflection.Compute.RecordError("The Duct MaterialComposition could not be calculated as no SectionProperty has been assigned."); return(null); } List <Material> materials = null; List <double> ratios = null; materials = new List <Material>() { duct.SectionProperty.DuctMaterial, duct.SectionProperty.LiningMaterial, duct.SectionProperty.InsulationMaterial }; ratios = new List <double>() { duct.SectionProperty.ElementSolidArea, duct.SectionProperty.LiningSolidArea, duct.SectionProperty.InsulationSolidArea }; return(Matter.Create.MaterialComposition(materials, ratios)); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { //Fetch the Document UIDocument uiDoc = commandData.Application.ActiveUIDocument; Document doc = uiDoc.Document; //required arrays BuiltInCategory biDucts = BuiltInCategory.OST_DuctCurves; ElementId idDucts = doc.Settings.Categories.get_Item(biDucts).Id; ICollection <ElementId> selectedIds = uiDoc.Selection.GetElementIds(); List <Element> eles = new List <Element>(); List <Connector> cons = new List <Connector>(); //check for element number if (selectedIds.Count > 2) { TaskDialog.Show("Wrong input", "You selected more then 2 elements"); return(Result.Succeeded); } //chekc element Category and if its ok foreach (var eleId in selectedIds) { Element ele = doc.GetElement(eleId); if (ele.Category.Id.Equals(idDucts)) { eles.Add(ele); } else { TaskDialog.Show("Wrong input", "Wrong elements category"); return(Result.Succeeded); } } Duct du1 = eles[0] as Duct; Duct du2 = eles[1] as Duct; ConnectorSet cc1 = du1.ConnectorManager.UnusedConnectors; ConnectorSet cc2 = du2.ConnectorManager.UnusedConnectors; foreach (Connector c in cc1) { cons.Add(c); } foreach (Connector c in cc2) { cons.Add(c); } //transaction for creating the transition using (Transaction trans = new Transaction(doc, "Trans1")) { trans.Start(); doc.Create.NewTransitionFitting(cons[0], cons[1]); trans.Commit(); } return(Result.Succeeded); }
public async Task <ResponseMessage> SaveDuct([FromBody] Duct duct) { try { if (duct.Id == null) { duct.CreatedBy = LoginUser.Name; duct.CreatedDate = DateTime.UtcNow; } duct.UpdatedBy = LoginUser.Name; duct.UpdatedDate = DateTime.UtcNow; var savedDuct = await _ductService.SaveDuct(duct); if (savedDuct == null) { return new ResponseMessage { Status = "Error", Message = "Error saving duct." } } ; return(new ResponseMessage { Status = "Ok", Data = savedDuct }); } catch (Exception ex) { _logger?.LogError(ex, "Error saving duct."); return(new ResponseMessage { Status = "Error", Message = "Error saving duct." }); } }
private Duct createVAVConnection(Objects.Edge edge, ElementId ductType, ElementId system, IList <Objects.Node> nodes, IList <MEPCurve> curves, IList <FamilyInstance> vavs, IList <FamilyInstance> fittings) { Objects.Node n1 = nodes.Single(n => n.Id == edge.Node1); Objects.Node n2 = nodes.Single(n => n.Id == edge.Node2); Objects.Node vavNode = n1; if (n1.NodeType != Objects.Node.NodeTypeEnum.Vav) { vavNode = n2; } Objects.Node corrNode = n1; if (n1.NodeType != Objects.Node.NodeTypeEnum.Other) { corrNode = n2; } // find the nearest VAV to vavNode; // determine if we need to shift the connector on the corridor var fi = isFittingAtPoint(corrNode.Location, fittings, 0.1); MEPCurve toConnect = null; if (fi != null) { MEPController.MoveFittingAway(fi, edge.Diameter, out toConnect); } Duct d = MEPController.MakeDuct(_uiDoc.Document, vavNode.Location, corrNode.Location, ductType, system, edge.Diameter, 0.0); Connector tap = MEPController.GetNearestConnector(d, corrNode.Location); if (toConnect == null) { toConnect = findNearestCurve(corrNode.Location, curves, 0.05); } FamilyInstance fi2 = MEPController.MakeTakeOff(tap, toConnect); if (fi2 != null) { fittings.Add(fi2); } // connect to the Vav try { FamilyInstance fiVav = findNearest(vavs, vavNode.Location); Connector vavConn = MEPController.GetProperConnector(fiVav, FlowDirectionType.In, DuctSystemType.SupplyAir); Connector vavEnd = MEPController.GetNearestConnector(d, vavNode.Location); MEPController.Connect(vavConn, vavEnd); } catch { } return(d); }
//method to get thinnest duct element private static Duct MaxWidthDuct(List <Element> eleList) { try { Duct maxDuct = null; foreach (Element e in eleList) { if (e is Duct) { maxDuct = e as Duct; break; } } foreach (Element e in eleList) { if (e is Duct) { if (((Duct)e).Width > maxDuct.Width) { maxDuct = e as Duct; } } } return(maxDuct); } catch { throw new Exception(); } }
//method to get thinnest duct element private Duct ThinnestDuct() { try { Duct thinDuct = null; foreach (Element e in trayDuctlist) { if (e is Duct) { thinDuct = e as Duct; break; } } foreach (Element e in trayDuctlist) { if (e is Duct) { if (((Duct)e).Width < thinDuct.Width) { thinDuct = e as Duct; } } } return(thinDuct); } catch { throw new Exception(); } }
private string GetSizeText(Duct el) { // вычисляемый стандартный параметр "Размер" string currentSize = el.get_Parameter(BuiltInParameter.RBS_CALCULATED_SIZE).AsString(); // прямоугольные воздуховоды if (currentSize.Contains("x")) { List <int> partSize = new List <int>(); Regex regex = new Regex(@"\d+"); foreach (Match match in regex.Matches(currentSize)) { int x; if (Int32.TryParse(match.Value, out x)) { partSize.Add(x); } } // соединяем обратно от большего к меньшему string reorderedSize = String.Join("x", partSize.OrderByDescending(i => i)); return(reorderedSize); } // круглые воздуховоды else { return(currentSize); } }
private void Main(Duct el) { el.LookupParameter(thickParameter).Set(GetDuctThickness(el)); el.LookupParameter(classParameter).Set(GetDuctClass(el)); el.LookupParameter(levelParameter).Set(GetLevelHeight(el)); el.LookupParameter(sizeParameter).Set(GetSizeText(el)); }
/// <summary> /// Create a Duct Placeholder /// </summary> /// <param name="document"></param> /// <param name="SystemTypeId"></param> /// <param name="DuctTypeId"></param> /// <param name="LevelId"></param> /// <param name="p1"></param> /// <param name="p2"></param> /// <returns></returns> internal static Duct DrawDuctPlaceholder(Document document, ElementId SystemTypeId, ElementId DuctTypeId, ElementId LevelId, Autodesk.DesignScript.Geometry.Point p1, Autodesk.DesignScript.Geometry.Point p2) { XYZ xyz1 = new XYZ(p1.X, p1.Y, p1.Z); XYZ xyz2 = new XYZ(p2.X, p2.Y, p2.Z); Duct newDuctPlaceholder = Duct.CreatePlaceholder(document, SystemTypeId, DuctTypeId, LevelId, xyz1, xyz2); return(newDuctPlaceholder); }
private int IsVertical(Duct el) { XYZ[] pts = (from Connector con in el.ConnectorManager.Connectors select con.Origin).ToArray(); XYZ vec = pts.Where(x => x.Z == pts.Max(y => y.Z)).First() - pts.Where(x => x.Z == pts.Min(y => y.Z)).First(); bool state = vec.Normalize().IsAlmostEqualTo(XYZ.BasisZ); return(Convert.ToInt32(state)); }
const double twoInches = 1.0 / 6.0; // two twelfths of a foot is a sixth /// <summary> /// Return dimension for this duct: /// diameter if round, else height. /// </summary> static double GetDuctDim(Duct d) { ConnectorProfileType shape = d.DuctType.Shape; return(ConnectorProfileType.Round == shape ? d.Diameter : d.Height); }
private void Main(Duct el) { el.LookupParameter(thickParameter).Set(GetDuctThickness(el)); el.LookupParameter(classParameter).Set(GetDuctClass(el)); el.LookupParameter(levelParameter).Set(GetLevelHeight(el)); el.LookupParameter(horizontalParameter).Set(IsHorizontal(el)); el.LookupParameter(verticalParameter).Set(IsVertical(el)); }
/// <summary> /// Return dimension for this duct: /// diameter if round, else height. /// </summary> static double GetDuctDim( Duct d, ConnectorProfileType shape) { return(ConnectorProfileType.Round == shape ? d.Diameter : d.Height); }
public static void DuctElementExcelPara(Document doc, FilteredElementCollector ductCollector, System.Data.DataTable dt) { foreach (Element ele in ductCollector) { Duct duct = ele as Duct; if (duct != null) { string Olev = null; double width = 0.0; double height = 0.0; double offset = 0.0; string shuidui = null; string chuizhidui = null; string type = null; foreach (Parameter param in duct.Parameters) { InternalDefinition definition = null; definition = param.Definition as InternalDefinition; if (null == definition) { continue; } if (BuiltInParameter.RBS_START_LEVEL_PARAM == definition.BuiltInParameter) { Olev = param.AsValueString(); } if (BuiltInParameter.RBS_CURVE_WIDTH_PARAM == definition.BuiltInParameter) { width = param.AsDouble(); } if (BuiltInParameter.RBS_CURVE_HEIGHT_PARAM == definition.BuiltInParameter) { height = param.AsDouble(); } if (BuiltInParameter.RBS_OFFSET_PARAM == definition.BuiltInParameter) { offset = param.AsDouble(); } if (BuiltInParameter.RBS_CURVE_HOR_OFFSET_PARAM == definition.BuiltInParameter) { shuidui = param.AsValueString(); } if (BuiltInParameter.RBS_CURVE_VERT_OFFSET_PARAM == definition.BuiltInParameter) { chuizhidui = param.AsValueString(); } if (BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM == definition.BuiltInParameter) { type = param.AsValueString(); } } CreateDuctEXCELRow(dt, duct.DuctType.Name, Olev, FeetTomm(width), FeetTomm(height), FeetTomm(offset), shuidui, chuizhidui, type); } } }
public static Duct MakeDuct(Document doc, XYZ p1, XYZ p2, ElementId typ, ElementId mst, object diameter, object insulationThick) { if (typ == null) { throw new ArgumentNullException("A Duct Type must be specified"); } // use default level (actually - it appears that this doesn't work??? ElementId level = new ElementId(-1); IList <Level> levelsBelow = getAllLevelsBelow(doc, Math.Min(p1.Z, p2.Z)); Level levElement = null; if (levelsBelow != null) { levElement = levelsBelow[0]; } else { levElement = getClosestLevel(doc, Math.Min(p1.Z, p2.Z)); } Duct d = Duct.Create(doc, mst, typ, levElement.Id, p1, p2); if (diameter != null) { if (diameter is String) { d.get_Parameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM).SetValueString(diameter.ToString()); } if (diameter is double) { d.get_Parameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM).Set(Convert.ToDouble(diameter)); } } if (insulationThick != null) { //if (insulationThick is String) //{ // d.get_Parameter(BuiltInParameter.RBS_PIPE_INSULATION_THICKNESS).SetValueString(insulationThick.ToString()); //} //if (insulationThick is double) //{ // double ins = Convert.ToDouble(insulationThick); // if (ins != 0) d.get_Parameter(BuiltInParameter.RBS_PIPE_INSULATION_THICKNESS).Set(Convert.ToDouble(insulationThick)); //} double thick = Convert.ToDouble(insulationThick); if (thick > 0) { DuctInsulation test = DuctInsulation.Create(doc, d.Id, new ElementId(-1), Convert.ToDouble(insulationThick)); } } return(d); }
public void GetAllVerticalDuctConnectedToDuctTest() { Duct duct = new Duct(1244249984656736257); string strArchPath = "D://Users//zheny//Source//Repos//HVAC-Checker//HVAC-Checker//6.2.2-arch.GDB"; string strHVACPath = "D://Users//zheny//Source//Repos//HVAC-Checker//HVAC-Checker//6.2.2-HVAC.GDB"; HVACFunction hvacFunction = new HVACFunction(strArchPath, strHVACPath); List <Duct> ducts = HVACFunction.GetAllVerticalDuctConnectedToDuct(duct); Assert.IsTrue(ducts.Count() > 0); }
private List <Connector> CreateDuct(XYZ point1, XYZ point2) { List <Connector> connectors = new List <Connector>(); Duct duct = Duct.Create(m_document, m_systemTypeId, m_ductTypeId, m_level.Id, point1, point2); connectors.Add(ConnectorInfo.GetConnector(duct, point1)); connectors.Add(ConnectorInfo.GetConnector(duct, point2)); return(connectors); }
//============================================== /// <summary> /// Generate a Transform instance which as Transform property of BoundingBoxXYZ, /// when the user select a beam, this method will be called /// </summary> /// <returns>the reference of Transform, return null if it can't be generated</returns> Transform GenerateDuctTransform() { Transform transform = null; Duct instance = m_currentComponent as Duct; // First check whether the beam is horizontal. // In order to predigest the calculation, only allow it to be horizontal //double startOffset = instance.get_Parameter(BuiltInParameter.STRUCTURAL_BEAM_END0_ELEVATION).AsDouble(); //var startOffset2 = instance.get_Parameter(BuiltInParameter.RBS_DUCT_SLOPE); double ductSlope = instance.get_Parameter(BuiltInParameter.RBS_DUCT_SLOPE).AsDouble(); if (ductSlope != 0) { m_errorInformation = "Please select a horizontal duct."; return(transform); } int nDucts = 0; int nCurves = 0; LocationCurve lc = instance.Location as LocationCurve; Debug.Assert(null != lc, "expected duct to have valid location curve."); if (null != lc) { ++nCurves; Curve c = lc.Curve; // Now I am sure I can create a transform instance. transform = Transform.Identity; // Third find the middle point of the line and set it as Origin property. Autodesk.Revit.DB.XYZ startPoint = c.GetEndPoint(0); Autodesk.Revit.DB.XYZ endPoint = c.GetEndPoint(1); Autodesk.Revit.DB.XYZ midPoint = XYZMath.FindMidPoint(startPoint, endPoint); transform.Origin = midPoint; // At last find out the directions of the created view, and set it as Basis property. Autodesk.Revit.DB.XYZ basisZ = XYZMath.FindDirection(startPoint, endPoint); Autodesk.Revit.DB.XYZ basisX = XYZMath.FindRightDirection(basisZ); Autodesk.Revit.DB.XYZ basisY = XYZMath.FindUpDirection(basisZ); transform.set_Basis(0, basisX); transform.set_Basis(1, basisY); transform.set_Basis(2, basisZ); } return(transform); }
/// <summary> /// Analyse the given duct element: /// determine its first rectangular connector, /// retrieve its solid, /// find the face containing the connector, /// and list its four vertices. /// </summary> static bool AnalyseDuct(Duct duct) { bool rc = false; Connector c1; if (!GetFirstRectangularConnector(duct, out c1)) { Trace.TraceError("The duct is not rectangular!"); } else { Options opt = new Options(); opt.DetailLevel = ViewDetailLevel.Fine; GeometryElement geoElement = duct.get_Geometry(opt); //foreach( GeometryObject obj in geoElement.Objects ) // 2012 foreach (GeometryObject obj in geoElement) // 2013 { Solid solid = obj as Solid; if (solid != null) { bool foundFace = false; foreach (Face face in solid.Faces) { foundFace = FaceContainsConnector(face, c1); if (foundFace) { Trace.WriteLine("==> Four face corners:"); EdgeArray a = face.EdgeLoops.get_Item(0); foreach (Edge e in a) { XYZ p = e.Evaluate(0.0); Trace.WriteLine("Point = " + Util.PointString(p)); } rc = true; break; } } if (!foundFace) { Trace.WriteLine("[Error] Face not found"); } } } } return(rc); }
private int IsHorizontal(Duct el) { var top = el.get_Parameter(BuiltInParameter.RBS_DUCT_TOP_ELEVATION).AsDouble(); var bottom = el.get_Parameter(BuiltInParameter.RBS_DUCT_BOTTOM_ELEVATION).AsDouble(); var height_p1 = el.get_Parameter(BuiltInParameter.RBS_CURVE_HEIGHT_PARAM); var height_p2 = el.get_Parameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM); var height = height_p1 != null?height_p1.AsDouble() : height_p2.AsDouble(); var diff = Math.Abs(top - bottom - height); var state = diff * 304.8 < 0.1; return(Convert.ToInt32(state)); }
/// <summary> /// Return shape of first end connector on given duct. /// </summary> static ConnectorProfileType GetShape(Duct duct) { ConnectorProfileType ductShape = ConnectorProfileType.Invalid; foreach (Connector c in duct.ConnectorManager.Connectors) { if (c.ConnectorType == ConnectorType.End) { ductShape = c.Shape; break; } } return(ductShape); }
public static List <BH.oM.MEP.System.Duct> DuctFromRevit(this Autodesk.Revit.DB.Mechanical.Duct revitDuct, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); // Reuse a BHoM duct from refObjects if it has been converted before List <BH.oM.MEP.System.Duct> bhomDucts = refObjects.GetValues <BH.oM.MEP.System.Duct>(revitDuct.Id); if (bhomDucts != null) { return(bhomDucts); } else { bhomDucts = new List <BH.oM.MEP.System.Duct>(); } List <BH.oM.Geometry.Line> queried = Query.LocationCurveMEP(revitDuct, settings); // Flow rate double flowRate = revitDuct.LookupParameterDouble(BuiltInParameter.RBS_DUCT_FLOW_PARAM); BH.oM.MEP.System.SectionProperties.DuctSectionProperty sectionProperty = BH.Revit.Engine.Core.Query.DuctSectionProperty(revitDuct, settings); // Orientation angle double orientationAngle = revitDuct.OrientationAngle(settings); //ToDo - resolve in next issue, specific issue being raised for (int i = 0; i < queried.Count; i++) { BH.oM.Geometry.Line segment = queried[i]; BH.oM.MEP.System.Duct thisSegment = new Duct { StartPoint = segment.StartPoint(), EndPoint = segment.EndPoint(), FlowRate = flowRate, SectionProperty = sectionProperty, OrientationAngle = orientationAngle }; //Set identifiers, parameters & custom data thisSegment.SetIdentifiers(revitDuct); thisSegment.CopyParameters(revitDuct, settings.ParameterSettings); thisSegment.SetProperties(revitDuct, settings.ParameterSettings); bhomDucts.Add(thisSegment); } refObjects.AddOrReplace(revitDuct.Id, bhomDucts); return(bhomDucts); }
public override void InnerExecute(UpdaterData data) { foreach (ElementId id in data.GetModifiedElementIds().Concat(data.GetAddedElementIds())) { try { Duct el = (Duct)Document.GetElement(id); Main(el); } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); Debug.WriteLine("Element id: " + id.IntegerValue.ToString()); } } }
public override void Load() { RoutedLayer = new RoutedLayer(); markerModules = new Dictionary <string, Type>(); Duct.Initialize(); Hooking.Initialize(); if (!Main.dedServ) { textureLootAll = ModContent.GetTexture("BaseLibrary/Textures/UI/LootAll"); textureDepositAll = ModContent.GetTexture("BaseLibrary/Textures/UI/DepositAll"); textureQuickStack = ModContent.GetTexture("BaseLibrary/Textures/UI/QuickStack"); } EmitDynamicItems(); }
public static double SolidVolume(this Duct duct) { double length = duct.Length(); double elementSolidArea = duct.SectionProperty.ElementSolidArea; double insulationSolidArea = duct.SectionProperty.InsulationSolidArea; double liningSolidArea = duct.SectionProperty.LiningSolidArea; if (length <= 0) { Engine.Reflection.Compute.RecordError("Cannot query SolidVolume from zero length members."); return(double.NaN); } if (duct.SectionProperty.SectionProfile.ElementProfile == null) { Engine.Reflection.Compute.RecordWarning("No ElementProfile detected for object " + duct.BHoM_Guid); } if (duct.SectionProperty.SectionProfile.InsulationProfile == null) { Engine.Reflection.Compute.RecordWarning("No InsulationProfile detected for object " + duct.BHoM_Guid); } if (duct.SectionProperty.SectionProfile.LiningProfile == null) { Engine.Reflection.Compute.RecordWarning("No LiningProfile detected for object " + duct.BHoM_Guid); } if (elementSolidArea <= 0) { Engine.Reflection.Compute.RecordNote("ElementSolidArea is 0. Returning 0 for ElementSolidVolume."); } if (insulationSolidArea <= 0) { Engine.Reflection.Compute.RecordNote("InsulationSolidArea is 0. Returning 0 for LiningSolidVolume."); } if (liningSolidArea <= 0) { Engine.Reflection.Compute.RecordNote("LiningSolidArea is 0. Returning 0 for InsulationSolidVolume."); } return((length * elementSolidArea) + (length * insulationSolidArea) + (length * liningSolidArea)); }
private void PrepareDiametersList() { Duct temp; DiametersList = new ObservableCollection <Duct>(); foreach (string diameterNode in StaticResources.DiametersList) { temp = new Duct() { DuctType = Compute_Engine.Enums.DuctType.Round, Diameter = int.Parse(diameterNode), AirFlow = Convert.ToInt32(ConvertUnits(AirVolume, AirVolumeUnit, Units.CubicMetersPerHour)), }; DiametersList.Add(temp); } }
public static Output <double, double, double> CompositeSolidVolumes(this Duct duct) { double length = duct.Length(); double elementSolidVolume = duct.SectionProperty.ElementSolidArea * length; double insulationSolidVolume = duct.SectionProperty.InsulationSolidArea * length; double liningSolidVolume = duct.SectionProperty.LiningSolidArea * length; if (duct.SectionProperty == null) { Engine.Reflection.Compute.RecordError("No section property defined."); return(null); } //Negative LiningThickness Warning if (duct.SectionProperty.LiningSolidArea < 0) { Engine.Reflection.Compute.RecordWarning("LiningSolidArea is a negative value, and will result in incorrect SolidVolume results. Try adjusting LiningThickness to produce a positive value for SolidArea."); } //SolidArea = 0 user feedback. if (duct.SectionProperty.ElementSolidArea <= 0) { Engine.Reflection.Compute.RecordNote("ElementSolidArea is 0. Returning 0 for ElementSolidVolume."); } if (duct.SectionProperty.LiningSolidArea <= 0) { Engine.Reflection.Compute.RecordNote("LiningSolidArea is 0. Returning 0 for LiningSolidVolume."); } if (duct.SectionProperty.InsulationSolidArea <= 0) { Engine.Reflection.Compute.RecordNote("InsulationSolidArea is 0. Returning 0 for InsulationSolidVolume."); } Output <double, double, double> output = new Output <double, double, double> { Item1 = elementSolidVolume, Item2 = insulationSolidVolume, Item3 = liningSolidVolume, }; return(output); }
/// <summary> /// 对构件类型进行分类,判断是否为特定的内建类型 /// </summary> /// <param name="elem"></param> /// <returns>返回该构件的类型属性</returns> private ParameterSet GetParamSet(Element elem) { FamilyInstance instance = elem as FamilyInstance; //管道 Pipe pipe = elem as Pipe; //风管 Duct duct = elem as Duct; //墙 Wall wall = elem as Wall; //楼板 Floor floor = elem as Floor; //轴网 Grid grid = elem as Grid; ParameterSet parameters = new ParameterSet(); if (instance != null) { parameters = instance.Symbol.Parameters; } else if (pipe != null) { parameters = pipe.PipeType.Parameters; } else if (duct != null) { parameters = duct.DuctType.Parameters; } else if (wall != null) { parameters = wall.WallType.Parameters; } else if (floor != null) { parameters = floor.FloorType.Parameters; } else if (grid != null) { parameters = grid.Parameters; } return(parameters); }
/// <summary> /// Return shape of all duct connectors. /// </summary> static ConnectorProfileType[] GetProfileTypes( Duct duct) { ConnectorSet connectors = duct.ConnectorManager.Connectors; int n = connectors.Size; ConnectorProfileType[] profileTypes = new ConnectorProfileType[n]; int i = 0; foreach (Connector c in connectors) { profileTypes[i++] = c.Shape; } return(profileTypes); }
/// <summary> /// Analyse the given duct element: /// determine its first rectangular connector, /// retrieve its solid, /// find the face containing the connector, /// and list its four vertices. /// </summary> static bool AnalyseDuct( Duct duct ) { bool rc = false; Connector c1; if( !GetFirstRectangularConnector( duct, out c1 ) ) { Trace.TraceError( "The duct is not rectangular!" ); } else { Options opt = new Options(); opt.DetailLevel = ViewDetailLevel.Fine; GeometryElement geoElement = duct.get_Geometry( opt ); //foreach( GeometryObject obj in geoElement.Objects ) // 2012 foreach( GeometryObject obj in geoElement ) // 2013 { Solid solid = obj as Solid; if( solid != null ) { bool foundFace = false; foreach( Face face in solid.Faces ) { foundFace = FaceContainsConnector( face, c1 ); if( foundFace ) { Trace.WriteLine( "==> Four face corners:" ); EdgeArray a = face.EdgeLoops.get_Item( 0 ); foreach( Edge e in a ) { XYZ p = e.Evaluate( 0.0 ); Trace.WriteLine( "Point = " + Util.PointString( p ) ); } rc = true; break; } } if( !foundFace ) { Trace.WriteLine( "[Error] Face not found" ); } } } } return rc; }
/// <summary> /// Return the first rectangular connector of the given duct element. /// </summary> static bool GetFirstRectangularConnector( Duct duct, out Connector c1) { c1 = null; ConnectorSet connectors = duct.ConnectorManager.Connectors; if( 0 < connectors.Size ) { foreach( Connector c in connectors ) { if( ConnectorProfileType.Rectangular == c.Shape ) { c1 = c; break; } else { Trace.WriteLine( "Connector shape: " + c.Shape ); } } } return null != c1; }
private void Stream( ArrayList data, Duct duct ) { data.Add( new Snoop.Data.ClassSeparator( typeof( Duct ) ) ); data.Add( new Snoop.Data.Object( "Duct type", duct.DuctType ) ); }