protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            // get input
            DB.CurtainGridLine gridLine = default;
            if (!DA.GetData("Curtain Grid Line", ref gridLine))
            {
                return;
            }


            DA.SetData("Curve", gridLine.FullCurve.ToCurve());
            DA.SetDataList("Segments", gridLine.AllSegmentCurves.ToCurves());
            DA.SetDataList("Existing Segments", gridLine.ExistingSegmentCurves.ToCurves());
            DA.SetDataList("Skipped Segments", gridLine.SkippedSegmentCurves.ToCurves());

            // find attached mullions
            const double EPSILON          = 0.1;
            var          attachedMullions = new List <Types.Element>();
            var          famInstFilter    = new DB.ElementClassFilter(typeof(DB.FamilyInstance));
            // collect familyinstances and filter for DB.Mullion
            var dependentMullions = gridLine.GetDependentElements(famInstFilter).Select(x => gridLine.Document.GetElement(x)).OfType <DB.Mullion>();

            // for each DB.Mullion that is dependent on this DB.CurtainGridLine
            foreach (DB.Mullion mullion in dependentMullions)
            {
                if (mullion.LocationCurve != null)
                {
                    // check the distance of the DB.Mullion curve start and end, to the DB.CurtainGridLine axis curve
                    var mcurve = mullion.LocationCurve;
                    var mstart = mcurve.GetEndPoint(0);
                    var mend   = mcurve.GetEndPoint(1);
                    // if the distance is less than EPSILON, the DB.Mullion axis and DB.CurtainGridLine axis are almost overlapping
                    if (gridLine.FullCurve.Distance(mstart) < EPSILON && gridLine.FullCurve.Distance(mend) < EPSILON)
                    {
                        attachedMullions.Add(Types.CurtainGridMullion.FromElement(mullion));
                    }
                }
            }
            DA.SetDataList("Attached Mullions", attachedMullions);

            // filter attached panels
            // panels can be a mix of DB.Panel and DB.FamilyInstance
            // no need to filter for .OfType<DB.Panel>() like with DB.Mullion
            // but make sure to remove all the DB.FamilyInstance that are actually DB.Mullion
            var dependentPanels = gridLine.GetDependentElements(famInstFilter).Select(x => gridLine.Document.GetElement(x)).Where(x => x as DB.Mullion is null);

            DA.SetDataList("Attached Panels", dependentPanels.Select(x => Types.Element.FromElement(x)));
        }
 public bool CanConvertToSpeckle(object @object)
 {
     return(@object
            switch
     {
         DB.DetailCurve _ => true,
         DB.DirectShape _ => true,
         DB.FamilyInstance _ => true,
         DB.Floor _ => true,
         DB.Level _ => true,
         DB.View _ => true,
         DB.ModelCurve _ => true,
         DB.Opening _ => true,
         DB.RoofBase _ => true,
         DB.Area _ => true,
         DB.Architecture.Room _ => true,
         DB.Architecture.TopographySurface _ => true,
         DB.Wall _ => true,
         DB.Mechanical.Duct _ => true,
         DB.Mechanical.Space _ => true,
         DB.Plumbing.Pipe _ => true,
         DB.Electrical.Wire _ => true,
         DB.CurtainGridLine _ => true, //these should be handled by curtain walls
         DB.Architecture.BuildingPad _ => true,
         DB.Architecture.Stairs _ => true,
         DB.Architecture.StairsRun _ => true,
         DB.Architecture.StairsLanding _ => true,
         DB.Architecture.Railing _ => true,
         DB.Architecture.TopRail _ => true,
         DB.Ceiling _ => true,
         DB.PointCloudInstance _ => true,
         DB.Group _ => true,
         DB.ProjectInfo _ => true,
         DB.ElementType _ => true,
         DB.Grid _ => true,
         DB.ReferencePoint _ => true,
         DB.Structure.AnalyticalModelStick _ => true,
         DB.Structure.AnalyticalModelSurface _ => true,
         DB.Structure.BoundaryConditions _ => true,
         _ => (@object as Element).IsElementSupported()
     });
Esempio n. 3
0
 public CurtainGridLine(DB.CurtainGridLine gridLine) : base(gridLine)
 {
 }
Esempio n. 4
0
 public static Elements.ModelCurve CurtainGridToHyparCurve(Autodesk.Revit.DB.CurtainGridLine gridLine)
 {
     Elements.Geometry.Curve curve = new Line(gridLine.FullCurve.GetEndPoint(0).ToVector3(), gridLine.FullCurve.GetEndPoint(1).ToVector3());
     return(new Elements.ModelCurve(curve, BuiltInMaterials.Edges));
 }