Пример #1
0
        private List <Member> createArch(float height, float scale, float supportWidth, float supportHeight)
        {
            TrussType archType = (TrussType)archTrussBox.SelectedIndex;
            int       archWebs = (int)archWebBox.Value;

            List <Member> bottomArch = new List <Member>();

            float startX = supportWidth;
            float startY = bitBox.Height;

            float xOriginal = bitBox.Width / 2;
            float yOriginal = (int)(-(scale * height) + (xOriginal * xOriginal) / (height * scale) / 2);

            float radius      = (float)Math.Sqrt(Math.Pow(startX - xOriginal, 2) + Math.Pow(startY - yOriginal, 2));
            float chordLength = (bitBox.Width - supportWidth * 2);
            float vertexAngle = 2 * (float)Math.Asin(chordLength / (2 * radius));

            //measured in radians
            // pi/2 - the angle of the chord start (sin-1[c/(2r)])
            float currentAngle = (1 / 2f) * (float)Math.PI - vertexAngle / 2;

            ;

            Point lastPoint = new Point((int)(scale * 1.75f), bitBox.Height);

            for (int i = 1; i < archWebs + 1; i++)
            {
                //int x = (int)(scale * ((16.25f / (archWebs + 1) * i) + 1.75f));
                //Point nextPoint = new Point(x, -((int)Math.Sqrt((radius * radius) - Math.Pow(x - xOriginal, 2)) - (int)yOriginal));

                currentAngle += vertexAngle / (float)(archWebs + 1);
                Point nextPoint = new Point((int)(-radius * Math.Cos(currentAngle) + xOriginal), (int)(-radius * Math.Sin(currentAngle) + yOriginal));

                bottomArch.Add(new Member(lastPoint, nextPoint));
                lastPoint = nextPoint;
            }
            bottomArch.Add(new Member(lastPoint, new Point(bitBox.Width - (int)(scale * 1.75f), bitBox.Height)));

            int currentLength = bottomArch.Count();

            List <Member> topArch = new List <Member>();

            for (int i = 0; i < currentLength; i++)
            {
                Member member = bottomArch[i];
                topArch.Add(new Member(member.Start.X, member.Start.Y - (int)supportHeight, member.End.X, (int)(member.End.Y - supportHeight)));
            }


            return(TrussCreator.CreateTruss(topArch, bottomArch, archType, (int)archExtraBox.Value));
        }
Пример #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            if ((uidoc.ActiveView as View3D) == null)
            {
                message = "Por favor, rode este comando em uma vista 3d";
                return(Result.Failed);
            }


            ISelectionFilter ridgeSelectionFilter = new RoofClasses.SelectionFilters.StraightLinesAndFacesRidgeSelectionFilter(doc);
            Reference        currentReference     = uidoc.Selection.PickObject(ObjectType.Edge, ridgeSelectionFilter);

            FootPrintRoof currentFootPrintRoof = doc.GetElement(currentReference) as FootPrintRoof;
            Edge          edge = Support.GetEdgeFromReference(currentReference, currentFootPrintRoof);

            IList <PlanarFace> pfaces = new List <PlanarFace>();

            Support.IsListOfPlanarFaces(HostObjectUtils.GetBottomFaces(currentFootPrintRoof)
                                        , currentFootPrintRoof, out pfaces);

            IList <RoofClasses.EdgeInfo> currentEdgeInfoList = Support.GetRoofEdgeInfoList(currentFootPrintRoof, false);
            Curve currentCurve = Support.GetMostSimilarCurve(edge.AsCurve(), currentEdgeInfoList);

            RoofClasses.EdgeInfo currentInfo = Support.GetCurveInformation(currentFootPrintRoof, currentCurve, pfaces);
            TaskDialog.Show("fac", currentInfo.RoofLineType.ToString());

            Element tTypeElement = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(fsy => fsy is TrussType).ToList().FirstOrDefault();

            if (tTypeElement == null)
            {
                message = "Nenhum tipo de treliça foi encontrada no projeto, por favor, carregue um tipo e rode este comando novamente";
                return(Result.Failed);
            }

            TrussType tType = tTypeElement as TrussType;

            Managers.TrussRidgeManager    currentTrussManager  = new Managers.TrussRidgeManager();
            IList <RoofClasses.TrussInfo> currentTrussInfoList = currentTrussManager.CreateTrussesFromRidgeInfo(currentInfo, tType);

            TaskDialog tDialog = new TaskDialog("Trusses");

            tDialog.MainInstruction = currentTrussInfoList.Count.ToString();
            tDialog.Show();

            return(Result.Succeeded);
        }
Пример #3
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            if ((uidoc.ActiveView as View3D) == null)
            {
                message = "Por favor, rode este comando em uma vista 3d";
                return(Result.Failed);
            }

            try
            {
                Element   tTypeElement = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(fsy => fsy is TrussType).ToList().FirstOrDefault();
                TrussType tType        = tTypeElement as TrussType;

                if (tTypeElement == null)
                {
                    message = "Nenhum tipo de treliça foi encontrada no projeto, por favor, carregue um tipo e rode este comando novamente";
                    return(Result.Failed);
                }

                Reference     currentReference     = uidoc.Selection.PickObject(ObjectType.Element, new RoofClasses.SelectionFilters.StraightLinesAndFacesFootPrintRoofSelFilter(), "Selecione um telhado.");
                FootPrintRoof currentFootPrintRoof = doc.GetElement(currentReference) as FootPrintRoof;

                Managers.TrussRidgeManager    currentTrussManager  = new Managers.TrussRidgeManager();
                IList <RoofClasses.TrussInfo> currentTrussInfoList = currentTrussManager.CreateTrussesFromRoof(currentFootPrintRoof, tType);

                TaskDialog tDialog = new TaskDialog("Trusses");
                tDialog.MainInstruction = currentTrussInfoList.Count.ToString();
                tDialog.Show();
            }
            catch (Exception e)
            {
                if (!(e is Autodesk.Revit.Exceptions.OperationCanceledException))
                {
                    throw e;
                }
            }

            return(Result.Succeeded);
        }
Пример #4
0
        public IList <TrussInfo> CreateTrussesFromRoof(FootPrintRoof currentRoof, TrussType tType)
        {
            IList <EdgeInfo>  currentRoofEdgeInfoList = new List <EdgeInfo>();
            IList <TrussInfo> currentRoofTrussList    = new List <TrussInfo>();

            if (currentRoof == null)
            {
                return(currentRoofTrussList);
            }

            currentRoofEdgeInfoList = Support.GetRoofEdgeInfoList(currentRoof, false);

            Document doc = currentRoof.Document;

            if (doc == null)
            {
                return(currentRoofTrussList);
            }

            if (currentRoofEdgeInfoList.Count == 0)
            {
                return(currentRoofTrussList);
            }

            using (Transaction t = new Transaction(doc, "Create Roof Trusses"))
            {
                t.Start();
                foreach (EdgeInfo currentEdgeInfo in currentRoofEdgeInfoList)
                {
                    currentRoofTrussList = currentRoofTrussList.Union(CreateTrussInfoList(currentEdgeInfo, doc, tType)).ToList();
                }
                t.Commit();
            }

            return(currentRoofTrussList);
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
0
        private void Stream(ArrayList data, TrussType trussType)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(TrussType)));

             // Nothing at this level yet!
        }
Пример #8
0
        Stream(ArrayList data, ElementType sym)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(ElementType)));

            // no data at this level yet

            AnnotationSymbolType annoType = sym as AnnotationSymbolType;

            if (annoType != null)
            {
                Stream(data, annoType);
                return;
            }

            AreaReinforcementType areaReinforcementType = sym as AreaReinforcementType;

            if (areaReinforcementType != null)
            {
                Stream(data, areaReinforcementType);
                return;
            }

            AreaTagType areaTagType = sym as AreaTagType;

            if (areaTagType != null)
            {
                Stream(data, areaTagType);
                return;
            }

            BeamSystemType beamSystemType = sym as BeamSystemType;

            if (beamSystemType != null)
            {
                Stream(data, beamSystemType);
                return;
            }

            DimensionType dimType = sym as DimensionType;

            if (dimType != null)
            {
                Stream(data, dimType);
                return;
            }

            //TF
            FabricSheetType fabricST = sym as FabricSheetType;

            if (fabricST != null)
            {
                Stream(data, fabricST);
                return;
            }

            FabricWireType fabricWT = sym as FabricWireType;

            if (fabricWT != null)
            {
                Stream(data, fabricWT);
                return;
            }
            //TFEND

            GroupType groupType = sym as GroupType;

            if (groupType != null)
            {
                Stream(data, groupType);
                return;
            }

            HostObjAttributes hostAtt = sym as HostObjAttributes;

            if (hostAtt != null)
            {
                Stream(data, hostAtt);
                return;
            }

            InsertableObject insObj = sym as InsertableObject;

            if (insObj != null)
            {
                Stream(data, insObj);
                return;
            }

            LevelType levelType = sym as LevelType;

            if (levelType != null)
            {
                Stream(data, levelType);
                return;
            }

            LineAndTextAttrSymbol lineAndTextAttr = sym as LineAndTextAttrSymbol;

            if (lineAndTextAttr != null)
            {
                Stream(data, lineAndTextAttr);
                return;
            }

            LoadTypeBase loadTypeBase = sym as LoadTypeBase;

            if (loadTypeBase != null)
            {
                Stream(data, loadTypeBase);
                return;
            }

            MEPBuildingConstruction mepBldConst = sym as MEPBuildingConstruction;

            if (mepBldConst != null)
            {
                Stream(data, mepBldConst);
                return;
            }

            PathReinforcementType pathReinforcementType = sym as PathReinforcementType;

            if (pathReinforcementType != null)
            {
                Stream(data, pathReinforcementType);
                return;
            }

            RebarBarType rebarBarType = sym as RebarBarType;

            if (rebarBarType != null)
            {
                Stream(data, rebarBarType);
                return;
            }

            RebarCoverType rebarCoverType = sym as RebarCoverType;

            if (rebarCoverType != null)
            {
                Stream(data, rebarCoverType);
                return;
            }

            RebarHookType rebarHookType = sym as RebarHookType;

            if (rebarHookType != null)
            {
                Stream(data, rebarHookType);
                return;
            }

            RebarShape rebarShape = sym as RebarShape;

            if (rebarShape != null)
            {
                Stream(data, rebarShape);
                return;
            }

            RoomTagType roomTagType = sym as RoomTagType;

            if (roomTagType != null)
            {
                Stream(data, roomTagType);
                return;
            }

            SpaceTagType spaceTagType = sym as SpaceTagType;

            if (spaceTagType != null)
            {
                Stream(data, spaceTagType);
                return;
            }

            TrussType trussType = sym as TrussType;

            if (trussType != null)
            {
                Stream(data, trussType);
                return;
            }

            DistributionSysType distSysType = sym as DistributionSysType;

            if (distSysType != null)
            {
                Stream(data, distSysType);
                return;
            }

            MEPCurveType mepCurType = sym as MEPCurveType;

            if (mepCurType != null)
            {
                Stream(data, mepCurType);
                return;
            }

            FluidType fluidType = sym as FluidType;

            if (fluidType != null)
            {
                Stream(data, fluidType);
                return;
            }

            PipeScheduleType pipeSchedType = sym as PipeScheduleType;

            if (pipeSchedType != null)
            {
                Stream(data, pipeSchedType);
                return;
            }

            VoltageType voltType = sym as VoltageType;

            if (voltType != null)
            {
                Stream(data, voltType);
                return;
            }

            WireType wireType = sym as WireType;

            if (wireType != null)
            {
                Stream(data, wireType);
                return;
            }

            ModelTextType modelTxtType = sym as ModelTextType;

            if (modelTxtType != null)
            {
                Stream(data, modelTxtType);
                return;
            }
        }
Пример #9
0
        Stream(ArrayList data, TrussType trussType)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(TrussType)));

            // Nothing at this level yet!
        }
Пример #10
0
 /// <summary>
 /// get selected truss type, this data will be used in truss creation
 /// </summary>
 /// <param name="sender">object who sent this event</param>
 /// <param name="e">event args</param>
 private void TrussTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     m_selectedTrussType = (TrussType)m_trussTypes[this.TrussTypeComboBox.SelectedIndex];
 }
Пример #11
0
 /// <summary>
 /// get selected truss type, this data will be used in truss creation
 /// </summary>
 /// <param name="sender">object who sent this event</param>
 /// <param name="e">event args</param>
 private void TrussTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     m_selectedTrussType = (TrussType)m_trussTypes[this.TrussTypeComboBox.SelectedIndex];
 }
Пример #12
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;
            Selection  sel   = uidoc.Selection;

            try
            {
                Element tTypeElement = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(fsy => fsy is TrussType).ToList().FirstOrDefault();
                if (tTypeElement == null)
                {
                    message = "Nenhum tipo de treliça foi encontrada no projeto, por favor, carregue um tipo e rode este comando novamente";
                    return(Result.Failed);
                }
                TrussType tType = tTypeElement as TrussType;

                ISelectionFilter ridgeSelectionFilter = new RoofClasses.SelectionFilters.StraightLinesAndFacesRidgeSelectionFilter(doc);
                Reference        currentReference     = sel.PickObject(ObjectType.Edge, ridgeSelectionFilter);

                FootPrintRoof        currentFootPrintRoof = doc.GetElement(currentReference) as FootPrintRoof;
                RoofClasses.EdgeInfo currentRidgeInfo     = Support.GetMostSimilarEdgeInfo(currentReference, doc);

                if (currentRidgeInfo == null)
                {
                    message = "Nenhuma linha inferior pode ser obtida a partir da seleção";
                    return(Result.Failed);
                }

                //                #region DEBUG ONLY
                //#if DEBUG
                //                using (Transaction ta = new Transaction(doc, "Line test"))
                //                {
                //                    ta.Start();

                //                    Frame fr = new Frame(currentRidgeInfo.Curve.Evaluate(0.5, true), XYZ.BasisX, XYZ.BasisY, XYZ.BasisZ);
                //                    SketchPlane skp = SketchPlane.Create(doc, Plane.Create(fr));
                //                    doc.Create.NewModelCurve(currentRidgeInfo.Curve, skp);


                //                    ta.Commit();
                //                }
                //#endif
                //                #endregion

                Line currentRidgeLine = currentRidgeInfo.Curve as Line;

                if (currentRidgeLine == null)
                {
                    message = "Ridge must be a straight line";
                    return(Result.Failed);
                }

                ISelectionFilter currentTrussBaseSupportFilter = new RoofClasses.SelectionFilters.SupportsSelectionFilter(currentRidgeLine.Direction.CrossProduct(XYZ.BasisZ));
                XYZ baseSupportPoint = null;
                try
                {
                    Reference currentTrussBaseRef  = sel.PickObject(ObjectType.Element, currentTrussBaseSupportFilter, "Selecione uma base para a treliça ou (ESC) para ignorar");
                    Element   currentTrussBaseElem = doc.GetElement(currentTrussBaseRef.ElementId);

                    //We can safely convert because the selection filter does not select anything that is not a curve locatated
                    Curve currentElementCurve = (currentTrussBaseElem.Location as LocationCurve).Curve;

                    if (currentRidgeLine != null)
                    {
                        if (currentElementCurve is Line)
                        {
                            Line   currentSupportLine = currentElementCurve as Line;
                            double height             = currentRidgeInfo.GetCurrentRoofHeight();
                            currentRidgeLine   = currentRidgeLine.Flatten(height);
                            currentSupportLine = currentSupportLine.Flatten(height);

                            IntersectionResultArray iResutArr  = new IntersectionResultArray();
                            SetComparisonResult     compResult = currentRidgeLine.Intersect(currentSupportLine, out iResutArr);

                            if (iResutArr.Size == 1)
                            {
                                IntersectionResult iResult = iResutArr.get_Item(0);
                                if (iResult != null)
                                {
                                    baseSupportPoint = currentRidgeInfo.Curve.Project(iResult.XYZPoint).XYZPoint;
                                }
                            }
                        }
                    }
                }
                catch
                {
                }

                if (baseSupportPoint == null)
                {
                    baseSupportPoint = currentRidgeLine.Project(currentReference.GlobalPoint).XYZPoint;
                }


                Managers.TrussRidgeManager currentTrussManager = new Managers.TrussRidgeManager();

                Line currentSupport0ElemLine = null;
                Line currentSupport1ElemLine = null;

                currentTrussBaseSupportFilter = new RoofClasses.SelectionFilters.SupportsSelectionFilter(currentRidgeLine.Direction);

                if (currentRidgeInfo.RoofLineType == RoofClasses.RoofLineType.Ridge)
                {
                    try
                    {
                        Reference currentSupport0Ref       = sel.PickObject(ObjectType.Element, currentTrussBaseSupportFilter, "O primeiro suporte para a treliça");
                        Element   currentSupport0Elem      = doc.GetElement(currentSupport0Ref.ElementId);
                        Curve     currentSupport0ElemCurve = (currentSupport0Elem.Location as LocationCurve).Curve;
                        currentSupport0ElemLine = currentSupport0ElemCurve as Line;

                        Reference currentSupport1Ref       = sel.PickObject(ObjectType.Element, currentTrussBaseSupportFilter, "O segundo suporte para a treliça");
                        Element   currentSupport1Elem      = doc.GetElement(currentSupport1Ref.ElementId);
                        Curve     currentSupport1ElemCurve = (currentSupport1Elem.Location as LocationCurve).Curve;
                        currentSupport1ElemLine = currentSupport1ElemCurve as Line;
                    }
                    catch
                    {
                        currentSupport0ElemLine = null;
                        currentSupport1ElemLine = null;
                    }
                }
                else if (currentRidgeInfo.RoofLineType == RoofClasses.RoofLineType.RidgeSinglePanel)
                {
                    try
                    {
                        Reference currentSupport0Ref       = sel.PickObject(ObjectType.Element, currentTrussBaseSupportFilter, "O suporte para a treliça");
                        Element   currentSupport0Elem      = doc.GetElement(currentSupport0Ref.ElementId);
                        Curve     currentSupport0ElemCurve = (currentSupport0Elem.Location as LocationCurve).Curve;
                        currentSupport0ElemLine = currentSupport0ElemCurve as Line;
                    }
                    catch
                    {
                        currentSupport0ElemLine = null;
                    }
                }

                RoofClasses.TrussInfo currentTrussInfo = currentTrussManager.CreateTrussFromRidgeWithSupports(baseSupportPoint, currentRidgeInfo, tType, currentSupport0ElemLine, currentSupport1ElemLine);

                //#region DEBUG ONLY

                //if (currentReference != null)
                //    DEBUG.CreateDebugPoint(doc, baseSupportPoint);

                //#endregion
            }
            catch (Exception e)
            {
                if (!(e is Autodesk.Revit.Exceptions.OperationCanceledException))
                {
                    throw e;
                }
            }

            return(Result.Succeeded);
        }
Пример #13
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;
            Selection  sel   = uidoc.Selection;

            ISelectionFilter hipSelFilter  = new RoofClasses.SelectionFilters.StraightLinesAndFacesHipSelectionFilter(doc);
            Reference        currentHipRef = sel.PickObject(ObjectType.Edge, hipSelFilter, "Selecione um rincão para posicionar as treliças");

            RoofClasses.EdgeInfo currentEdgeInfo = Support.GetMostSimilarEdgeInfo(currentHipRef, doc);

            //if (currentHipRef.GlobalPoint != null)
            //    DEBUG.CreateDebugPoint(doc, currentHipRef.GlobalPoint);

            //DEBUG.CreateDebugPoint(doc, currentEdgeInfo.Curve.Evaluate(0.5, true));

            if (currentEdgeInfo == null)
            {
                message = "Nenhuma linha inferior pode ser obtida a partir da seleção";
                return(Result.Failed);
            }

            if (currentEdgeInfo.Curve as Line == null)
            {
                message = "Rincão deve ser uma linha reta";
                return(Result.Failed);
            }

            Line             currentHipLine      = currentEdgeInfo.Curve as Line;
            ISelectionFilter firstSupportFilter  = new RoofClasses.SelectionFilters.SupportsSelectionFilter(currentHipLine.Flatten().Direction.Rotate(45));
            ISelectionFilter secondSupportFilter = new RoofClasses.SelectionFilters.SupportsSelectionFilter(currentHipLine.Flatten().Direction.Rotate(-45));
            Element          firstSupport        = null;
            Element          secondSupport       = null;

            try
            {
                Reference firstSupportRef  = sel.PickObject(ObjectType.Element, firstSupportFilter);
                Reference SecondSupportRef = sel.PickObject(ObjectType.Element, secondSupportFilter);

                firstSupport  = doc.GetElement(firstSupportRef);
                secondSupport = doc.GetElement(SecondSupportRef);
            }
            catch
            {
            }

            if (firstSupport == null || secondSupport == null)
            {
                message = "Nenhum suporte foi selecionado";
                return(Result.Failed);
            }

            Element tTypeElement = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(fsy => fsy is TrussType).ToList().FirstOrDefault();

            if (tTypeElement == null)
            {
                message = "Nenhum tipo de treliça foi encontrada no projeto, por favor, carregue um tipo e rode este comando novamente";
                return(Result.Failed);
            }
            TrussType tType = tTypeElement as TrussType;

            Managers.TrussHipManager trussHipManager = new Managers.TrussHipManager();
            trussHipManager.CreateTrussInfo(doc, currentHipLine.Evaluate(0.5, true), currentEdgeInfo, firstSupport, secondSupport, tType);

            return(Result.Succeeded);
        }
Пример #14
0
        public static List <Member> CreateTruss(List <Member> top, List <Member> bottom, TrussType trussType, int extraMembers)
        {
            if (top.Count < extraMembers * 2)
            {
                extraMembers = 0;
            }

            if (trussType == TrussType.Pratt)
            {
                return(pratt(top, bottom, extraMembers));
            }
            else if (trussType == TrussType.Warren)
            {
                return(warren(top, bottom, extraMembers));
            }
            else if (trussType == TrussType.Howe)
            {
                return(howe(top, bottom, extraMembers));
            }
            else if (trussType == TrussType.KTruss)
            {
                return(kTruss(top, bottom, extraMembers));
            }
            else
            {
                return(new List <Member>());
                //throw new NotImplementedException();
            }
        }
Пример #15
0
        public static List <Line> AllVerts(List <Point3d> TCPts, List <Point3d> BCPts, TrussType trussType)
        {
            List <Line> VertMems = new List <Line>();

            if (trussType == TrussType.Howe ||
                trussType == TrussType.Pratt ||
                trussType == TrussType.WarrenFlippedwVerts ||
                trussType == TrussType.WarrenwVerts ||
                trussType == TrussType.Xtruss ||
                trussType == TrussType.Ktruss ||
                trussType == TrussType.KtrussFlipped)
            {
                for (int i = 0; i <= TCPts.Count - 1; i++)
                {
                    Line Vert = new Line(BCPts[i], TCPts[i]);
                    VertMems.Add(Vert);
                }
            }

            else if (trussType == TrussType.Warren ||
                     trussType == TrussType.WarrenFlipped)
            {
                for (int i = 0; i <= TCPts.Count - 1; i++)
                {
                    if (i == 0 || i == TCPts.Count - 1)
                    {
                        Line Vert = new Line(BCPts[i], TCPts[i]);
                        VertMems.Add(Vert);
                    }
                }
            }
            return(VertMems);
        }
Пример #16
0
        public IList <TrussInfo> CreateTrussesFromRidgeInfo(EdgeInfo currentRidgeEdgeInfo, TrussType tType)
        {
            IList <TrussInfo> trussInfoList = new List <TrussInfo>();

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

            FootPrintRoof currentRoof = currentRidgeEdgeInfo.CurrentRoof;

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

            Document doc = currentRidgeEdgeInfo.CurrentRoof.Document;

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

            IList <EdgeInfo> currentRoofEdgeInfoList = new List <EdgeInfo>();

            using (Transaction t = new Transaction(doc, "Create Ridge Trusses"))
            {
                t.Start();
                trussInfoList = CreateTrussInfoList(currentRidgeEdgeInfo, doc, tType);
                t.Commit();
            }

            return(trussInfoList);
        }
Пример #17
0
        public TrussInfo CreateTrussFromRidgeWithSupports(XYZ currentPointOnRidge, EdgeInfo currentRidgeEdgeInfo, TrussType tType, Line support0, Line support1)
        {
            TrussInfo currentTrussInfo = null;

            Document doc = currentRidgeEdgeInfo.CurrentRoof.Document;

            if (doc == null)
            {
                return(currentTrussInfo);
            }

            IList <XYZ> currentSupportPoints = new List <XYZ>();
            double      roofheight           = currentRidgeEdgeInfo.GetCurrentRoofHeight();

            Line currentRidgeLineFlatten = (currentRidgeEdgeInfo.Curve as Line).Flatten(roofheight);

            if (currentRidgeLineFlatten == null)
            {
                return(currentTrussInfo);
            }

            XYZ crossDirection             = currentRidgeLineFlatten.Direction.CrossProduct(XYZ.BasisZ);
            XYZ currentPointOnRidgeFlatten = new XYZ(currentPointOnRidge.X, currentPointOnRidge.Y, roofheight);

            Line currentCrossedLineInfinite = Line.CreateBound(currentPointOnRidgeFlatten, currentPointOnRidgeFlatten.Add(crossDirection));

            currentCrossedLineInfinite.MakeUnbound();

            if (support0 != null)
            {
                IntersectionResultArray iResultArr = new IntersectionResultArray();
                SetComparisonResult     iResulComp = currentCrossedLineInfinite.Intersect(support0.Flatten(roofheight), out iResultArr);
                if (iResultArr != null && iResultArr.Size == 1)
                {
                    currentSupportPoints.Add(iResultArr.get_Item(0).XYZPoint);
                }
            }
            if (support1 != null)
            {
                IntersectionResultArray iResultArr = new IntersectionResultArray();
                SetComparisonResult     iResulComp = currentCrossedLineInfinite.Intersect(support1.Flatten(roofheight), out iResultArr);
                if (iResultArr != null && iResultArr.Size == 1)
                {
                    currentSupportPoints.Add(iResultArr.get_Item(0).XYZPoint);
                }
            }

            using (Transaction t = new Transaction(doc, "Criar treliça"))
            {
                t.Start();
                currentTrussInfo = CreateTrussInfo(doc, currentPointOnRidge, currentRidgeEdgeInfo, currentSupportPoints, tType);
                t.Commit();
            }

            return(currentTrussInfo);
        }
Пример #18
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);
        }