示例#1
0
        private void AddConnectedMember(AttachedMember attachedMember, ConnectionPoint connectionPoint)
        {
            PolyLine3D polyLine3D = new PolyLine3D();

            polyLine3D.Id = openModel.GetMaxId(polyLine3D) + 1;
            openModel.AddObject(polyLine3D);

            //endpoints
            Point3D pA = openModel.Point3D.First(a => a.Id == attachedMember.ideaLine.Start.id);
            Point3D pB = openModel.Point3D.First(a => a.Id == attachedMember.ideaLine.End.id);

            //create line segment
            LineSegment3D lineSegment = new LineSegment3D();

            lineSegment.Id         = openModel.GetMaxId(lineSegment) + 1;
            lineSegment.StartPoint = new ReferenceElement(pA);
            lineSegment.EndPoint   = new ReferenceElement(pB);
            openModel.AddObject(lineSegment);
            polyLine3D.Segments.Add(new ReferenceElement(lineSegment));

            ///*
            double xcor = attachedMember.ElementRAZ.line.vector.X;
            double ycor = attachedMember.ElementRAZ.line.vector.Y;
            double zcor = attachedMember.ElementRAZ.line.vector.Z;

            //Define LCS (local-y in XY plane) and unitize
            VectorRAZ vx = new VectorRAZ(xcor, ycor, zcor).Unitize();
            VectorRAZ vy = new VectorRAZ();
            VectorRAZ vz = new VectorRAZ();

            if (xcor == 0.0 && ycor == 0.0)
            {
                vy = new VectorRAZ(0.0, 1.0, 0.0).Unitize();
                vz = new VectorRAZ((-zcor), 0.0, (xcor)).Unitize();
            }
            else
            {
                vy = new VectorRAZ(-ycor, xcor, 0.0).Unitize();
                vz = new VectorRAZ((-zcor * xcor), (-zcor * ycor), ((xcor * xcor) + (ycor * ycor))).Unitize();
            }



            var LocalCoordinateSystem = new CoordSystemByVector();

            LocalCoordinateSystem.VecX = new Vector3D()
            {
                X = vx.X, Y = vx.Y, Z = vx.Z
            };
            LocalCoordinateSystem.VecY = new Vector3D()
            {
                X = vy.X, Y = vy.Y, Z = vy.Z
            };
            LocalCoordinateSystem.VecZ = new Vector3D()
            {
                X = vz.X, Y = vz.Y, Z = vz.Z
            };

            lineSegment.LocalCoordinateSystem = LocalCoordinateSystem;
            //*/

            //create element
            Element1D element1D = new Element1D();

            //element1D.Id = openModel.GetMaxId(element1D) + 1;

            element1D.Id = attachedMember.ElementRAZ.id + 1; //Use of Id from Grasshopper Model + Plus One

            element1D.Name    = "Element " + element1D.Id.ToString();
            element1D.Segment = new ReferenceElement(lineSegment);

            IdeaRS.OpenModel.CrossSection.CrossSection crossSection = openModel.CrossSection.First(a => a.Id == attachedMember.ElementRAZ.crossSection.id);
            element1D.CrossSectionBegin = new ReferenceElement(crossSection);
            element1D.CrossSectionEnd   = new ReferenceElement(crossSection);

            if (attachedMember is ConnectingMember)
            {
                ConnectingMember connectingMember = attachedMember as ConnectingMember;
                double           eccentricty      = new double();
                if (connectingMember.localEccentricity == -0)
                {
                    eccentricty = 0;
                }
                else
                {
                    eccentricty = connectingMember.localEccentricity;
                }
                element1D.EccentricityBeginZ = eccentricty;
                element1D.EccentricityEndZ   = eccentricty;
            }

            openModel.AddObject(element1D);

            //create member
            Member1D member1D = new Member1D();

            member1D.Id   = openModel.GetMaxId(member1D) + 1;
            member1D.Name = "Member " + member1D.Id.ToString();
            member1D.Elements1D.Add(new ReferenceElement(element1D));
            openModel.Member1D.Add(member1D);

            //create connected member
            ConnectedMember connectedMember = new ConnectedMember();

            connectedMember.Id       = member1D.Id;
            connectedMember.MemberId = new ReferenceElement(member1D);
            connectionPoint.ConnectedMembers.Add(connectedMember);
        }
        private void AddConnectedMember(AttachedMember attachedMember, ConnectionPoint connectionPoint)
        {
            PolyLine3D polyLine3D = new PolyLine3D();

            polyLine3D.Id = openModel.GetMaxId(polyLine3D) + 1;
            openModel.AddObject(polyLine3D);

            //endpoints
            Point3D pA = openModel.Point3D.First(a => a.Id == attachedMember.ideaLine.Start.id);
            Point3D pB = openModel.Point3D.First(a => a.Id == attachedMember.ideaLine.End.id);

            //create line segment
            LineSegment3D lineSegment = new LineSegment3D();

            lineSegment.Id         = openModel.GetMaxId(lineSegment) + 1;
            lineSegment.StartPoint = new ReferenceElement(pA);
            lineSegment.EndPoint   = new ReferenceElement(pB);
            openModel.AddObject(lineSegment);
            polyLine3D.Segments.Add(new ReferenceElement(lineSegment));

            SetLCS(attachedMember, lineSegment);


            //create element
            Element1D element1D = new Element1D();

            //element1D.Id = openModel.GetMaxId(element1D) + 1;

            element1D.Id = attachedMember.ElementRAZ.id + 1; //Use of Id from Grasshopper Model + Plus One

            element1D.Name    = "Element " + element1D.Id.ToString();
            element1D.Segment = new ReferenceElement(lineSegment);

            IdeaRS.OpenModel.CrossSection.CrossSection crossSection = openModel.CrossSection.First(a => a.Id == attachedMember.ElementRAZ.crossSection.id);
            element1D.CrossSectionBegin = new ReferenceElement(crossSection);
            element1D.CrossSectionEnd   = new ReferenceElement(crossSection);
            //element1D.RotationRx = attachedMember.ElementRAZ.rotationLCS;

            if (attachedMember is ConnectingMember)
            {
                ConnectingMember connectingMember = attachedMember as ConnectingMember;
                double           eccentricty      = new double();
                if (connectingMember.localEccentricity == -0)
                {
                    eccentricty = 0;
                }
                else
                {
                    eccentricty = connectingMember.localEccentricity;
                }
                element1D.EccentricityBeginZ = eccentricty;
                element1D.EccentricityEndZ   = eccentricty;
            }

            openModel.AddObject(element1D);

            //create member
            Member1D member1D = new Member1D();

            member1D.Id   = openModel.GetMaxId(member1D) + 1;
            member1D.Name = "Member " + member1D.Id.ToString();
            member1D.Elements1D.Add(new ReferenceElement(element1D));
            openModel.Member1D.Add(member1D);

            //create connected member
            ConnectedMember connectedMember = new ConnectedMember();

            connectedMember.Id       = member1D.Id;
            connectedMember.MemberId = new ReferenceElement(member1D);
            connectionPoint.ConnectedMembers.Add(connectedMember);
        }
示例#3
0
        private void AddConnectedMember(List <BearingMember> bearingMembers, ConnectionPoint connectionPoint)
        {
            PolyLine3D polyLine3D = new PolyLine3D();

            polyLine3D.Id = openModel.GetMaxId(polyLine3D) + 1;
            openModel.AddObject(polyLine3D);

            Point3D pA = new Point3D();
            Point3D pB = new Point3D();
            Point3D pC = new Point3D();
            Point3D pD = new Point3D();

            //view from point [B], point [B] is centerpoint of connection
            if (bearingMembers[0].isStartPoint == false)
            {
                if (bearingMembers[1].isStartPoint == true)
                {
                    // [A]=0=>[B]=1=>[C]
                    pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id);
                    pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id);
                    pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id);
                    pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id);
                }
                else
                {
                    // [A]=0=>[B]<=1=[C]
                    pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id);
                    pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id);
                    pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id);
                    pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id);
                }
            }
            else
            {
                if (bearingMembers[1].isStartPoint == true)
                {
                    // [A]<=0=[B]=1=>[C]
                    pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id);
                    pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id);
                    pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id);
                    pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id);
                }
                else
                {
                    // [A]<=0=[B]<=1=[C]
                    pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id);
                    pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id);
                    pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id);
                    pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id);

                    /*
                     * pA = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id);
                     * pB = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id);
                     * pC = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id);
                     * pD = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id);
                     */
                }
            }


            //segments

            /*
             * Point3D pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ideaLine.Start.id);
             * Point3D pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ideaLine.End.id);
             * Point3D pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ideaLine.Start.id);
             * Point3D pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ideaLine.End.id);
             */

            List <Point3D> points = new List <Point3D>()
            {
                pA, pB, pC, pD
            };
            //Point3D pointB = points.Where(a => a.Id == connectionPoint.Id).First();
            //Point3D pointA = points.Where(a => a.Id != connectionPoint.Id).ToList()[0];//logica
            //Point3D pointC = points.Where(a => a.Id != connectionPoint.Id).ToList()[1];

            //Note: not most robust solution, e.g. does not hold in case of segments with inverse vectors
            Point3D pointA = pA; //Endpoint of first member
            Point3D pointB = pB; //Startpoint of first member
            Point3D pointC = pD; //Endpoint of second member


            LineSegment3D lineSegment1 = new LineSegment3D();

            lineSegment1.Id = openModel.GetMaxId(lineSegment1) + 1;
            openModel.AddObject(lineSegment1);
            lineSegment1.StartPoint = new ReferenceElement(pointA);
            lineSegment1.EndPoint   = new ReferenceElement(pointB);
            polyLine3D.Segments.Add(new ReferenceElement(lineSegment1));


            ///*
            //Defining LCS for First lineSegment
            double xcor = bearingMembers[0].ElementRAZ.line.vector.X;
            double ycor = bearingMembers[0].ElementRAZ.line.vector.Y;
            double zcor = bearingMembers[0].ElementRAZ.line.vector.Z;

            //Define LCS (local-y in XY plane) and unitize
            VectorRAZ vx = new VectorRAZ(xcor, ycor, zcor).Unitize();
            VectorRAZ vy = new VectorRAZ();
            VectorRAZ vz = new VectorRAZ();

            if (xcor == 0.0 && ycor == 0.0)
            {
                vy = new VectorRAZ(0.0, 1.0, 0.0).Unitize();
                vz = new VectorRAZ((-zcor), 0.0, (xcor)).Unitize();
            }
            else
            {
                vy = new VectorRAZ(-ycor, xcor, 0.0).Unitize();
                vz = new VectorRAZ((-zcor * xcor), (-zcor * ycor), ((xcor * xcor) + (ycor * ycor))).Unitize();
            }



            var LocalCoordinateSystem = new CoordSystemByVector();

            LocalCoordinateSystem.VecX = new Vector3D()
            {
                X = vx.X, Y = vx.Y, Z = vx.Z
            };
            LocalCoordinateSystem.VecY = new Vector3D()
            {
                X = vy.X, Y = vy.Y, Z = vy.Z
            };
            LocalCoordinateSystem.VecZ = new Vector3D()
            {
                X = vz.X, Y = vz.Y, Z = vz.Z
            };

            lineSegment1.LocalCoordinateSystem = LocalCoordinateSystem;

            //*/

            LineSegment3D lineSegment2 = new LineSegment3D();

            lineSegment2.Id = openModel.GetMaxId(lineSegment2) + 1;
            openModel.AddObject(lineSegment2);
            lineSegment2.StartPoint = new ReferenceElement(pointB);
            lineSegment2.EndPoint   = new ReferenceElement(pointC);
            polyLine3D.Segments.Add(new ReferenceElement(lineSegment2));


            ///*
            /////Defining LCS for Second lineSegment
            double xcor2 = bearingMembers[1].ElementRAZ.line.vector.X;
            double ycor2 = bearingMembers[1].ElementRAZ.line.vector.Y;
            double zcor2 = bearingMembers[1].ElementRAZ.line.vector.Z;

            //Define LCS (local-y in XY plane) and unitize
            VectorRAZ vx2 = new VectorRAZ(xcor2, ycor2, zcor2).Unitize();
            VectorRAZ vy2 = new VectorRAZ();
            VectorRAZ vz2 = new VectorRAZ();

            if (xcor2 == 0.0 && ycor2 == 0.0)
            {
                vy2 = new VectorRAZ(0.0, 1.0, 0.0).Unitize();
                vz2 = new VectorRAZ((-zcor2), 0.0, (xcor2)).Unitize();
            }
            else
            {
                vy2 = new VectorRAZ(-ycor2, xcor2, 0.0).Unitize();
                vz2 = new VectorRAZ((-zcor2 * xcor2), (-zcor2 * ycor2), ((xcor2 * xcor2) + (ycor2 * ycor2))).Unitize();
            }



            var LocalCoordinateSystem2 = new CoordSystemByVector();

            LocalCoordinateSystem2.VecX = new Vector3D()
            {
                X = vx2.X, Y = vx2.Y, Z = vx2.Z
            };
            LocalCoordinateSystem2.VecY = new Vector3D()
            {
                X = vy2.X, Y = vy2.Y, Z = vy2.Z
            };
            LocalCoordinateSystem2.VecZ = new Vector3D()
            {
                X = vz2.X, Y = vz2.Y, Z = vz2.Z
            };

            lineSegment2.LocalCoordinateSystem = LocalCoordinateSystem2;
            //*/

            //create elements
            Element1D el1 = new Element1D();

            //el1.Id = openModel.GetMaxId(el1) + 1;

            el1.Id = bearingMembers[0].ElementRAZ.id + 1; //Use of Id from Grasshopper Model + Plus One

            el1.Name    = "E" + el1.Id.ToString();
            el1.Segment = new ReferenceElement(lineSegment1);
            IdeaRS.OpenModel.CrossSection.CrossSection crossSection = openModel.CrossSection.First(a => a.Id == bearingMembers[0].ElementRAZ.crossSection.id);
            el1.CrossSectionBegin = new ReferenceElement(crossSection);
            el1.CrossSectionEnd   = new ReferenceElement(crossSection);
            openModel.AddObject(el1);

            Element1D el2 = new Element1D();

            //el2.Id = openModel.GetMaxId(el2) + 1;

            el2.Id = bearingMembers[1].ElementRAZ.id + 1; //Use of Id from Grasshopper Model + Plus One

            el2.Name              = "E" + el2.Id.ToString();
            el2.Segment           = new ReferenceElement(lineSegment2);
            el2.CrossSectionBegin = new ReferenceElement(crossSection);
            el2.CrossSectionEnd   = new ReferenceElement(crossSection);
            openModel.AddObject(el2);

            //create member
            Member1D member1D = new Member1D();

            member1D.Id   = openModel.GetMaxId(member1D) + 1;
            member1D.Name = "Member" + member1D.Id.ToString();
            member1D.Elements1D.Add(new ReferenceElement(el1));
            member1D.Elements1D.Add(new ReferenceElement(el2));
            openModel.Member1D.Add(member1D);

            //create connected member
            ConnectedMember connectedMember = new ConnectedMember();

            connectedMember.Id       = member1D.Id;
            connectedMember.MemberId = new ReferenceElement(member1D);
            connectionPoint.ConnectedMembers.Add(connectedMember);
        }
        private void AddConnectedMember(List <BearingMember> bearingMembers, ConnectionPoint connectionPoint)
        {
            PolyLine3D polyLine3D = new PolyLine3D();

            polyLine3D.Id = openModel.GetMaxId(polyLine3D) + 1;
            openModel.AddObject(polyLine3D);



            Point3D pA  = new Point3D();
            Point3D pB  = new Point3D();
            Point3D pB2 = new Point3D();
            Point3D pC  = new Point3D();

            pA  = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id);
            pB  = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id);
            pB2 = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id);
            pC  = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id);

            List <Point3D> points = new List <Point3D>()
            {
                pA, pB, pB2, pC
            };

            Point3D pointA = pA; //Endpoint of first member
            Point3D pointB = pB; //Startpoint of first member
            Point3D pointC = pC; //Endpoint of second member


            LineSegment3D lineSegment1 = new LineSegment3D();

            lineSegment1.Id = openModel.GetMaxId(lineSegment1) + 1;
            openModel.AddObject(lineSegment1);
            lineSegment1.StartPoint = new ReferenceElement(pointA);
            lineSegment1.EndPoint   = new ReferenceElement(pointB);
            polyLine3D.Segments.Add(new ReferenceElement(lineSegment1));

            SetLCS(bearingMembers[0], lineSegment1);

            LineSegment3D lineSegment2 = new LineSegment3D();

            lineSegment2.Id = openModel.GetMaxId(lineSegment2) + 1;
            openModel.AddObject(lineSegment2);
            lineSegment2.StartPoint = new ReferenceElement(pointB);
            lineSegment2.EndPoint   = new ReferenceElement(pointC);
            polyLine3D.Segments.Add(new ReferenceElement(lineSegment2));

            SetLCS(bearingMembers[1], lineSegment2);

            //create elements
            Element1D el1 = new Element1D();

            //el1.Id = openModel.GetMaxId(el1) + 1;

            el1.Id = bearingMembers[0].ElementRAZ.id + 1; //Use of Id from Grasshopper Model + Plus One

            el1.Name    = "E" + el1.Id.ToString();
            el1.Segment = new ReferenceElement(lineSegment1);
            IdeaRS.OpenModel.CrossSection.CrossSection crossSection = openModel.CrossSection.First(a => a.Id == bearingMembers[0].ElementRAZ.crossSection.id);
            el1.CrossSectionBegin = new ReferenceElement(crossSection);
            el1.CrossSectionEnd   = new ReferenceElement(crossSection);
            //el1.RotationRx = bearingMembers[0].ElementRAZ.rotationLCS;
            openModel.AddObject(el1);

            Element1D el2 = new Element1D();

            //el2.Id = openModel.GetMaxId(el2) + 1;

            el2.Id = bearingMembers[1].ElementRAZ.id + 1; //Use of Id from Grasshopper Model + Plus One

            el2.Name              = "E" + el2.Id.ToString();
            el2.Segment           = new ReferenceElement(lineSegment2);
            el2.CrossSectionBegin = new ReferenceElement(crossSection);
            el2.CrossSectionEnd   = new ReferenceElement(crossSection);
            //el2.RotationRx = bearingMembers[1].ElementRAZ.rotationLCS;
            openModel.AddObject(el2);

            //create member
            Member1D member1D = new Member1D();

            member1D.Id   = openModel.GetMaxId(member1D) + 1;
            member1D.Name = "Member" + member1D.Id.ToString();
            member1D.Elements1D.Add(new ReferenceElement(el1));
            member1D.Elements1D.Add(new ReferenceElement(el2));
            openModel.Member1D.Add(member1D);


            //create connected member
            ConnectedMember connectedMember = new ConnectedMember();

            connectedMember.Id       = member1D.Id;
            connectedMember.MemberId = new ReferenceElement(member1D);
            connectionPoint.ConnectedMembers.Add(connectedMember);
        }