public override LinearElementCollection EnterLinearElements(string prompt = "Enter linear elements") { GetObject gO = new GetObject(); gO.SetCustomGeometryFilter(new GetObjectGeometryFilter(FilterHandles)); gO.GeometryFilter = ObjectType.Curve; gO.SetCommandPrompt(prompt); if (gO.GetMultiple(1, 0) == GetResult.Cancel) { throw new OperationCanceledException("Operation cancelled by user"); } var result = new LinearElementCollection(); foreach (ObjRef rObj in gO.Objects()) { if (Host.Instance.Handles.Links.ContainsSecond(rObj.ObjectId)) { Guid guid = Host.Instance.Handles.Links.GetFirst(rObj.ObjectId); Element element = Core.Instance.ActiveDocument?.Model?.Elements[guid]; if (element != null && element is LinearElement) { result.Add((LinearElement)element); } } } return(result); }
public static List <LinearElementGoo> Convert(LinearElementCollection collection, ExecutionInfo exInfo = null) { var result = new List <LinearElementGoo>(); if (collection != null) { foreach (LinearElement obj in collection) { result.Add(new LinearElementGoo(obj, exInfo)); } } return(result); }
/// <summary> /// Initialise a new spring force physics component including /// springs based on the specified set of linear elements /// </summary> /// <param name="elements"></param> public SpringForceComponent(LinearElementCollection elements) { foreach (var element in elements) { if (!element.IsDeleted) { if (!element.HasData <Spring>()) { element.Data.Add(new Spring(element)); } Springs.Add(element.GetData <Spring>()); } } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Host.EnsureInitialisation(); LinearElementCollection elements = Core.Instance.ActiveDocument.Model.Elements.LinearElements; foreach (LinearElement lEl in elements) { if (!lEl.IsDeleted) { Extrusion extrusion = ToRC.ConvertToExtrusion(lEl); Guid guid = Guid.Empty; if (extrusion != null) { guid = RhinoOutput.BakeExtrusion(extrusion); } else { Brep brep = ToRC.ConvertToBrep(lEl); if (brep != null) { guid = RhinoOutput.Bake(brep); } } if (guid != Guid.Empty) { RhinoOutput.SetObjectName(guid, lEl.Name); if (lEl.Family != null) { RhinoOutput.SetObjectUserString(guid, "Family", lEl.Family.Name); if (lEl.Family.GetPrimaryMaterial() != null) { RhinoOutput.SetObjectUserString(guid, "Material", lEl.Family.GetPrimaryMaterial().Name); } if (lEl.Family.Profile != null) { RhinoOutput.SetObjectUserString(guid, "Profile", lEl.Family.Profile.ToString()); } } } } } Host.Instance.Refresh(); return(Result.Success); }
/// <summary> /// Write Linear Elements to ETABS /// </summary> /// <param name="elements"></param> /// <param name="context"></param> public void WriteLinearElements(LinearElementCollection elements, ETABSConversionContext context) { foreach (LinearElement element in elements) { if (!element.IsDeleted) { Vector s = element.Start.Position; Vector e = element.End.Position; string id = context.IDMap.GetSecondID(element) ?? ""; SapModel.FrameObj.AddByCoord(s.X, s.Y, s.Z, e.X, e.Y, e.Z, ref id, element.Family?.Name, element.Name); //Releases: bool[] sRls = element.Start.Releases.ToArray(); bool[] eRls = element.End.Releases.ToArray(); double[] sStf = new double[6]; //Temp double[] eStf = new double[6]; //Temp SapModel.FrameObj.SetReleases(id, ref sRls, ref eRls, ref sStf, ref eStf); SapModel.FrameObj.SetLocalAxes(id, element.Orientation.Degrees); // May need adjustment for columns! context.IDMap.Add(element, id); } } }
public override bool Execute(ExecutionInfo exInfo = null) { Beams = new LinearElementCollection(); VertexCollection verts = new VertexCollection(SupportPoints); MeshFaceCollection faces = Mesh.DelaunayTriangulationXY(verts); if (Perimeter != null) { faces.CullOutsideXY(Perimeter); } faces.Quadrangulate(); IList <MeshEdge> edges = faces.ExtractUniqueEdges(); foreach (MeshEdge mE in edges) { LinearElement lEl = Model.Create.LinearElement(mE.ToLine(), exInfo); lEl.Family = BeamSection; Beams.Add(lEl); } PanelBoundaries = faces.ExtractFaceBoundaries(); return(true); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Host.EnsureInitialisation(); LinearElementCollection elements = Core.Instance.ActiveDocument.Model.Elements.LinearElements; foreach (LinearElement lEl in elements) { if (!lEl.IsDeleted) { RhinoMeshAvatar mAv = new RhinoMeshAvatar(); ((IMeshAvatar)mAv).Builder.AddSectionPreview(lEl); ((IMeshAvatar)mAv).FinalizeMesh(); Guid guid = RhinoOutput.BakeMesh(mAv.RenderMesh); if (guid != Guid.Empty) { RhinoOutput.SetObjectName(guid, lEl.Name); if (lEl.Family != null) { RhinoOutput.SetObjectUserString(guid, "Family", lEl.Family.Name); if (lEl.Family.GetPrimaryMaterial() != null) { RhinoOutput.SetObjectUserString(guid, "Material", lEl.Family.GetPrimaryMaterial().Name); } if (lEl.Family.Profile != null) { RhinoOutput.SetObjectUserString(guid, "Profile", lEl.Family.Profile.ToString()); } } } } } Host.Instance.Refresh(); return(Result.Success); }
/// <summary> /// Write a Nucleus model to the currently open ETABS model /// </summary> /// <param name="model"></param> /// <param name="context"></param> /// <returns></returns> private bool WriteToETABS(Model.Model model, ETABSConversionContext context) { RaiseMessage("Writing data to ETABS..."); SapModel.File.NewBlank(); //TODO: check if updating //SapModel.File.NewSteelDeck(0, 12, 12, 0, 0, 24, 24); if (context.Options.Levels) { LevelCollection levels = model.Levels; // Seemingly can only write whole table at once - updating individuals may not be wise... if (levels.Count > 0) { RaiseMessage("Writing levels..."); WriteStoreys(levels, context); } } if (context.Options.Nodes) { NodeCollection nodes = model.Nodes; if (context.Options.Update) { nodes = nodes.Modified(context.Options.UpdateSince); } if (nodes.Count > 0) { RaiseMessage("Writing nodes..."); } WriteNodes(nodes, context); } if (context.Options.Families) { FamilyCollection families = model.Families; if (context.Options.Update) { families = families.Modified(context.Options.UpdateSince); } if (families.Count > 0) { RaiseMessage("Writing properties..."); } WriteFamilies(families, context); } if (context.Options.LinearElements) { LinearElementCollection linearElements = model.Elements.LinearElements; if (context.Options.Update) { linearElements = linearElements.Modified(context.Options.UpdateSince); } if (linearElements.Count > 0) { RaiseMessage("Writing linear elements..."); } WriteLinearElements(linearElements, context); } if (context.Options.PanelElements) { PanelElementCollection panelElements = model.Elements.PanelElements; if (context.Options.Update) { panelElements = panelElements.Modified(context.Options.UpdateSince); } if (panelElements.Count > 0) { RaiseMessage("Writing Panels..."); } WritePanelElements(panelElements, context); } if (context.Options.Sets) { ModelObjectSetCollection sets = model.Sets; //if (context.Options.Update) sets = //TODO? if (sets.Count > 0) { RaiseMessage("Writing Groups..."); } WriteSets(sets, context); } if (context.Options.Loading) { var cases = model.LoadCases; if (cases.Count > 0) { RaiseMessage("Writing Load Cases..."); } WriteLoadCases(cases, context); var loads = model.Loads; if (loads.Count > 0) { RaiseMessage("Writing Loads..."); } WriteLoads(loads, context); } return(true); }
public override bool Execute(ExecutionInfo exInfo = null) { TopChordElements = new LinearElementCollection(); BottomChordElements = new LinearElementCollection(); PostElements = new LinearElementCollection(); BracingElements = new LinearElementCollection(); if (TopChord != null && BottomChord != null) { int divisions; double maxLength = Math.Max(TopChord.Length, BottomChord.Length); if (NodeSpacing <= 0 || maxLength / NodeSpacing > 1000) { //Auto-determine appropriate node spacing Vector[] samplePointsT = TopChord.Divide(4); Vector[] samplePointsB = BottomChord.Divide(4); double tDist = 0; for (int i = 0; i < 5; i++) { tDist += samplePointsB[i].DistanceTo(samplePointsT[i]); } tDist /= 5; divisions = (int)(maxLength / tDist).Round(2); } else { divisions = (int)Math.Ceiling(maxLength / NodeSpacing); } if (divisions > 0) { Vector[] topPts = TopChord.Divide(divisions); Vector[] bottomPts = BottomChord.Divide(divisions); //foreach (Vector v in topPts) TopChordNodes.Add(Model.Create.Node(v, 0, exInfo)); //foreach (Vector v in bottomPts) BottomChordNodes.Add(Model.Create.Node(v, 0, exInfo)); for (int i = 0; i < topPts.Length - 1; i++) { //Node tNode0 = TopChordNodes[i]; //Node tNode1 = TopChordNodes[i + 1]; //Node bNode0 = BottomChordNodes[i]; //Node bNode1 = BottomChordNodes[i + 1]; Vector tNode0 = topPts[i]; Vector tNode1 = topPts[i + 1]; Vector bNode0 = bottomPts[i]; Vector bNode1 = bottomPts[i + 1]; TopChordElements.Add(Model.Create.LinearElement(tNode0, tNode1, ChordSection, exInfo)); BottomChordElements.Add(Model.Create.LinearElement(bNode0, bNode1, ChordSection, exInfo)); if (i > 0) { PostElements.Add(Model.Create.LinearElement(tNode0, bNode0, PostSection, exInfo)); } if (i < topPts.Length / 2) { BracingElements.Add(Model.Create.LinearElement(tNode0, bNode1, BracingSection, exInfo)); } else { BracingElements.Add(Model.Create.LinearElement(bNode0, tNode1, BracingSection, exInfo)); } } TopChordElements.GenerateNodes(new NodeGenerationParameters()); BottomChordElements.GenerateNodes(new NodeGenerationParameters()); PostElements.GenerateNodes(new NodeGenerationParameters()); BracingElements.GenerateNodes(new NodeGenerationParameters()); TopChordNodes = TopChordElements.GetNodes(); BottomChordNodes = BottomChordElements.GetNodes(); TopChordNodes.ClearAttachedData(); BottomChordNodes.ClearAttachedData(); } } return(true); }
public override bool Execute(ExecutionInfo exInfo = null) { var elements = new LinearElementCollection(); if (Struts != null) { elements.AddRange(Struts); } if (Ties != null) { elements.AddRange(Ties); } if (elements.Count > 0) { elements.ClearAttachedData(typeof(Spring)); var nodes = elements.GetNodes(); nodes.ClearAttachedData(typeof(Particle)); var motion = new KineticDampingComponent(nodes); //motion.SpeedLimit = SpeedLimit; var gravity = new ParticleGravityComponent(nodes); var springForces = new SpringForceComponent(elements); if (Struts != null) { foreach (var strut in Struts) { if (strut.HasData <Spring>()) { strut.GetData <Spring>().Compression = true; strut.GetData <Spring>().Tension = true; } } } //Set ties (temp): if (Ties != null) { foreach (var tie in Ties) { if (tie.HasData <Spring>()) { tie.GetData <Spring>().Compression = false; tie.GetData <Spring>().Tension = true; } } } var engine = new PhysicsEngine(); engine.Components.Add(gravity); engine.Components.Add(springForces); engine.Components.Add(motion); engine.Start(); for (int i = 0; i < Cycles; i++) { engine.Cycle(1.0); } // Outputs: StrutDeformation = new CurveCollection(); TieDeformation = new CurveCollection(); StrutForces = new List <double>(); TieForces = new List <double>(); if (Struts != null) { foreach (var lEl in Struts) { if (!lEl.IsDeleted) { StrutDeformation.Add( new Line( lEl.StartNode.GetData <Particle>().Position, lEl.EndNode.GetData <Particle>().Position)); StrutForces.Add( lEl.GetData <Spring>().AxialForce()); } } } if (Ties != null) { foreach (var lEl in Ties) { if (!lEl.IsDeleted) { TieDeformation.Add( new Line( lEl.StartNode.GetData <Particle>().Position, lEl.EndNode.GetData <Particle>().Position)); TieForces.Add( lEl.GetData <Spring>().AxialForce()); } } } } return(true); }
public override bool Execute(ExecutionInfo exInfo = null) { Columns = new LinearElementCollection(); PrimaryBeams = new LinearElementCollection(); SecondaryBeams = new LinearElementCollection(); int sCount = 0; if (SecondarySpacing > 0) { sCount = (int)Math.Ceiling(XSpacing / SecondarySpacing); } double z = FirstStoreyHeight; double zLast = 0; for (int i = 1; i <= StoreyCount; i++) { for (int j = 0; j < XCount; j++) { for (int k = 0; k < YCount; k++) { Vector pt00 = SetOut.LocalToGlobal((j - 1) * XSpacing, (k - 1) * YSpacing, z); Vector pt10 = SetOut.LocalToGlobal(j * XSpacing, (k - 1) * YSpacing, z); Vector pt01 = SetOut.LocalToGlobal((j - 1) * XSpacing, k * YSpacing, z); Vector pt11 = SetOut.LocalToGlobal(j * XSpacing, k * YSpacing, z); // Column: Columns.Add(Model.Create.LinearElement(pt11.WithZ(zLast), pt11, ColumnSection, exInfo)); if (j > 0) { // Primary beams: PrimaryBeams.Add(Model.Create.LinearElement(pt01, pt11, PrimaryBeamSection, exInfo)); } if (k > 0) { // Secondary beams: SecondaryBeams.Add(Model.Create.LinearElement(pt10, pt11, SecondaryBeamSection, exInfo)); if (j > 0 && sCount > 1) { for (int s = 1; s < sCount; s++) { SecondaryBeams.Add(Model.Create.LinearElement( pt00.Interpolate(pt10, ((double)s) / sCount), pt01.Interpolate(pt11, ((double)s) / sCount), SecondaryBeamSection, exInfo)); } } } //TODO: Intermediate secondaries } } zLast = z; z += StoreyHeight; } Columns.GenerateNodes(new NodeGenerationParameters()); PrimaryBeams.GenerateNodes(new NodeGenerationParameters()); SecondaryBeams.GenerateNodes(new NodeGenerationParameters()); return(true); }
public override bool Execute(ExecutionInfo exInfo = null) { Elements = Model.Elements.LinearElements; Elements.RemoveDeleted(); return(true); }