コード例 #1
0
        public bool FindFamilySymbol()
        {
            // Categories names
            string strBeamCat  = ThisExtension.Revit.ActiveDocument.Settings.Categories.get_Item(Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFraming).Name;
            string strColCat   = ThisExtension.Revit.ActiveDocument.Settings.Categories.get_Item(Autodesk.Revit.DB.BuiltInCategory.OST_StructuralColumns).Name;
            string strFootCat  = ThisExtension.Revit.ActiveDocument.Settings.Categories.get_Item(Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFoundation).Name;
            bool   mboolBeam   = false;
            bool   mboolColumn = false;
            bool   mboolFoot   = false;

            FilteredElementIterator fei = new FilteredElementCollector(ThisExtension.Revit.ActiveUIDocument.Document).OfClass(typeof(Family)).GetElementIterator();

            while (fei.MoveNext())
            {
                Family f = fei.Current as Family;
                if (f != null)
                {
                    foreach (ElementId symbolId in f.GetFamilySymbolIds())
                    {
                        Element elem = ThisExtension.Revit.ActiveUIDocument.Document.GetElement(symbolId);
                        if (null == elem)
                        {
                            continue;
                        }
                        FamilySymbol familyType = elem as FamilySymbol;
                        if (null == familyType)
                        {
                            continue;
                        }
                        if (null == familyType.Category)
                        {
                            continue;
                        }
                        if (strBeamCat == familyType.Category.Name)
                        {
                            Beams.Add(familyType);
                            mboolBeam = true;
                        }
                        else if (strColCat == familyType.Category.Name)
                        {
                            Columns.Add(familyType);
                            mboolColumn = true;
                        }
                        if (strFootCat == familyType.Category.Name)
                        {
                            Footings.Add(familyType);
                            mboolFoot = true;
                        }
                    }
                }
            }
            if (mboolBeam && mboolColumn && mboolFoot)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
 /// <summary>
 /// The system has been justified horizontally, so all objects are at their final horizontal positions.
 /// This function
 ///  1. creates all the contained beams horizontally with their top edges at 0F.
 ///  2. expands the beams vertically, and moves them to the closest position on the correct side of their noteheads.
 ///  3. shears the beams.
 ///  4. moves the stem tips and related objects (dynamics, ornament numbers) to their correct positions wrt the outer beam.
 /// Especially note that neither this beam Block or its contained beams ever move _horizontally_.
 /// </summary>
 public void FinalizeBeamBlock()
 {
     #region create the individual beams all with top edge horizontal at 0F.
     HashSet <DurationClass> durationClasses = new HashSet <DurationClass>()
     {
         DurationClass.fiveFlags,
         DurationClass.fourFlags,
         DurationClass.threeFlags,
         DurationClass.semiquaver,
         DurationClass.quaver
     };
     float stubWidth = _gap * 1.2F;
     foreach (DurationClass durationClass in durationClasses)
     {
         List <Beam> beams = CreateBeams(durationClass, stubWidth);
         _left  = float.MaxValue;
         _right = float.MinValue;
         foreach (Beam beam in beams)
         {
             _left  = _left < beam.LeftX ? _left : beam.LeftX;
             _right = _right > beam.RightX ? _right : beam.RightX;
             Beams.Add(beam);
         }
         _originX = _left;
         // _left, _right and _originX never change again after they have been set here
     }
     SetVerticalBounds();
     #endregion
     Dictionary <DurationClass, float> durationClassBeamThickness = GetBeamThicknessesPerDurationClass(durationClasses);
     List <ChordMetrics> chordsMetrics = GetChordsMetrics();
     ExpandVerticallyAtNoteheads(chordsMetrics, durationClassBeamThickness);
     Shear(chordsMetrics);
     SetToStaff(durationClassBeamThickness);
     MoveStemTips();
 }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="NewBeamGroup"></param>
        /// <returns></returns>
        private List <List <LINE> > ConnectedEdgeFromMiddleColumns(List <List <LINE> > NewBeamGroup)
        {
            List <List <LINE> > newFloorGroup = new List <List <LINE> >();

            foreach (List <LINE> Beams in NewBeamGroup)
            {
                //SaveTmp(Beams);
                Dictionary <int, LINE> tmpAddLines = new Dictionary <int, LINE>();
                for (int i = 0; i < Beams.Count; i++)
                {
                    LINE L1 = Beams[i];
                    LINE L2 = i + 1 == Beams.Count ? Beams[0] : Beams[i + 1];
                    if (L1.IsSameDirection(L2.GetDirection(), true) && !L1.IsPointInLine(L2.GetStartPoint()))
                    {
                        tmpAddLines[i] = new LINE(L1.GetEndPoint(), L2.GetStartPoint());
                    }
                }

                foreach (int ii in tmpAddLines.Keys)
                {
                    Beams.Add(tmpAddLines[ii]);
                }
                SaveTmp(Beams);
                int         kk       = 0;
                List <LINE> newBeams = new List <LINE>();
                int[]       flag     = new int[Beams.Count];
                flag[kk] = -1;
                newBeams.Add(Beams[0]);
                while (kk < Beams.Count)
                {
                    if (flag[kk] != -1 && newBeams[newBeams.Count - 1].IsPointInLine(Beams[kk].GetStartPoint()))
                    {
                        flag[kk] = -1;
                        newBeams.Add(Beams[kk]);
                        kk = 0;
                    }
                    kk = kk + 1;
                }

                newFloorGroup.Add(newBeams);
                //SaveTmp(newBeams);
            }

            return(newFloorGroup);
        }
コード例 #4
0
 public void AddBeam(Beam beam)
 {
     Beams.Add(beam);
 }