示例#1
0
 public TrussDetailControl(Truss activeTruss) : this()
 {
     FavTruss.Span          = activeTruss.Span;
     FavTruss.Slope         = activeTruss.Slope;
     FavTruss.SupportHeight = activeTruss.SupportDepth;
     FavTruss.PanelAmount   = activeTruss.PanelAmount;
 }
示例#2
0
        public TrussInfo CreateTrussInfo(Document doc, XYZ currentPointOnHip, EdgeInfo currentRidgeEdgeInfo, Element firstSupport, Element secondSupport, TrussType tType)
        {
            TrussInfo currentTrussInfo = TrussInfo.BuildTrussAtHip(currentPointOnHip, currentRidgeEdgeInfo, firstSupport, secondSupport);

            using (Transaction t = new Transaction(doc, "Criar treliça"))
            {
                t.Start();

                if (currentTrussInfo != null)
                {
                    SketchPlane stkP = SketchPlane.Create(doc, currentRidgeEdgeInfo.CurrentRoof.LevelId);

                    double levelHeight = currentRidgeEdgeInfo.GetCurrentRoofHeight();

                    XYZ   firstPoint   = new XYZ(currentTrussInfo.FirstPoint.X, currentTrussInfo.FirstPoint.Y, levelHeight);
                    XYZ   secondPoint  = new XYZ(currentTrussInfo.SecondPoint.X, currentTrussInfo.SecondPoint.Y, levelHeight);
                    Truss currentTruss = Truss.Create(doc, tType.Id, stkP.Id, Line.CreateBound(firstPoint, secondPoint));

                    currentTruss.get_Parameter(BuiltInParameter.TRUSS_HEIGHT).Set(currentTrussInfo.Height);
                }

                t.Commit();
            }
            //DEBUG.CreateDebugPoint(doc, currentPointOnHip);

            return(currentTrussInfo);
        }
示例#3
0
 /// <summary>
 /// Create a new truss object.
 /// </summary>
 public void Restart()
 {
     model = new Truss();
     joints.Clear();
     pin    = null;
     roller = null;
     knownForces.Clear();
 }
        public ProjectTruss GetInfo(Project project, Truss truss)
        {
            var pt = _trussContext.ProjectTruss
                     .ToArray()
                     .FirstOrDefault(projTruss => projTruss.ProjectId == project.ProjectId && projTruss.TrussId == truss.TrussId);

            return(pt != null?Mapper.Map <ProjectTruss>(pt) : null);
        }
示例#5
0
        public void Truss()
        {
            this.Name = "Truss";
            var model   = new Model();
            var profile = WideFlangeProfileServer.Instance.GetProfileByName("W33x387");
            var truss   = new Truss(new Vector3(0, 0, 0), new Vector3(0, 30, 0), 3.0, 10, profile, profile, profile, BuiltInMaterials.Steel, 0.1, 0.1);

            this.Model.AddElement(truss);
        }
示例#6
0
        public void Example()
        {
            var model   = new Model();
            var profile = WideFlangeProfileServer.Instance.GetProfileByName("W33x387");
            var truss   = new Truss(new Vector3(0, 0, 0), new Vector3(0, 10, 0), 1.0, 10, profile, profile, profile, BuiltInMaterials.Steel, 0.1, 0.1);

            model.AddElement(truss);
            model.SaveGlb("truss.glb");
        }
示例#7
0
        /// <summary>
        /// Creates trusses along a specific ridge edge and stores them on a list of truss info
        /// </summary>
        /// <param name="currentRidgeEdgeInfo">The specific edge ridge to create trusses</param>
        /// <param name="doc">The target document to create the trusses</param>
        /// <param name="tType">The target truss type to be used on creation</param>
        /// <returns>The list of info of the created trusses</returns>
        private IList <TrussInfo> CreateTrussInfoList(EdgeInfo currentRidgeEdgeInfo, Document doc, TrussType tType)
        {
            IList <TrussInfo> trussInfoList = new List <TrussInfo>();

            if (currentRidgeEdgeInfo.RoofLineType == RoofLineType.RidgeSinglePanel || currentRidgeEdgeInfo.RoofLineType == RoofLineType.Ridge)
            {
                Line currentRidgeLineShortenedBySupports = currentRidgeEdgeInfo.Curve as Line;

                if (currentRidgeLineShortenedBySupports == null)
                {
                    return(trussInfoList);
                }

                IList <EdgeInfo> startConditions = currentRidgeEdgeInfo.GetEndConditions(0);
                IList <EdgeInfo> endConditions   = currentRidgeEdgeInfo.GetEndConditions(1);

                currentRidgeLineShortenedBySupports = ShortenRidgeIfNecessary(currentRidgeLineShortenedBySupports, startConditions, endConditions);

                Tuple <int, double> iterations = Utils.Utils.EstabilishIterations(currentRidgeLineShortenedBySupports.ApproximateLength, trussDistance);
                int    numPoints = iterations.Item1;
                double distance  = iterations.Item2;

                for (int i = 0; i <= numPoints; i++)
                {
                    double    currentParam        = i * distance;
                    XYZ       currentPointOnRidge = currentRidgeLineShortenedBySupports.Evaluate(currentRidgeLineShortenedBySupports.GetEndParameter(0) + currentParam, false);
                    TrussInfo currentTrussInfo    = TrussInfo.BuildTrussAtRidge(currentPointOnRidge, currentRidgeEdgeInfo, null);

                    if (currentTrussInfo != null)
                    {
                        SketchPlane stkP = SketchPlane.Create(doc, currentRidgeEdgeInfo.CurrentRoof.LevelId);

                        double levelHeight = currentRidgeEdgeInfo.GetCurrentRoofHeight();

                        XYZ   firstPoint   = new XYZ(currentTrussInfo.FirstPoint.X, currentTrussInfo.FirstPoint.Y, levelHeight);
                        XYZ   secondPoint  = new XYZ(currentTrussInfo.SecondPoint.X, currentTrussInfo.SecondPoint.Y, levelHeight);
                        Truss currentTruss = Truss.Create(doc, tType.Id, stkP.Id, Line.CreateBound(firstPoint, secondPoint));

                        currentTruss.get_Parameter(BuiltInParameter.TRUSS_HEIGHT).Set(currentTrussInfo.Height);
                        trussInfoList.Add(currentTrussInfo);
                    }
                    #region DEBUG ONLY
                    else
                    {
#if DEBUG
                        FamilySymbol fs = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel).WhereElementIsElementType().Where(type => type.Name.Contains("DebugPoint")).FirstOrDefault() as FamilySymbol;
                        fs.Activate();
                        doc.Create.NewFamilyInstance(currentPointOnRidge, fs, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
#endif
                    }
                    #endregion
                }
            }

            return(trussInfoList);
        }
示例#8
0
        public void Remove(Truss itemToDelete)
        {
            var dbTruss = _trussContext.Truss.First(tr => tr.TrussId == itemToDelete.TrussId);

            _trussContext.Bar.RemoveRange(dbTruss.Bar);

            _trussContext.ProjectTruss.RemoveRange(dbTruss.ProjectTruss);
            _trussContext.Truss.Remove(dbTruss);
            _trussContext.SaveChanges();
        }
        /// <summary>
        /// Exports a truss as an IFC assembly.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="truss">The truss element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportTrussElement(ExporterIFC exporterIFC, Truss truss,
                                              ProductWrapper productWrapper)
        {
            if (truss == null)
            {
                return;
            }

            ICollection <ElementId> trussMemberIds = truss.Members;

            ExportAssemblyInstanceWithMembers(exporterIFC, truss, trussMemberIds, IFCElementAssemblyType.Truss, productWrapper);
        }
示例#10
0
        public void Serialize()
        {
            var model   = new Model();
            var profile = WideFlangeProfileServer.Instance.GetProfileByName("W33x387");
            var truss   = new Truss(new Vector3(0, 0, 0), new Vector3(0, 10, 0), 1.0, 10, profile, profile, profile, BuiltInMaterials.Steel, 0.1, 0.1);

            model.AddElement(truss);
            var json     = model.ToJson();
            var newModel = Model.FromJson(json);
            var newTruss = newModel.ElementsOfType <Truss>().FirstOrDefault();

            Assert.Equal(truss.Divisions, newTruss.Divisions);
            Assert.Equal(truss.Depth, newTruss.Depth);
            Assert.Equal(truss.Start, newTruss.Start);
            Assert.Equal(truss.End, newTruss.End);
        }
示例#11
0
        public void Truss()
        {
            this.Name = "Elements_Truss";

            // <example>
            // Create a framing type.
            var profile     = WideFlangeProfileServer.Instance.GetProfileByName("W33x387");
            var framingType = new StructuralFramingType("W33x387", profile, BuiltInMaterials.Steel);

            // Create a truss.
            var truss = new Truss(new Vector3(0, 0, 0), new Vector3(0, 30, 10), 3.0, 10, framingType, framingType, framingType, BuiltInMaterials.Steel, 0.1, 0.1);

            // </example>

            this.Model.AddElement(truss);

            Assert.Equal(this.Model.Elements.Count, truss.Elements.Count + 1);
        }
示例#12
0
        private TrussInfo CreateTrussInfo(Document doc, XYZ currentPointOnRidge, EdgeInfo currentRidgeEdgeInfo, IList <XYZ> currentSupportPoints, TrussType tType)
        {
            TrussInfo currentTrussInfo = TrussInfo.BuildTrussAtRidge(currentPointOnRidge, currentRidgeEdgeInfo, currentSupportPoints);

            if (currentTrussInfo != null)
            {
                SketchPlane stkP = SketchPlane.Create(doc, currentRidgeEdgeInfo.CurrentRoof.LevelId);

                double levelHeight = currentRidgeEdgeInfo.GetCurrentRoofHeight();

                XYZ   firstPoint   = new XYZ(currentTrussInfo.FirstPoint.X, currentTrussInfo.FirstPoint.Y, levelHeight);
                XYZ   secondPoint  = new XYZ(currentTrussInfo.SecondPoint.X, currentTrussInfo.SecondPoint.Y, levelHeight);
                Truss currentTruss = Truss.Create(doc, tType.Id, stkP.Id, Line.CreateBound(firstPoint, secondPoint));

                currentTruss.get_Parameter(BuiltInParameter.TRUSS_HEIGHT).Set(currentTrussInfo.Height);
            }


            return(currentTrussInfo);
        }
示例#13
0
        public void Serialize()
        {
            this.Name = "Truss";

            var profile   = WideFlangeProfileServer.Instance.GetProfileByName("W8x13");
            var chordType = new StructuralFramingType("W33x387", profile, new Material("Chord", Colors.Aqua));
            var webType   = new StructuralFramingType("W33x387", profile, new Material("Web", Colors.Orange));
            var truss     = new Truss(new Vector3(0, 0, 0), new Vector3(0, 10, 0), 1.0, 10, chordType, chordType, webType, BuiltInMaterials.Steel, 0.1, 0.1);

            this.Model.AddElement(truss);

            var json     = this.Model.ToJson();
            var newModel = Model.FromJson(json);
            var newTruss = newModel.ElementsOfType <Truss>().FirstOrDefault();

            Assert.Equal(truss.Divisions, newTruss.Divisions);
            Assert.Equal(truss.Depth, newTruss.Depth);
            Assert.Equal(truss.Start, newTruss.Start);
            Assert.Equal(truss.End, newTruss.End);
        }
示例#14
0
        public void Update(Truss item)
        {
            var dbTruss = _trussContext.Truss.First(tr => tr.TrussId == item.TrussId);

            if (dbTruss.PanelAmount != item.PanelAmount)
            {
                dbTruss.PanelAmount = item.PanelAmount;
                _trussContext.Bar.RemoveRange(dbTruss.Bar);
                for (int i = 1; i <= item.PanelAmount / 2; i++)
                {
                    _trussContext.Bar.Add(new BarDA
                    {
                        TrussId   = item.TrussId,
                        ElementId = _trussContext.TrussElement.First(el => el.ShortName == "ВП").ElementId,
                        BarNumber = i
                    });

                    _trussContext.Bar.Add(new BarDA
                    {
                        TrussId   = item.TrussId,
                        ElementId = _trussContext.TrussElement.First(el => el.ShortName == "НП").ElementId,
                        BarNumber = item.PanelAmount / 2 + i
                    });

                    if (i == 1)
                    {
                        _trussContext.Bar.Add(new BarDA
                        {
                            TrussId   = item.TrussId,
                            ElementId = _trussContext.TrussElement.First(el => el.ShortName == "ОР").ElementId,
                            BarNumber = item.PanelAmount + 2 * i - 1
                        });
                        _trussContext.Bar.Add(new BarDA
                        {
                            TrussId   = item.TrussId,
                            ElementId = _trussContext.TrussElement.First(el => el.ShortName == "ОР").ElementId,
                            BarNumber = item.PanelAmount + 2 * i
                        });
                    }
                    else
                    {
                        _trussContext.Bar.Add(new BarDA
                        {
                            TrussId   = item.TrussId,
                            ElementId = _trussContext.TrussElement.First(el => el.ShortName == "Р").ElementId,
                            BarNumber = item.PanelAmount + 2 * i - 1
                        });
                        _trussContext.Bar.Add(new BarDA
                        {
                            TrussId   = item.TrussId,
                            ElementId = _trussContext.TrussElement.First(el => el.ShortName == "Р").ElementId,
                            BarNumber = item.PanelAmount + 2 * i
                        });
                    }
                }
            }
            dbTruss.Span         = item.Span;
            dbTruss.Slope        = item.Slope;
            dbTruss.SupportDepth = item.SupportDepth;
            dbTruss.LoadId       = item.LoadId;
            _trussContext.SaveChanges();
            item.Bar = new ObservableCollection <Bar>(dbTruss.Bar.Select(Mapper.Map <Bar>));
        }
        /// <summary>
        /// Exports a truss as an IFC assembly.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="truss">The truss element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportTrussElement(ExporterIFC exporterIFC, Truss truss,
            ProductWrapper productWrapper)
        {
            if (truss == null)
                return;

            ICollection<ElementId> trussMemberIds = truss.Members;
            ExportAssemblyInstanceWithMembers(exporterIFC, truss, trussMemberIds, IFCElementAssemblyType.Truss, productWrapper);
        }
示例#16
0
        private void Stream( ArrayList data, Truss truss )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( Truss ) ) );

              data.Add( new Snoop.Data.Enumerable( "Curves", truss.Curves ) );
              data.Add( new Snoop.Data.Enumerable( "Members", truss.Members ) );
              data.Add( new Snoop.Data.Object( "Truss type", truss.TrussType ) );
        }
示例#17
0
 public TrussBuilder()
 {
     model       = new Truss();
     joints      = new List <Vertex>();
     knownForces = new List <Tuple <Vertex, Vector> >();
 }
示例#18
0
        public void Add(Truss item)
        {
            var addTruss    = Mapper.Map <TrussDA>(item);
            var searchTruss = _trussContext.Truss.FirstOrDefault(truss =>
                                                                 truss.Span == addTruss.Span &&
                                                                 Math.Abs(truss.Slope - addTruss.Slope) < 0.001 &&
                                                                 truss.PanelAmount == addTruss.PanelAmount &&
                                                                 truss.LoadId == addTruss.LoadId &&
                                                                 truss.UnitForce == addTruss.UnitForce &&
                                                                 truss.SupportDepth == addTruss.SupportDepth);

            if (searchTruss == null)
            {
                if (addTruss.UnitForce)
                {
                    addTruss.UnitForce = false;
                }

                _trussContext.Truss.Add(addTruss);
                for (var i = 1; i <= addTruss.PanelAmount / 2; i++)
                {
                    _trussContext.Bar.Add(new BarDA
                    {
                        TrussId   = addTruss.TrussId,
                        ElementId = _trussContext.TrussElement.First(el => el.ShortName == "ВП").ElementId,
                        BarNumber = i
                    });

                    _trussContext.Bar.Add(new BarDA
                    {
                        TrussId   = addTruss.TrussId,
                        ElementId = _trussContext.TrussElement.First(el => el.ShortName == "НП").ElementId,
                        BarNumber = addTruss.PanelAmount / 2 + i
                    });

                    if (i == 1)
                    {
                        _trussContext.Bar.Add(new BarDA
                        {
                            TrussId   = addTruss.TrussId,
                            ElementId = _trussContext.TrussElement.First(el => el.ShortName == "ОР").ElementId,
                            BarNumber = addTruss.PanelAmount + 2 * i - 1
                        });
                        _trussContext.Bar.Add(new BarDA
                        {
                            TrussId   = addTruss.TrussId,
                            ElementId = _trussContext.TrussElement.First(el => el.ShortName == "ОР").ElementId,
                            BarNumber = addTruss.PanelAmount + 2 * i
                        });
                    }
                    else
                    {
                        _trussContext.Bar.Add(new BarDA
                        {
                            TrussId   = addTruss.TrussId,
                            ElementId = _trussContext.TrussElement.First(el => el.ShortName == "Р").ElementId,
                            BarNumber = addTruss.PanelAmount + 2 * i - 1
                        });
                        _trussContext.Bar.Add(new BarDA
                        {
                            TrussId   = addTruss.TrussId,
                            ElementId = _trussContext.TrussElement.First(el => el.ShortName == "Р").ElementId,
                            BarNumber = addTruss.PanelAmount + 2 * i
                        });
                    }
                }

                _trussContext.SaveChanges();
                item.TrussId = Mapper.Map <Truss>(addTruss).TrussId;
                item.Bar     = new ObservableCollection <Bar>(addTruss.Bar.Select(Mapper.Map <Bar>));
            }
            else
            {
                item.Bar     = new ObservableCollection <Bar>(searchTruss.Bar.Select(Mapper.Map <Bar>));
                item.TrussId = searchTruss.TrussId;
            }
        }