Ejemplo n.º 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);
        }
Ejemplo n.º 2
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));

            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);
        }