public List <ApplicationPlaceholderObject> StructuralModelToNative(Model speckleStructModel) { List <ApplicationPlaceholderObject> placeholderObjects = new List <ApplicationPlaceholderObject> { }; foreach (Node node in speckleStructModel.nodes) { var Application = AnalyticalNodeToNative(node); placeholderObjects.Concat(Application); } foreach (var element in speckleStructModel.elements) { Element1D element1D = new Element1D(); if (element.GetType().Equals(element1D.GetType())) { try { var Application = AnalyticalStickToNative((Element1D)element); placeholderObjects.Concat(Application); } catch { } } else { try { var Application = AnalyticalSurfaceToNative((Element2D)element); placeholderObjects.Concat(Application); } catch { } } } return(placeholderObjects); }
/// <summary> /// Create member /// </summary> /// <param name="model">Idea open model</param> /// <param name="id">Member id</param> /// <param name="type">Member type</param> /// <param name="css">Cross section</param> /// <param name="startNode">Start node</param> /// <param name="endNode">End node</param> /// <returns>Connected member</returns> public static ConnectedMember CreateMember(OpenModel model, int id, Member1DType type, CrossSection css, string startNode, string endNode) { // create line segments LineSegment3D segment = CreateLineSegment3D(model, startNode, endNode); // create polylines PolyLine3D polyline = new PolyLine3D(); polyline.Id = model.GetMaxId(polyline) + 1; polyline.Segments.Add(new ReferenceElement(segment)); // add polylines and segments to the model model.AddObject(polyline); model.AddObject(segment); // create 1D elements Element1D element = CreateElement1D(model, css, segment); model.AddObject(element); // create 1D members Member1D member = CreateMember1D(model, id, type, element); model.Member1D.Add(member); // create and return connected member ConnectedMember connectedMember = new ConnectedMember(); connectedMember.Id = id; connectedMember.MemberId = new ReferenceElement(member); return(connectedMember); }
public List <ApplicationPlaceholderObject> AnalyticalStickToNative(Element1D speckleStick) { List <ApplicationPlaceholderObject> placeholderObjects = new List <ApplicationPlaceholderObject> { }; XYZ offset1 = VectorToNative(speckleStick.end1Offset); XYZ offset2 = VectorToNative(speckleStick.end2Offset); List <ApplicationPlaceholderObject> placeholders = new List <ApplicationPlaceholderObject> { }; switch (speckleStick.type) { case ElementType1D.Beam: RevitBeam revitBeam = new RevitBeam(); //This only works for CSIC sections now for sure. Need to test on other sections revitBeam.type = speckleStick.property.name.Replace('X', 'x'); revitBeam.baseLine = speckleStick.baseLine; //Beam beam = new Beam(speckleStick.baseLine); placeholders = BeamToNative(revitBeam); DB.FamilyInstance nativeRevitBeam = (DB.FamilyInstance)placeholders[0].NativeObject; AnalyticalModelStick analyticalModel = (AnalyticalModelStick)nativeRevitBeam.GetAnalyticalModel(); analyticalModel.SetReleases(true, Convert.ToBoolean(speckleStick.end1Releases.stiffnessX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end1Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZZ)); analyticalModel.SetReleases(false, Convert.ToBoolean(speckleStick.end2Releases.stiffnessX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end2Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZZ)); analyticalModel.SetOffset(AnalyticalElementSelector.StartOrBase, offset1); analyticalModel.SetOffset(AnalyticalElementSelector.EndOrTop, offset2); //analyticalModel. return(placeholders); case ElementType1D.Brace: RevitBrace revitBrace = new RevitBrace(); revitBrace.type = speckleStick.property.name.Replace('X', 'x'); revitBrace.baseLine = speckleStick.baseLine; //Brace brace = new Brace(speckleStick.baseLine); placeholders = BraceToNative(revitBrace); DB.FamilyInstance nativeRevitBrace = (DB.FamilyInstance)placeholders[0].NativeObject; analyticalModel = (AnalyticalModelStick)nativeRevitBrace.GetAnalyticalModel(); analyticalModel.SetReleases(true, Convert.ToBoolean(speckleStick.end1Releases.stiffnessX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end1Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZZ)); analyticalModel.SetReleases(false, Convert.ToBoolean(speckleStick.end2Releases.stiffnessX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end2Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZZ)); analyticalModel.SetOffset(AnalyticalElementSelector.StartOrBase, offset1); analyticalModel.SetOffset(AnalyticalElementSelector.EndOrTop, offset2); return(placeholders); case ElementType1D.Column: RevitColumn revitColumn = new RevitColumn(); revitColumn.type = speckleStick.property.name.Replace('X', 'x'); revitColumn.baseLine = speckleStick.baseLine; placeholders = ColumnToNative(revitColumn); DB.FamilyInstance nativeRevitColumn = (DB.FamilyInstance)placeholders[0].NativeObject; AnalyticalModelColumn analyticalModelCol = (AnalyticalModelColumn)nativeRevitColumn.GetAnalyticalModel(); analyticalModelCol.SetReleases(true, Convert.ToBoolean(speckleStick.end1Releases.stiffnessX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end1Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZZ)); analyticalModelCol.SetReleases(false, Convert.ToBoolean(speckleStick.end2Releases.stiffnessX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end2Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZZ)); analyticalModelCol.SetOffset(AnalyticalElementSelector.StartOrBase, offset1); analyticalModelCol.SetOffset(AnalyticalElementSelector.EndOrTop, offset2); return(placeholders); //Column column = new Column(speckleStick.baseLine); return(ColumnToNative(revitColumn)); } return(placeholderObjects); }
private ConnectedMember AddConnectedMember3point(int idMember, int idCss, int idPointA, int idPointB, int idPointC) { PolyLine3D polyLine3D = new PolyLine3D(); polyLine3D.Id = idMember; openStructModel.AddObject(polyLine3D); //Segments LineSegment3D ls1 = new LineSegment3D(); ls1.Id = openStructModel.GetMaxId(ls1) + 1; openStructModel.AddObject(ls1); ls1.StartPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointA)); ls1.EndPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointB)); polyLine3D.Segments.Add(new ReferenceElement(ls1)); LineSegment3D ls2 = new LineSegment3D(); ls2.Id = openStructModel.GetMaxId(ls2) + 1; openStructModel.AddObject(ls2); ls2.StartPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointB)); ls2.EndPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointC)); polyLine3D.Segments.Add(new ReferenceElement(ls2)); Element1D el1 = new Element1D(); el1.Id = openStructModel.GetMaxId(el1) + 1; el1.Name = "E" + el1.Id; el1.Segment = new ReferenceElement(ls1); el1.CrossSectionBegin = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); el1.CrossSectionEnd = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); openStructModel.AddObject(el1); Element1D el2 = new Element1D(); el2.Id = openStructModel.GetMaxId(el2) + 1; el2.Name = "E" + el2.Id; el2.Segment = new ReferenceElement(ls2); el2.CrossSectionBegin = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); el2.CrossSectionEnd = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); openStructModel.AddObject(el2); Member1D mb = new Member1D(); mb.Id = idMember; mb.Name = "B" + mb.Id; mb.Elements1D.Add(new ReferenceElement(el1)); mb.Elements1D.Add(new ReferenceElement(el2)); openStructModel.Member1D.Add(mb); ConnectedMember conMb = new ConnectedMember(); conMb.Id = mb.Id; conMb.MemberId = new ReferenceElement(mb); return(conMb); }
private void CreateIDEAOpenModelResults() { openStructModelR = new OpenModelResult(); openStructModelR.ResultOnMembers = new List <ResultOnMembers>(); ResultOnMembers resIF = new ResultOnMembers(); for (int ib = 0; ib < openStructModel.Member1D.Count; ib++) { Member1D mb = openStructModel.Member1D[ib]; for (int iel = 0; iel < mb.Elements1D.Count; iel++) { Element1D elem = openStructModel.Element1D.First(c => c.Id == mb.Elements1D[iel].Id); ResultOnMember resMember = new ResultOnMember(new Member() { Id = elem.Id, MemberType = MemberType.Element1D }, ResultType.InternalForces); int numPoints = 10; for (int ip = 0; ip <= numPoints; ip++) { ResultOnSection resSec = new ResultOnSection(); resSec.AbsoluteRelative = AbsoluteRelative.Relative; resSec.Position = (double)ip / (double)numPoints; int count = openStructModel.LoadCase.Count; for (int i = 1; i <= count; i++) { ResultOfInternalForces resLc = new ResultOfInternalForces(); int loadCaseNumber = i; resLc.Loading = new ResultOfLoading() { Id = loadCaseNumber, LoadingType = LoadingType.LoadCase }; resLc.Loading.Items.Add(new ResultOfLoadingItem() { Coefficient = 1.0 }); resLc.N = 15000; resLc.Qy = 2; resLc.Qz = 3; resLc.Mx = 4; resLc.My = (ip + 1) * 21000; resLc.Mz = 6; resSec.Results.Add(resLc); } resMember.Results.Add(resSec); } resIF.Members.Add(resMember); } } openStructModelR.ResultOnMembers.Add(resIF); }
/// <summary> /// Create element 1D /// </summary> /// <param name="model">Idea open model</param> /// <param name="css">Cross section</param> /// <param name="segment">Line segment</param> /// <returns>Element 1D</returns> private static Element1D CreateElement1D(OpenModel model, CrossSection css, LineSegment3D segment) { Element1D element1D = new Element1D(); element1D.Id = model.GetMaxId(element1D) + 1; element1D.Name = "E" + element1D.Id.ToString(); element1D.Segment = new ReferenceElement(segment); element1D.CrossSectionBegin = new ReferenceElement(css); element1D.CrossSectionEnd = new ReferenceElement(css); return(element1D); }
private double GetLength(OpenModel openStructModel, Member1D mb) { Element1D el = openStructModel.Element1D.First(c => c.Id == mb.Elements1D[0].Id); LineSegment3D seg = openStructModel.LineSegment3D.First(c => c.Id == el.Segment.Id); Point3D pA = openStructModel.Point3D.First(c => c.Id == seg.StartPoint.Id); Point3D pB = openStructModel.Point3D.First(c => c.Id == seg.EndPoint.Id); Vector3D vector = new Vector3D(); vector.X = pA.X - pB.X; vector.Y = pA.Y - pB.Y; vector.Z = pA.Z - pB.Z; return(Math.Sqrt(((vector.X * vector.X) + (vector.Y * vector.Y) + (vector.Z * vector.Z)))); }
/// <summary> /// Create member /// </summary> /// <param name="model">Idea open model</param> /// <param name="id">Member id</param> /// <param name="type">Member type</param> /// <param name="css">Cross section</param> /// <param name="startNode">Start node</param> /// <param name="middleNode">Middle node</param> /// <param name="endNode">End node</param> /// <returns>Connected member</returns> public static ConnectedMember CreateMember(OpenModel model, int id, Member1DType type, CrossSection css, string startNode, string middleNode, string endNode) { // column members have different coordination system in our example bool transformCoordSystem = type == Member1DType.Column ? true : false; // create line segments LineSegment3D segment1 = CreateLineSegment3D(model, startNode, middleNode, transformCoordSystem); model.AddObject(segment1); LineSegment3D segment2 = CreateLineSegment3D(model, middleNode, endNode, transformCoordSystem); model.AddObject(segment2); // create polylines PolyLine3D polyline = new PolyLine3D(); polyline.Id = model.GetMaxId(polyline) + 1; polyline.Segments.Add(new ReferenceElement(segment1)); polyline.Segments.Add(new ReferenceElement(segment2)); model.AddObject(polyline); // create 1D elements Element1D element1 = CreateElement1D(model, css, segment1); model.AddObject(element1); Element1D element2 = CreateElement1D(model, css, segment2); model.AddObject(element2); // create 1D members Member1D member = CreateMember1D(model, id, type, element1, element2); model.Member1D.Add(member); // create and return connected member ConnectedMember connectedMember = new ConnectedMember(); connectedMember.Id = id; connectedMember.MemberId = new ReferenceElement(member); return(connectedMember); }
private ConnectedMember AddConnectedMember2point(int idMember, int idCss, int idPointA, int idPointB, double eccentricity) { PolyLine3D polyLine3D = new PolyLine3D(); polyLine3D.Id = openStructModel.GetMaxId(polyLine3D) + 1; openStructModel.AddObject(polyLine3D); LineSegment3D ls = new LineSegment3D(); ls.Id = openStructModel.GetMaxId(ls) + 1; ls.StartPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointA)); ls.EndPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointB)); openStructModel.AddObject(ls); polyLine3D.Segments.Add(new ReferenceElement(ls)); Element1D el = new Element1D(); el.Id = openStructModel.GetMaxId(el) + 1; el.Name = "E" + el.Id.ToString(); el.Segment = new ReferenceElement(ls); el.EccentricityBeginZ = eccentricity; el.CrossSectionBegin = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); el.CrossSectionEnd = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); openStructModel.AddObject(el); Member1D mb = new Member1D(); mb.Id = idMember; mb.Name = "B" + mb.Id.ToString(); mb.Elements1D.Add(new ReferenceElement(el)); openStructModel.Member1D.Add(mb); ConnectedMember conMb = new ConnectedMember(); conMb.Id = mb.Id; conMb.MemberId = new ReferenceElement(mb); return(conMb); }
/// <summary> /// Create compound member 1D /// </summary> /// <param name="model">Idea open model</param> /// <param name="id">Member id</param> /// <param name="type">Member type</param> /// <param name="element1">First element</param> /// <param name="element2">Second element</param> /// <returns>Member 1D</returns> private static Member1D CreateMember1D(OpenModel model, int id, Member1DType type, Element1D element1, Element1D element2) { Member1D member1D = new Member1D(); member1D.Id = id; member1D.Name = "M" + member1D.Id.ToString(); member1D.Member1DType = type; member1D.Elements1D.Add(new ReferenceElement(element1)); member1D.Elements1D.Add(new ReferenceElement(element2)); return(member1D); }
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); }
private ConnectedMember AddConnectedMember(int idMember, int idCss, int idPointA, int idPointB, int idPointC, int idPointD, int idPointE) { PolyLine3D polyLine3D = new PolyLine3D(); polyLine3D.Id = idMember; openStructModel.AddObject(polyLine3D); //SEGMENTEN (voeg ls3 en ls4 toe) LineSegment3D ls1 = new LineSegment3D(); ls1.Id = openStructModel.GetMaxId(ls1) + 1; openStructModel.AddObject(ls1); ls1.StartPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointA)); ls1.EndPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointB)); polyLine3D.Segments.Add(new ReferenceElement(ls1)); LineSegment3D ls2 = new LineSegment3D(); ls2.Id = openStructModel.GetMaxId(ls2) + 1; openStructModel.AddObject(ls2); ls2.StartPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointB)); ls2.EndPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointC)); polyLine3D.Segments.Add(new ReferenceElement(ls2)); LineSegment3D ls3 = new LineSegment3D(); ls3.Id = openStructModel.GetMaxId(ls3) + 1; openStructModel.AddObject(ls3); ls3.StartPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointC)); ls3.EndPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointD)); polyLine3D.Segments.Add(new ReferenceElement(ls3)); LineSegment3D ls4 = new LineSegment3D(); ls4.Id = openStructModel.GetMaxId(ls4) + 1; openStructModel.AddObject(ls4); ls4.StartPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointD)); ls4.EndPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointE)); polyLine3D.Segments.Add(new ReferenceElement(ls4)); //ELEMENTEN (Crosssections toekennen) Element1D el1 = new Element1D(); el1.Id = openStructModel.GetMaxId(el1) + 1; el1.Name = "E" + el1.Id; el1.Segment = new ReferenceElement(ls1); el1.CrossSectionBegin = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); el1.CrossSectionEnd = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); openStructModel.AddObject(el1); Element1D el2 = new Element1D(); el2.Id = openStructModel.GetMaxId(el2) + 1; el2.Name = "E" + el2.Id; el2.Segment = new ReferenceElement(ls2); el2.CrossSectionBegin = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); el2.CrossSectionEnd = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); openStructModel.AddObject(el2); Element1D el3 = new Element1D(); el3.Id = openStructModel.GetMaxId(el3) + 1; el3.Name = "E" + el3.Id; el3.Segment = new ReferenceElement(ls3); el3.CrossSectionBegin = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); el3.CrossSectionEnd = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); openStructModel.AddObject(el3); Element1D el4 = new Element1D(); el4.Id = openStructModel.GetMaxId(el4) + 1; el4.Name = "E" + el4.Id; el4.Segment = new ReferenceElement(ls4); el4.CrossSectionBegin = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); el4.CrossSectionEnd = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss)); openStructModel.AddObject(el4); //MEMBERS Member1D mb = new Member1D(); mb.Id = idMember; mb.Name = "B" + mb.Id; mb.Elements1D.Add(new ReferenceElement(el1)); mb.Elements1D.Add(new ReferenceElement(el2)); mb.Elements1D.Add(new ReferenceElement(el3)); mb.Elements1D.Add(new ReferenceElement(el4)); openStructModel.Member1D.Add(mb); ConnectedMember conMb = new ConnectedMember(); conMb.Id = mb.Id; conMb.MemberId = new ReferenceElement(mb); return(conMb); }
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); }
public object FrameToNative(Element1D element1D) { if (GetAllFrameNames(Model).Contains(element1D.name)) { return(null); } string units = ModelUnits(); string newFrame = ""; Line baseline = element1D.baseLine; string[] properties = null; int number = 0; Model.PropFrame.GetNameList(ref number, ref properties); if (!properties.Contains(element1D.property.name)) { Property1DToNative(element1D.property); Model.PropFrame.GetNameList(ref number, ref properties); } if (baseline != null) { Point end1node = baseline.start; Point end2node = baseline.end; if (properties.Contains(element1D.property.name)) { Model.FrameObj.AddByCoord(end1node.x, end1node.y, end1node.z, end2node.x, end2node.y, end2node.z, ref newFrame, element1D.property.name); } else { Model.FrameObj.AddByCoord(end1node.x, end1node.y, end1node.z, end2node.x, end2node.y, end2node.z, ref newFrame); } } else { Point end1node = element1D.end1Node.basePoint; Point end2node = element1D.end2Node.basePoint; if (properties.Contains(element1D.property.name)) { Model.FrameObj.AddByCoord(end1node.x, end1node.y, end1node.z, end2node.x, end2node.y, end2node.z, ref newFrame, element1D.property.name); } else { Model.FrameObj.AddByCoord(end1node.x, end1node.y, end1node.z, end2node.x, end2node.y, end2node.z, ref newFrame); } } bool[] end1Release = null; bool[] end2Release = null; double[] startV, endV; startV = null; endV = null; if (element1D.end1Releases != null && element1D.end2Releases != null) { end1Release = RestraintToNative(element1D.end1Releases); end2Release = RestraintToNative(element1D.end2Releases); startV = PartialRestraintToNative(element1D.end1Releases); endV = PartialRestraintToNative(element1D.end2Releases); } if (element1D.orientationAngle != null) { Model.FrameObj.SetLocalAxes(newFrame, element1D.orientationAngle); } end1Release = end1Release.Select(b => !b).ToArray(); end2Release = end2Release.Select(b => !b).ToArray(); Model.FrameObj.SetReleases(newFrame, ref end1Release, ref end2Release, ref startV, ref endV); if (element1D.name != null) { Model.FrameObj.ChangeName(newFrame, element1D.name); } else { Model.FrameObj.ChangeName(newFrame, element1D.id); } if (element1D is ETABSElement1D) { var ETABSelement1D = (ETABSElement1D)element1D; if (ETABSelement1D.SpandrelAssignment != null) { Model.FrameObj.SetSpandrel(ETABSelement1D.name, ETABSelement1D.SpandrelAssignment); } if (ETABSelement1D.PierAssignment != null) { Model.FrameObj.SetPier(ETABSelement1D.name, ETABSelement1D.PierAssignment); } if (ETABSelement1D.ETABSLinearSpring != null) { Model.FrameObj.SetSpringAssignment(ETABSelement1D.name, ETABSelement1D.ETABSLinearSpring.name); } if (ETABSelement1D.DesignProcedure != null) { switch (ETABSelement1D.DesignProcedure) { case DesignProcedure.ProgramDetermined: Model.FrameObj.SetDesignProcedure(ETABSelement1D.name, 0); break; case DesignProcedure.CompositeBeamDesign: Model.FrameObj.SetDesignProcedure(ETABSelement1D.name, 3); break; case DesignProcedure.CompositeColumnDesign: Model.FrameObj.SetDesignProcedure(ETABSelement1D.name, 13); break; case DesignProcedure.SteelFrameDesign: Model.FrameObj.SetDesignProcedure(ETABSelement1D.name, 1); break; case DesignProcedure.ConcreteFrameDesign: Model.FrameObj.SetDesignProcedure(ETABSelement1D.name, 2); break; case DesignProcedure.SteelJoistDesign: Model.FrameObj.SetDesignProcedure(ETABSelement1D.name, 4); break; case DesignProcedure.NoDesign: Model.FrameObj.SetDesignProcedure(ETABSelement1D.name, 7); break; } if (ETABSelement1D.Modifiers != null) { var modifiers = ETABSelement1D.Modifiers; Model.FrameObj.SetModifiers(ETABSelement1D.name, ref modifiers); } } } return(element1D.name); }
private void CreateIDEAOpenModelResults(Joint joint) { Project project = joint.project; openModelResult.ResultOnMembers = new List <ResultOnMembers>(); ResultOnMembers resultIF = new ResultOnMembers(); for (int ibeam = 0; ibeam < openModel.Member1D.Count; ibeam++) { //Continues Chord consist out of one member Member1D mb = openModel.Member1D[ibeam]; //Loop is needed in case of a continuous member for (int iele = 0; iele < mb.Elements1D.Count; iele++) { //Continouos chord consists out of two elements Element1D elem = openModel.Element1D.First(a => a.Id == mb.Elements1D[iele].Id);//wordt hier de link met het verkeerde element gelegd? //word de verkeerde id toegekent? //results on members are constant in the framework ResultOnMember resMember = new ResultOnMember(new Member() { Id = elem.Id, MemberType = MemberType.Element1D }, ResultType.InternalForces); int numPoints = 1; for (int ip = 0; ip <= numPoints; ip++) { ResultOnSection resSec = new ResultOnSection(); resSec.AbsoluteRelative = AbsoluteRelative.Relative; resSec.Position = (double)ip / (double)numPoints; //iterate over loadcases int count = openModel.LoadCase.Count; for (int i = 1; i <= count; i++) { ResultOfInternalForces resLoadCase = new ResultOfInternalForces(); int loadCaseNumber = i; resLoadCase.Loading = new ResultOfLoading() { Id = loadCaseNumber, LoadingType = LoadingType.LoadCase }; resLoadCase.Loading.Items.Add(new ResultOfLoadingItem() { Coefficient = 1.0 }); //Check if Startpoint is equal to centerpoint int GrassId = elem.Id - 1; //Element1D.Id - 1 == ElementRAZ.id int GrassLCId = i - 1; //Loadcase grasshopper starts at 0, Loadcase IDEA starts at 1. List <BearingMember> BM = joint.attachedMembers.OfType <BearingMember>().ToList(); //Find the element to check: isStartpoint true or false AttachedMember attached = joint.attachedMembers.Find(a => a.ElementRAZ.id == GrassId); if (attached.isStartPoint == true) // { SetStartLoads(1, joint, GrassLCId, GrassId, resLoadCase, resSec); } else//isEndPoint { if (attached is BearingMember && BM.Count == 2) { SetEndLoads(1, joint, GrassLCId, GrassId, resLoadCase, resSec); } else { SetEndLoads(-1, joint, GrassLCId, GrassId, resLoadCase, resSec); } } } resMember.Results.Add(resSec); } resultIF.Members.Add(resMember); } } openModelResult.ResultOnMembers.Add(resultIF); }
protected override ModelBIM ImportActive(CountryCode countryCode, RequestedItemsType requestedType) { try { if (_selectedObjects?.Count == 0) { Debug.Fail("Nothing selected"); return(null); } var materials = new Dictionary <string, MatSteelEc2>(); var crossSections = new Dictionary <string, CrossSectionParameter>(); var pointConnections = _selectedObjects.OfType <StructuralPointConnection>().ToList(); var curveMembers = _selectedObjects.OfType <StructuralCurveMember>().ToList(); var assemblies = _selectedObjects.OfType <ElementAssembly>().ToList(); if (pointConnections.Count == 0) { MessageBoxHelper.ShowInformation("please select a PointConnection object to identify the connectionPoint", null); return(null); } // read all nodes (maybe it's esier) var nodes = _integrationBase.ApiCore.DtObjects.GetObjects <StructuralPointConnection>( _integrationBase.CurrentProject.Id, false, false, true); OpenModel openModel = new OpenModel { OriginSettings = new OriginSettings() { CrossSectionConversionTable = IdeaRS.OpenModel.CrossSectionConversionTable.NoUsed, CountryCode = countryCode } }; int ccsId = 1; int matId = 1; int lsId = 1; int memberId = 1; // ConnectionPoint ConnectionPoint connectionPoint = null; foreach (var point in pointConnections) { // ad main node to openModel connectionPoint = new ConnectionPoint(); if (point.NodeId.HasValue) { ConnectionPointId = point.NodeId.Value; } Point3D node = AddNodeToOpenModel(point, openModel, ConnectionPointId); connectionPoint.Node = new ReferenceElement(node); connectionPoint.Id = ConnectionPointId; connectionPoint.Name = string.Format("Conn-{0}", ConnectionPointId); connectionPoint.ProjectFileName = Path.Combine(".\\Connections", connectionPoint.Name + ".ideaCon"); } // try to add Member1D objects if they are not selected by user foreach (var assembly in assemblies) { if (assembly.Connections == null) { continue; } foreach (var c in assembly.Connections) { var ce = c as RelConnectsElements; if (ce == null || curveMembers.Find(x => x.Id == ce.RelatedElement.Value) != null) { continue; } var cm = _integrationBase.ApiCore.DtObjects.GetObjectInternal(ce.RelatedElement.Value) as StructuralCurveMember; if (cm != null) { foreach (var cm1 in pointConnections[0].ConnectsStructuralMembers) { if (cm.Id.ToString() == cm1.RelatingStructuralMember.GetValueOrDefault().ToString()) { curveMembers.Add(cm); } } } } } // create Element1D from StructuralCurveMember foreach (var element in curveMembers) { var matName = element.GetStringProperty(TableNames.contentAttributes, MaterialAttributeId) ?? "S355"; if (!materials.ContainsKey(matName)) { MatSteelEc2 material = new MatSteelEc2(); // set properties material.Id = matId++; material.Name = matName; material.E = 210000000000; material.G = material.E / (2 * (1 + 0.3)); material.Poisson = 0.3; material.UnitMass = 7850; material.SpecificHeat = 0.6; material.ThermalExpansion = 0.000012; material.ThermalConductivity = 45; material.IsDefaultMaterial = false; material.OrderInCode = 0; material.StateOfThermalExpansion = ThermalExpansionState.Code; material.StateOfThermalConductivity = ThermalConductivityState.Code; material.StateOfThermalSpecificHeat = ThermalSpecificHeatState.Code; material.StateOfThermalStressStrain = ThermalStressStrainState.Code; material.StateOfThermalStrain = ThermalStrainState.Code; material.fy = 355000000; material.fu = 510000000; material.fy40 = 335000000; material.fu40 = 470000000; material.DiagramType = SteelDiagramType.Bilinear; // add material to the model openModel.AddObject(material); materials.Add(matName, material); } var crossSection = element.GetStringProperty(TableNames.contentAttributes, CrossSectionAttributeId) ?? "HE200"; crossSection = crossSection.Replace("HE200B", "HEB200"); crossSection = crossSection.Replace("HE240B", "HEB240"); if (!crossSections.ContainsKey(crossSection)) { CrossSectionParameter css = new CrossSectionParameter { Id = ccsId++, Name = crossSection, CrossSectionRotation = 0, CrossSectionType = CrossSectionType.RolledI, Material = new ReferenceElement(materials[matName]) }; css.Parameters.Add(new ParameterString() { Name = "UniqueName", Value = crossSection }); // add cross sections to the model openModel.AddObject(css); crossSections.Add(crossSection, css); } if (element?.ConnectedBy.Count != 2) { continue; } var node = nodes.Find(x => x.Id == element?.ConnectedBy[0].RelatedStructuralConnection.Value); if (node == null) { continue; } Point3D ptA = AddNodeToOpenModel(node, openModel, node.NodeId.GetValueOrDefault()); node = nodes.Find(x => x.Id == element?.ConnectedBy[1].RelatedStructuralConnection.Value); Point3D ptB = AddNodeToOpenModel(node, openModel, node.NodeId.GetValueOrDefault()); var member1d = new Member1D { Id = memberId++, Name = element.Name }; IdeaRS.OpenModel.Geometry3D.PolyLine3D polyLine3D = new IdeaRS.OpenModel.Geometry3D.PolyLine3D { Id = member1d.Id }; var start = new WM.Point3D(ptA.X, ptA.Y, ptA.Z); var end = new WM.Point3D(ptB.X, ptB.Y, ptB.Z); var dirVectort = end - start; GetAngles(dirVectort, out double alpha, out double beta); beta *= -1; CI.Geometry3D.Matrix44 lcsSegmentMatrix = new CI.Geometry3D.Matrix44(); if (!IsZero(beta)) { // gamma pitch lcsSegmentMatrix.Rotate(beta, new CI.Geometry3D.Vector3D(0, 1, 0)); } if (!IsZero(alpha)) { // beta direction lcsSegmentMatrix.Rotate(alpha, new CI.Geometry3D.Vector3D(0, 0, 1)); } IdeaRS.OpenModel.Geometry3D.LineSegment3D ls = new IdeaRS.OpenModel.Geometry3D.LineSegment3D { Id = member1d.Id, StartPoint = new ReferenceElement(ptA), EndPoint = new ReferenceElement(ptB), LocalCoordinateSystem = new IdeaRS.OpenModel.Geometry3D.CoordSystemByVector() { VecX = new IdeaRS.OpenModel.Geometry3D.Vector3D() { X = lcsSegmentMatrix.AxisX.DirectionX, Y = lcsSegmentMatrix.AxisX.DirectionY, Z = lcsSegmentMatrix.AxisX.DirectionZ, } , VecY = new IdeaRS.OpenModel.Geometry3D.Vector3D() { X = lcsSegmentMatrix.AxisY.DirectionX, Y = lcsSegmentMatrix.AxisY.DirectionY, Z = lcsSegmentMatrix.AxisY.DirectionZ, } , VecZ = new IdeaRS.OpenModel.Geometry3D.Vector3D() { X = lcsSegmentMatrix.AxisZ.DirectionX, Y = lcsSegmentMatrix.AxisZ.DirectionY, Z = lcsSegmentMatrix.AxisZ.DirectionZ, } }, }; polyLine3D.Segments.Add(new ReferenceElement(ls)); openModel.PolyLine3D.Add(polyLine3D); openModel.LineSegment3D.Add(ls); Element1D element1d = new Element1D { Id = member1d.Id, Name = element.Id.ToString(), //element.Name, Its esier for mapping Element1D with bimplus Structuralcurvemember RotationRx = element.GetDoubleProperty(TableNames.contentAttributes, RotationAttributeId) ?? 0, CrossSectionBegin = new ReferenceElement(crossSections[crossSection]), CrossSectionEnd = new ReferenceElement(crossSections[crossSection]), Segment = new ReferenceElement(ls) }; openModel.Element1D.Add(element1d); member1d.Elements1D.Add(new ReferenceElement(element1d)); openModel.Member1D.Add(member1d); if (connectionPoint != null) { ConnectedMember conMb = new ConnectedMember { Id = member1d.Id, MemberId = new ReferenceElement(member1d), IsContinuous = false, }; connectionPoint.ConnectedMembers.Add(conMb); } BeamData beamData = new BeamData { Id = member1d.Id, Name = element1d.Name, OriginalModelId = member1d.Id.ToString(), // member1d.Name, IsAdded = false, MirrorY = false, RefLineInCenterOfGravity = true, }; if (openModel.Connections.Count == 0) { openModel.Connections.Add(new ConnectionData()); } (openModel.Connections[0].Beams ?? (openModel.Connections[0].Beams = new List <BeamData>())).Add(beamData); } // create Member1D from assemblies /* foreach (var assembly in assemblies) * { * var member1d = new Member1D * { * Id = assembly.OrderNumber.GetValueOrDefault(), * Name = assembly.Name * }; * foreach (var c in assembly.Connections) * { * var ce = c as RelConnectsElements; * var element = openModel.Element1D.Find(x => x.Name == ce.RelatedElement.ToString()); * if (element == null) continue; * member1d.Elements1D.Add(new ReferenceElement(element)); * openModel.Member1D.Add(member1d); * } * }*/ /*if (connectionPoint != null) * { * var p0t = pointConnections.Find(x => x.NodeId.GetValueOrDefault() == ConnectionPointId); * if (p0t != null && p0t.ConnectsStructuralMembers != null) * { * foreach (var cm in p0t.ConnectsStructuralMembers) * { * var member = openModel.Element1D.Find(x => x.Name == cm.RelatingStructuralMember.GetValueOrDefault().ToString()); * if (member == null) * continue; * ConnectedMember conMb = new ConnectedMember * { * Id = member.Id, * MemberId = new ReferenceElement(member), * IsContinuous = false, * }; * connectionPoint.ConnectedMembers.Add(conMb); * * // BEAM DATA - definition * BeamData bData = new BeamData * { * Id = conMb.Id, * OriginalModelId = "???", // ass.Id.ToString(), is it important? * IsAdded = false, * MirrorY = false, * RefLineInCenterOfGravity = false, * }; * if (openModel.Connections.Count == 0) * { * openModel.Connections.Add(new ConnectionData { Beams = new List<BeamData>() }); * } * openModel.Connections[0].Beams.Add(bData); * } * } * * }*/ openModel.AddObject(connectionPoint); // important !!! OpenModelResult openModelResult = new OpenModelResult() { ResultOnMembers = new System.Collections.Generic.List <ResultOnMembers>() { new ResultOnMembers() } }; OpenMessages openMessages = new OpenMessages(); return(new ModelBIM() { Items = new List <BIMItemId>() { new BIMItemId() { Id = connectionPoint.Id, Type = BIMItemType.Node } }, Model = openModel, Results = openModelResult, Messages = openMessages, Project = AllplanBimplusDemo.Properties.Settings.Default.IdeaDefaultWorkingDir, }); } catch (Exception e) { MessageBoxHelper.ShowInformation(e.Message, null); return(null); } }
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 CreateIDEAOpenModelResults(Joint joint) { Project project = joint.project; openModelResult.ResultOnMembers = new List <ResultOnMembers>(); ResultOnMembers resultIF = new ResultOnMembers(); for (int ibeam = 0; ibeam < openModel.Member1D.Count; ibeam++) { //Continues Chord consist out of one member Member1D mb = openModel.Member1D[ibeam]; //Loop is needed in case of a continuous member for (int iele = 0; iele < mb.Elements1D.Count; iele++) { //Continues chord consists out of two elements Element1D elem = openModel.Element1D.First(a => a.Id == mb.Elements1D[iele].Id);//wordt hier de link met het verkeerde element gelegd? //word de verkeerde id toegekent? //results on members are constant in the framework ResultOnMember resMember = new ResultOnMember(new Member() { Id = elem.Id, MemberType = MemberType.Element1D }, ResultType.InternalForces); int numPoints = 10; for (int ip = 0; ip <= numPoints; ip++) { ResultOnSection resSec = new ResultOnSection(); resSec.AbsoluteRelative = AbsoluteRelative.Relative; resSec.Position = (double)ip / (double)numPoints; //iterate over loadcases int count = openModel.LoadCase.Count; for (int i = 1; i <= count; i++) { ResultOfInternalForces resLoadCase = new ResultOfInternalForces(); int loadCaseNumber = i; resLoadCase.Loading = new ResultOfLoading() { Id = loadCaseNumber, LoadingType = LoadingType.LoadCase }; resLoadCase.Loading.Items.Add(new ResultOfLoadingItem() { Coefficient = 1.0 }); //Check if Startpoint is equal to centerpoint int GrassId = elem.Id - 1;//Element1D.Id - 1 == ElementRAZ.id int GrassLCId = i - 1; AttachedMember attached = joint.attachedMembers.Find(a => a.ElementRAZ.id == GrassId); //The following if statements simulate that every member has a local coordinate system //where the local z-axis points counterclockwise (shear force) //and where the positive bending moment is clockwise if (attached.isStartPoint == true) { //Pick startloads //API to IDEA UI, My, Vy and Vz are plotted negatively double N0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.N; double My0 = (-1) * 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.My; double Vz0 = (-1) * 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Vz; double Vy0 = (-1) * 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Vy; double Mz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Mz; double Mt0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Mt; //From Karamba3D to Framework double N = N0; double My = My0; double Vz = Vz0; double Vy = Vy0; double Mz = Mz0; double Mt = Mt0; resLoadCase.N = N; // resLoadCase.My = My; // resLoadCase.Qz = Vz; // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } else//isEndPoint { //Pick endloads //API to IDEA UI, My, Vy and Vz are plotted negatively double N0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.N; double My0 = (-1) * 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.My; double Vz0 = (-1) * 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Vz; double Vy0 = (-1) * 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Vy; double Mz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Mz; double Mt0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Mt; //From Karamba3D to Framework double N = N0 * (-1); double My = My0 * (-1); // double Vz = Vz0 * (-1); double Vy = Vy0 * (-1); double Mz = Mz0 * (-1); // double Mt = Mt0 * (-1); resLoadCase.N = N; // resLoadCase.My = My; // resLoadCase.Qz = Vz; // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } } resMember.Results.Add(resSec); } resultIF.Members.Add(resMember); } } openModelResult.ResultOnMembers.Add(resultIF); }
private void CreateIDEAOpenModelResultsOLD(Joint joint) { Project project = joint.project; openModelResult.ResultOnMembers = new List <ResultOnMembers>(); ResultOnMembers resultIF = new ResultOnMembers(); for (int ibeam = 0; ibeam < openModel.Member1D.Count; ibeam++) { //Continues Chord consist out of one member Member1D mb = openModel.Member1D[ibeam]; for (int iele = 0; iele < mb.Elements1D.Count; iele++) { //Continues chord consist out of two elements Element1D elem = openModel.Element1D.First(a => a.Id == mb.Elements1D[iele].Id); //results on members are constant in the framework ResultOnMember resMember = new ResultOnMember(new Member() { Id = elem.Id, MemberType = MemberType.Element1D }, ResultType.InternalForces); int numPoints = 10; for (int ip = 0; ip <= numPoints; ip++) { ResultOnSection resSec = new ResultOnSection(); resSec.AbsoluteRelative = AbsoluteRelative.Relative; resSec.Position = (double)ip / (double)numPoints; //iterate over loadcases int count = openModel.LoadCase.Count; for (int i = 1; i <= count; i++) { ResultOfInternalForces resLoadCase = new ResultOfInternalForces(); int loadCaseNumber = i; resLoadCase.Loading = new ResultOfLoading() { Id = loadCaseNumber, LoadingType = LoadingType.LoadCase }; resLoadCase.Loading.Items.Add(new ResultOfLoadingItem() { Coefficient = 1.0 }); //Check if Startpoint is equal to centerpoint int GrassId = elem.Id - 1;//Element1D.Id - 1 == ElementRAZ.id int GrassLCId = i - 1; AttachedMember attached = joint.attachedMembers.Find(a => a.ElementRAZ.id == GrassId); //The following if statements simulate that every member has a local coordinate system //where the local z - axis points counterclockwise(shear force) //and where the positive bending moment is clockwise if (attached.isStartPoint == true) { //Pick startloads // API to IDEA UI, My and Vz are plotted negatively double N0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.N; double My0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.My * -1; double Vz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Vz * -1; double Vy0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Vy; double Mz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Mz; double Mt0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Mt; //From Karamba3D to Framework double N = N0; double My = My0; double Vz = Vz0; double Vy = Vy0; double Mz = Mz0; double Mt = Mt0; //From Framework to IDEA VectorRAZ unitvector = attached.ideaLine.vector.Unitize();//gaat niet op bij ColumnT-Joint want gebruikt globale asses ipv locale if (unitvector.X < -10e-6) { if (attached is BearingMember) //exception { resLoadCase.N = N; // resLoadCase.My = My * (-1); // in case of start point M of the begin element of the chords needs to be flipped resLoadCase.Qz = Vz * (-1); // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz0; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } else//members where rule needs to be applied to { resLoadCase.N = N;// resLoadCase.My = My * -1; // resLoadCase.Qz = Vz * -1; // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz0; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } } else { resLoadCase.N = N; // resLoadCase.My = My; // resLoadCase.Qz = Vz; // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz0; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } } else//isEndPoint { //Pick endloads //API to IDEA UI, My and Vz are plotted negatively double N0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.N; double My0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.My * -1; double Vz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Vz * -1; double Vy0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Vy; double Mz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Mz; double Mt0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Mt; //From Karamba3D to Framework double N = N0; double My = My0 * (-1); //*-1 double Vz = Vz0 * (-1); //*-1 double Vy = Vy0 * (-1); //*-1 double Mz = Mz0 * (-1); //*-1 double Mt = Mt0 * (-1); //*-1 //From Framework to IDEA VectorRAZ unitvector = attached.ideaLine.vector.Unitize();//gaat niet op bij ColumnT-Joint want gebruikt globale asses ipv locale if (unitvector.X < -10e-6) { if (attached is BearingMember) //exception { resLoadCase.N = N; // resLoadCase.My = My * (-1); // in case of start point M of the begin element of the chords needs to be flipped resLoadCase.Qz = Vz * (-1); // resLoadCase.Qy = Vy * (-1); resLoadCase.Mz = Mz0 * (-1); resLoadCase.Mx = Mt * (-1); resSec.Results.Add(resLoadCase); } else//members where rule needs to be applied to { resLoadCase.N = N;// resLoadCase.My = My * (-1); // * (-1) resLoadCase.Qz = Vz * (-1); // * (-1) resLoadCase.Qy = Vy * (-1); resLoadCase.Mz = Mz0 * (-1); resLoadCase.Mx = Mt * (-1); resSec.Results.Add(resLoadCase); } } else { resLoadCase.N = N; // resLoadCase.My = My; // resLoadCase.Qz = Vz; // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz0; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } } } resMember.Results.Add(resSec); } resultIF.Members.Add(resMember); } } openModelResult.ResultOnMembers.Add(resultIF); }
private Element1D AnalyticalStickToSpeckle(AnalyticalModelStick revitStick) { if (!revitStick.IsEnabled()) { return(new Element1D()); } var speckleElement1D = new Element1D(); switch (revitStick.Category.Name) { case "Analytical Columns": speckleElement1D.type = ElementType1D.Column; break; case "Analytical Beams": speckleElement1D.type = ElementType1D.Beam; break; case "Analytical Braces": speckleElement1D.type = ElementType1D.Brace; break; default: speckleElement1D.type = ElementType1D.Other; break; } var curves = revitStick.GetCurves(AnalyticalCurveType.RigidLinkHead).ToList(); curves.AddRange(revitStick.GetCurves(AnalyticalCurveType.ActiveCurves)); curves.AddRange(revitStick.GetCurves(AnalyticalCurveType.RigidLinkTail)); if (curves.Count > 1) { speckleElement1D.baseLine = null; } else { speckleElement1D.baseLine = (Objects.Geometry.Line)CurveToSpeckle(curves[0]); } var coordinateSystem = revitStick.GetLocalCoordinateSystem(); if (coordinateSystem != null) { speckleElement1D.localAxis = new Geometry.Plane(PointToSpeckle(coordinateSystem.Origin), VectorToSpeckle(coordinateSystem.BasisZ), VectorToSpeckle(coordinateSystem.BasisX), VectorToSpeckle(coordinateSystem.BasisY)); } var startOffset = revitStick.GetOffset(AnalyticalElementSelector.StartOrBase); var endOffset = revitStick.GetOffset(AnalyticalElementSelector.EndOrTop); speckleElement1D.end1Offset = VectorToSpeckle(startOffset); speckleElement1D.end2Offset = VectorToSpeckle(endOffset); var startRelease = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_START_RELEASE_TYPE); var endRelease = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_END_RELEASE_TYPE); if (startRelease == 0) { speckleElement1D.end1Releases = new Restraint(RestraintType.Fixed); } else { var botReleaseX = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_FX) == 1 ? "R" : "F"; var botReleaseY = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_FY) == 1 ? "R" : "F"; var botReleaseZ = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_FZ) == 1 ? "R" : "F"; var botReleaseXX = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_MX) == 1 ? "R" : "F"; var botReleaseYY = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_MY) == 1 ? "R" : "F"; var botReleaseZZ = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_MZ) == 1 ? "R" : "F"; string botReleaseCode = botReleaseX + botReleaseY + botReleaseZ + botReleaseXX + botReleaseYY + botReleaseZZ; speckleElement1D.end1Releases = new Restraint(botReleaseCode); } if (endRelease == 0) { speckleElement1D.end2Releases = new Restraint(RestraintType.Fixed); } else { var topReleaseX = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_FX) == 1 ? "R" : "F"; var topReleaseY = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_FY) == 1 ? "R" : "F"; var topReleaseZ = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_FZ) == 1 ? "R" : "F"; var topReleaseXX = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_MX) == 1 ? "R" : "F"; var topReleaseYY = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_MY) == 1 ? "R" : "F"; var topReleaseZZ = GetParamValue <int>(revitStick, BuiltInParameter.STRUCTURAL_TOP_RELEASE_MZ) == 1 ? "R" : "F"; string topReleaseCode = topReleaseX + topReleaseY + topReleaseZ + topReleaseXX + topReleaseYY + topReleaseZZ; speckleElement1D.end2Releases = new Restraint(topReleaseCode); } var prop = new Property1D(); var stickFamily = (Autodesk.Revit.DB.FamilyInstance)Doc.GetElement(revitStick.GetElementId()); var section = stickFamily.Symbol.GetStructuralSection(); var speckleSection = new SectionProfile(); speckleSection.name = section.StructuralSectionShapeName; switch (section.StructuralSectionGeneralShape) { case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralI: // Double T structural sections var ISection = new ISection(); ISection.name = section.StructuralSectionShapeName; ISection.shapeType = Structural.ShapeType.I; ISection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("Height").GetValue(section); ISection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("Width").GetValue(section); ISection.webThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("WebThickness").GetValue(section); ISection.flangeThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("FlangeThickness").GetValue(section); ISection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("SectionArea").GetValue(section); ISection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("NominalWeight").GetValue(section); ISection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); ISection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); ISection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralI).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = ISection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralT: // Tees structural sections var teeSection = new Tee(); teeSection.name = section.StructuralSectionShapeName; teeSection.shapeType = Structural.ShapeType.I; teeSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("Height").GetValue(section); teeSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("Width").GetValue(section); teeSection.webThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("WebThickness").GetValue(section); teeSection.flangeThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("FlangeThickness").GetValue(section); teeSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("SectionArea").GetValue(section); teeSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("NominalWeight").GetValue(section); teeSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); teeSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); teeSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralT).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = teeSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralH: // Rectangular Pipe structural sections var rectSection = new Rectangular(); rectSection.name = section.StructuralSectionShapeName; rectSection.shapeType = Structural.ShapeType.I; rectSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("Height").GetValue(section); rectSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("Width").GetValue(section); var wallThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("WallNominalThickness").GetValue(section); rectSection.webThickness = wallThickness; rectSection.flangeThickness = wallThickness; rectSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("SectionArea").GetValue(section); rectSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("NominalWeight").GetValue(section); rectSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); rectSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); rectSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = rectSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralR: // Pipe structural sections var circSection = new Circular(); circSection.name = section.StructuralSectionShapeName; circSection.shapeType = Structural.ShapeType.Circular; circSection.radius = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("Diameter").GetValue(section) / 2; circSection.wallThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("WallNominalThickness").GetValue(section); circSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("SectionArea").GetValue(section); circSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("NominalWeight").GetValue(section); circSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); circSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); circSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = circSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralF: // Flat Bar structural sections var flatRectSection = new Rectangular(); flatRectSection.name = section.StructuralSectionShapeName; flatRectSection.shapeType = Structural.ShapeType.I; flatRectSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("Height").GetValue(section); flatRectSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("Width").GetValue(section); flatRectSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("SectionArea").GetValue(section); flatRectSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("NominalWeight").GetValue(section); flatRectSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); flatRectSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); flatRectSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralF).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = flatRectSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralS: // Round Bar structural sections var flatCircSection = new Circular(); flatCircSection.name = section.StructuralSectionShapeName; flatCircSection.shapeType = Structural.ShapeType.Circular; flatCircSection.radius = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("Diameter").GetValue(section) / 2; flatCircSection.wallThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("WallNominalThickness").GetValue(section); flatCircSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("SectionArea").GetValue(section); flatCircSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("NominalWeight").GetValue(section); flatCircSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); flatCircSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); flatCircSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralS).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = flatCircSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralW: // Angle structural sections var angleSection = new Angle(); angleSection.name = section.StructuralSectionShapeName; angleSection.shapeType = Structural.ShapeType.Angle; angleSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("Height").GetValue(section); angleSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("Width").GetValue(section); angleSection.webThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("WebThickness").GetValue(section); angleSection.flangeThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("FlangeThickness").GetValue(section); angleSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("SectionArea").GetValue(section); angleSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("NominalWeight").GetValue(section); angleSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); angleSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); angleSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralW).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = angleSection; break; case DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralU: // Channel structural sections var channelSection = new Channel(); channelSection.name = section.StructuralSectionShapeName; channelSection.shapeType = Structural.ShapeType.Channel; channelSection.depth = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("Height").GetValue(section); channelSection.width = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("Width").GetValue(section); channelSection.webThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("WebThickness").GetValue(section); channelSection.flangeThickness = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("FlangeThickness").GetValue(section); channelSection.area = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("SectionArea").GetValue(section); channelSection.weight = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("NominalWeight").GetValue(section); channelSection.Iyy = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("MomentOfInertiaStrongAxis").GetValue(section); channelSection.Izz = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("MomentOfInertiaWeakAxis").GetValue(section); channelSection.J = (double)typeof(DB.Structure.StructuralSections.StructuralSectionGeneralU).GetProperty("TorsionalMomentOfInertia").GetValue(section); speckleSection = channelSection; break; default: speckleSection.name = section.StructuralSectionShapeName; break; } var materialType = stickFamily.StructuralMaterialType; var structMat = (DB.Material)Doc.GetElement(stickFamily.StructuralMaterialId); if (structMat == null) { structMat = (DB.Material)Doc.GetElement(stickFamily.Symbol.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM).AsElementId()); } var materialAsset = ((PropertySetElement)Doc.GetElement(structMat.StructuralAssetId)).GetStructuralAsset(); Structural.Materials.Material speckleMaterial = null; switch (materialType) { case StructuralMaterialType.Concrete: var concreteMaterial = new Concrete { name = Doc.GetElement(stickFamily.StructuralMaterialId).Name, //type = Structural.MaterialType.Concrete, grade = null, designCode = null, codeYear = null, elasticModulus = materialAsset.YoungModulus.X, compressiveStrength = materialAsset.ConcreteCompression, tensileStrength = 0, flexuralStrength = 0, maxCompressiveStrain = 0, maxTensileStrain = 0, maxAggregateSize = 0, lightweight = materialAsset.Lightweight, poissonsRatio = materialAsset.PoissonRatio.X, shearModulus = materialAsset.ShearModulus.X, density = materialAsset.Density, thermalExpansivity = materialAsset.ThermalExpansionCoefficient.X, dampingRatio = 0 }; speckleMaterial = concreteMaterial; break; case StructuralMaterialType.Steel: var steelMaterial = new Steel { name = Doc.GetElement(stickFamily.StructuralMaterialId).Name, //type = Structural.MaterialType.Steel, grade = materialAsset.Name, designCode = null, codeYear = null, elasticModulus = materialAsset.YoungModulus.X, // Newtons per foot meter yieldStrength = materialAsset.MinimumYieldStress, // Newtons per foot meter ultimateStrength = materialAsset.MinimumTensileStrength, // Newtons per foot meter maxStrain = 0, poissonsRatio = materialAsset.PoissonRatio.X, shearModulus = materialAsset.ShearModulus.X, // Newtons per foot meter density = materialAsset.Density, // kilograms per cubed feet thermalExpansivity = materialAsset.ThermalExpansionCoefficient.X, // inverse Kelvin dampingRatio = 0 }; speckleMaterial = steelMaterial; break; case StructuralMaterialType.Wood: var timberMaterial = new Timber { name = Doc.GetElement(structMat.StructuralAssetId).Name, //type = Structural.MaterialType.Timber, grade = materialAsset.WoodGrade, designCode = null, codeYear = null, elasticModulus = materialAsset.YoungModulus.X, // Newtons per foot meter poissonsRatio = materialAsset.PoissonRatio.X, shearModulus = materialAsset.ShearModulus.X, // Newtons per foot meter density = materialAsset.Density, // kilograms per cubed feet thermalExpansivity = materialAsset.ThermalExpansionCoefficient.X, // inverse Kelvin species = materialAsset.WoodSpecies, dampingRatio = 0 }; timberMaterial["bendingStrength"] = materialAsset.WoodBendingStrength; timberMaterial["parallelCompressionStrength"] = materialAsset.WoodParallelCompressionStrength; timberMaterial["parallelShearStrength"] = materialAsset.WoodParallelShearStrength; timberMaterial["perpendicularCompressionStrength"] = materialAsset.WoodPerpendicularCompressionStrength; timberMaterial["perpendicularShearStrength"] = materialAsset.WoodPerpendicularShearStrength; speckleMaterial = timberMaterial; break; default: var defaultMaterial = new Objects.Structural.Materials.Material { name = Doc.GetElement(stickFamily.StructuralMaterialId).Name }; speckleMaterial = defaultMaterial; break; } prop.profile = speckleSection; prop.material = speckleMaterial; prop.name = Doc.GetElement(revitStick.GetElementId()).Name; var structuralElement = Doc.GetElement(revitStick.GetElementId()); var mark = GetParamValue <string>(structuralElement, BuiltInParameter.ALL_MODEL_MARK); if (revitStick is AnalyticalModelColumn) { speckleElement1D.type = ElementType1D.Column; //prop.memberType = MemberType.Column; var locationMark = GetParamValue <string>(structuralElement, BuiltInParameter.COLUMN_LOCATION_MARK); if (locationMark == null) { speckleElement1D.name = mark; } else { speckleElement1D.name = locationMark; } } else { prop.memberType = MemberType.Beam; speckleElement1D.name = mark; } speckleElement1D.property = prop; GetAllRevitParamsAndIds(speckleElement1D, revitStick); speckleElement1D.displayMesh = GetElementDisplayMesh(Doc.GetElement(revitStick.GetElementId())); return(speckleElement1D); }
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); }