Example #1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_BeamElement beami = null;
            Curve          c     = null;
            double         err   = 0.001;

            bool boolL      = DA.GetData(0, ref beami);
            bool boolC      = DA.GetData <Curve>(1, ref c);
            bool boolClosed = c.IsClosed;

            DA.GetData(2, ref err);
            if (boolL && boolC && boolClosed)
            {
                List <Point3d> pts = new List <Point3d>();
                pts.Add(beami.Value.Line.PointAt(0));
                pts.Add(beami.Value.Line.PointAt(1));
                BoundingBox bx         = c.GetBoundingBox(false);
                Plane       curvePlane = Plane.WorldXY;
                c.TryGetPlane(out curvePlane, bx.Min.DistanceTo(bx.Max));
                List <Point3d> planePts = new List <Point3d>();
                for (int j = 0; j < 2; j++)
                {
                    planePts.Add(curvePlane.ClosestPoint(pts[j]));//获得杆件在平面内的投影节点
                }

                if (c.Contains(planePts[0], curvePlane, err) == PointContainment.Inside && c.Contains(planePts[1], curvePlane, err) == PointContainment.Inside)//起点和终点都在曲线内
                {
                    DA.SetData(0, beami);
                }
            }
            else
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "用于建立选区的curve必须是封闭曲线");
            }
        }
Example #2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            int            loadcase   = 1;
            GH_BeamElement Beams      = null;
            int            coordinate = 1;
            int            direction  = 3;
            double         value      = double.NaN;

            bool bool_case  = DA.GetData(0, ref loadcase);
            bool bool_beams = DA.GetData(1, ref Beams);
            bool bool_coord = DA.GetData <int>(2, ref coordinate);
            bool bool_dir   = DA.GetData <int>(3, ref direction);
            bool bool_value = DA.GetData <double>(4, ref value);

            if (bool_beams && bool_value)
            {
                BeamLoadCls beamloadi = new BeamLoadCls(loadcase, Beams.Value.Line, coordinate, direction, value);
                DA.SetData(0, new GH_BeamLoadCls(beamloadi));
            }
        }