public void generateNodes(IRobotStructure str, Node[] nodes) { for (int i = 0; i < nodes.Length; i++) { str.Nodes.Create(nodes[i].id, nodes[i].xCoord, nodes[i].yCoord, nodes[i].zCoord); } }
public void generateBars(IRobotStructure str, Bar[] bars) { for (int i = 0; i < bars.Length; i++) { str.Bars.Create(bars[i].id, bars[i].startNode.id, bars[i].endNode.id); } }
public RobotLabels() { Structure structure = new Structure(); str = structure.getStructure(); labels = str.Labels; }
private double _windz = 0.0; //the wind vector /// <summary> /// Create the Robot model from scratch. /// </summary> /// <param name="_nodeInfo">A List of node objects.</param> /// <param name="_barInfo">A List of bar objects.</param> public RobotModel(IRobotApplication robot, IEnumerable <AnalyticalNode> nodeInfo, IEnumerable <AnalyticalBar> barInfo, IEnumerable <AnalyticalPlate> plateInfo) { robot.Project.New(RobotOM.IRobotProjectType.I_PT_SHELL); _project = robot.Project; if (_project == null) { throw new Exception("The robot project could not be initialized."); } //create the structure and the node and bar servers _structure = _project.Structure; _nodes = _structure.Nodes; _bars = _structure.Bars; _objects = _structure.Objects; List <int> forWindLoads = new List <int>(); List <int> forLiveLoads = new List <int>(); List <int> forBuildingLoads = new List <int>(); List <int> forDeadLoadsBars = new List <int>(); List <int> forDeadLoadsSlabs = new List <int>(); double windLoad = 0.0; double liveLoad = 0.0; double buildingLoad = 0.0; double fatManLoad = 300 * 4.45; //300lbs. -> Newton IRobotSimpleCase ll; IRobotSimpleCase dl; IRobotSimpleCase bl; IRobotSimpleCase wl; CreateLoadCases(out ll, out dl, out wl, out bl); CreateLoads(ll, dl, wl, bl); CreateBarEndRelease(_barInfo); CreateNodes(); CreateBars(forDeadLoadsBars); #region plates CreatePlates(liveLoad, forLiveLoads, windLoad, forWindLoads, buildingLoad, forBuildingLoads, forDeadLoadsSlabs, ll, wl, bl, fatManLoad, dl, forDeadLoadsBars); #endregion }
public Structure(int frames, double spam, double heigth, double offset) { //Parsing the main parameters this.numberOfFrames = frames; this.frameSpam = spam; this.frameHeigth = heigth; this.frameOffset = offset; //Start application robApp = RobotController.getRobot(); //Create a project RobotProjectController.createProject(robApp); //Create a structure str = robApp.Project.Structure; }
static void Main(string[] args) { Console.WriteLine("Starting Robot application..."); //Cria um novo objeto da aplicação Robot IRobotApplication robApp = new RobotApplicationClass(); //Se a aplicaçao não estiver visivel, torna o robot visivel para permitir iteracao if (robApp.Visible == 0) { robApp.Interactive = 1; robApp.Visible = 1; } Console.WriteLine("Creating concrete project..."); //Cria o projeto da viga de concreto robApp.Project.New(IRobotProjectType.I_PT_SHELL); Console.WriteLine("Executing project settings..."); //Configuracao das preferencias RobotProjectPreferences projectPrefs = robApp.Project.Preferences; //Configuracoes do codigo de verificacao da estrutura de concreto projectPrefs.SetActiveCode(IRobotCodeType.I_CT_RC_THEORETICAL_REINF, "BAEL 91"); //Configuracao das preferencias de malha RobotMeshParams meshParams = projectPrefs.MeshParams; meshParams.SurfaceParams.Method.Method = IRobotMeshMethodType.I_MMT_DELAUNAY; meshParams.SurfaceParams.Generation.Type = IRobotMeshGenerationType.I_MGT_ELEMENT_SIZE; meshParams.SurfaceParams.Generation.ElementSize = 0.5; meshParams.SurfaceParams.Delaunay.Type = IRobotMeshDelaunayType.I_MDT_DELAUNAY; //Geração da estrutura Console.WriteLine("Generating structure"); IRobotStructure str = robApp.Project.Structure; Console.WriteLine("Generating nodes..."); str.Nodes.Create(1, 0, 0, 0); str.Nodes.Create(2, 3, 0, 0); str.Nodes.Create(3, 3, 3, 0); str.Nodes.Create(4, 0, 3, 0); str.Nodes.Create(5, 0, 0, 4); str.Nodes.Create(6, 3, 0, 4); str.Nodes.Create(7, 3, 3, 4); str.Nodes.Create(8, 0, 3, 4); str.Bars.Create(1, 1, 5); str.Bars.Create(2, 2, 6); str.Bars.Create(3, 3, 7); str.Bars.Create(4, 4, 8); str.Bars.Create(5, 5, 6); str.Bars.Create(6, 7, 8); Console.WriteLine("Generating labels..."); RobotLabelServer labels = str.Labels; string columnSectionName = "Rect. Column 30*30"; IRobotLabel label = labels.Create(IRobotLabelType.I_LT_BAR_SECTION, columnSectionName); RobotBarSectionData section = (RobotBarSectionData)label.Data; section.ShapeType = IRobotBarSectionShapeType.I_BSST_CONCR_COL_R; RobotBarSectionConcreteData concrete = (RobotBarSectionConcreteData)section.Concrete; concrete.SetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_B, 0.3); concrete.SetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_H, 0.3); section.CalcNonstdGeometry(); labels.Store(label); Console.WriteLine("Defining sections..."); RobotSelection selectionBars = str.Selections.Get(IRobotObjectType.I_OT_BAR); selectionBars.FromText("1 2 3 4"); str.Bars.SetLabel(selectionBars, IRobotLabelType.I_LT_BAR_SECTION, columnSectionName); RobotSectionDatabaseList steelSections = projectPrefs.SectionsActive; if (steelSections.Add("RCAT") == 1) { Console.WriteLine("Warning! Steel section base RCAT not found..."); } selectionBars.FromText("5 6"); label = labels.Create(IRobotLabelType.I_LT_BAR_SECTION, "HEA 340"); str.Labels.Store(label); str.Bars.SetLabel(selectionBars, IRobotLabelType.I_LT_BAR_SECTION, "HEA 340"); Console.WriteLine("Defining materials..."); string materialName = "Concrete 30"; label = labels.Create(IRobotLabelType.I_LT_MATERIAL, materialName); RobotMaterialData material = (RobotMaterialData)label.Data; material.Type = IRobotMaterialType.I_MT_CONCRETE; material.E = 3E+09; material.NU = 1 / 6; material.RO = 25000; material.Kirchoff = material.E / (2 * (1 + material.NU)); Console.WriteLine("Generating slab..."); RobotPointsArray points = (RobotPointsArray)robApp.CmpntFactory.Create(IRobotComponentType.I_CT_POINTS_ARRAY); points.SetSize(5); points.Set(1, 0, 0, 4); points.Set(2, 3, 0, 4); points.Set(3, 3, 3, 4); points.Set(4, 0, 3, 4); points.Set(5, 0, 0, 4); string slabSectionName = "Slab 30"; label = labels.Create(IRobotLabelType.I_LT_PANEL_THICKNESS, slabSectionName); RobotThicknessData thickness = (RobotThicknessData)label.Data; thickness.MaterialName = materialName; thickness.ThicknessType = IRobotThicknessType.I_TT_HOMOGENEOUS; RobotThicknessHomoData thicknessData = (RobotThicknessHomoData)thickness.Data; thicknessData.ThickConst = 0.3; labels.Store(label); RobotObjObject slab; int objNumber = str.Objects.FreeNumber; str.Objects.CreateContour(objNumber, points); slab = (RobotObjObject)str.Objects.Get(objNumber); slab.Main.Attribs.Meshed = 1; slab.SetLabel(IRobotLabelType.I_LT_PANEL_THICKNESS, slabSectionName); slab.Initialize(); Console.WriteLine("Adding hole in the slab..."); points.Set(1, 1.1, 1.1, 4); points.Set(2, 2.5, 1.1, 4); RobotObjObject hole; Console.ReadLine(); }
private static void CalcReinforcement(RobotApplication robApp, int objNumber, RobotLabelServer labels, RobotObjObject slab, IRobotStructure str) { IRobotLabel label; var concrCalcEngine = robApp.Project.ConcrReinfEngine; var concrSlabRequiredReinfEngine = concrCalcEngine.SlabRequiredReinf; var slabRnfParams = concrSlabRequiredReinfEngine.Params; slabRnfParams.Method = IRobotReinforceCalcMethods.I_RCM_WOOD_ARMER; slabRnfParams.GloballyAvgDesginForces = false; slabRnfParams.ForcesReduction = false; slabRnfParams.DisplayErrors = false; slabRnfParams.CasesULS.FromText("1 2 3 4 5 6 7 8"); var slabs = slabRnfParams.Panels; slabs.FromText(System.Convert.ToString(objNumber)); var slabReinforcementName = "Slab X"; label = labels.Create(IRobotLabelType.I_LT_PANEL_REINFORCEMENT, slabReinforcementName); labels.Store(label); slab.SetLabel(IRobotLabelType.I_LT_PANEL_REINFORCEMENT, slabReinforcementName); slab.Update(); Console.WriteLine(!concrSlabRequiredReinfEngine.Calculate() ? "Calculation Failed!" : "Done!"); //getting results My and Yz for beam (bar 5) with live load (case 2) var txt = "Bar 5, Live at 0.5 length:" + "\n\r" + " My = " + str.Results.Bars.Forces.Value(5, 2, 0.5).MY / 1000 + " [kN*m]" + "\n\r" + " Qz = " + -str.Results.Bars.Deflections.Value(5, 2, 0.5).UZ * 1000 + " [mm]" + "\n\r" + " Fz1 = " + str.Results.Bars.Forces.Value(5, 2, 0).FZ / 1000 + " [kN]" + "\n\r" + " Fz2 = " + str.Results.Bars.Forces.Value(5, 2, 1).FZ / 1000 + " [kN]" + "\n\r"; //getting results Fx and Fy for column (bar 4) with wind load (case 3) txt += "Bar 4, Wind:" + "\n\r" + " Fx = " + str.Results.Bars.Forces.Value(4, 3, 1).FX / 1000 + " [kN]" + "\n\r" + " Fy = " + str.Results.Bars.Forces.Value(4, 3, 1).FY / 1000 + " [kN]" + "\n\r"; //getting results Fx, Fy, Fz, Mx, My, Mz for foot (node 1) with self-weight (case 1) txt += "Node 1, Self-Weight:" + "\n\r" + " Fx = " + str.Results.Nodes.Reactions.Value(1, 1).FX / 1000 + " [kN]" + "\n\r" + " Fy = " + str.Results.Nodes.Reactions.Value(1, 1).FY / 1000 + " [kN]" + "\n\r" + " Fz = " + str.Results.Nodes.Reactions.Value(1, 1).FZ / 1000 + " [kN]" + "\n\r" + " Mx = " + str.Results.Nodes.Reactions.Value(1, 1).MX / 1000 + " [kN]" + "\n\r" + " My = " + str.Results.Nodes.Reactions.Value(1, 1).MY / 1000 + " [kN]" + "\n\r" + " Mz = " + str.Results.Nodes.Reactions.Value(1, 1).MZ / 1000 + " [kN]" + "\n\r"; //getting results Ax+, Ax-, Ay+, Ay- for slab var selectionFe = str.Selections.Get(IRobotObjectType.I_OT_FINITE_ELEMENT); selectionFe.FromText(slab.FiniteElems); var objFEs = (RobotLabelCollection)str.FiniteElems.GetMany(selectionFe); double a; a = 0; double axP = 0; double axM = 0; double ayP = 0; double ayM = 0; var finiteElementNodes = new List <RobotFiniteElement>(); for (var n = 1; n <= objFEs.Count; n++) { var fe = (RobotFiniteElement)objFEs.Get(n); finiteElementNodes.Add(fe); a = str.Results.FiniteElems.Reinforcement(slab.Number, fe.Number).AX_BOTTOM; if (a > axM) { axM = a; } a = str.Results.FiniteElems.Reinforcement(slab.Number, fe.Number).AX_TOP; if (a > axP) { axP = a; } a = str.Results.FiniteElems.Reinforcement(slab.Number, fe.Number).AY_BOTTOM; if (a > ayM) { ayM = a; } a = str.Results.FiniteElems.Reinforcement(slab.Number, fe.Number).AY_TOP; if (a > ayP) { ayP = a; } } //getting results Fx, Fy, Fz, Mx, My, Mz for foot (node 1) with self-weight (case 1) txt += "Slab 1, Reinforcemet extreme values:" + "\n\r" + " Ax+ = " + axP * 10000 + " [cm2]" + "\n\r" + " Ax- = " + axM * 10000 + " [cm2]" + "\n\r" + " Ay+ = " + ayP * 10000 + " [cm2]" + "\n\r" + " Ay- = " + ayM * 10000 + " [cm2]" + "\n\r"; foreach (var fe in finiteElementNodes) { var nodes = fe.Nodes; Console.WriteLine( $"{fe.Number} - {Enumerable.Range(0, nodes.Count).Aggregate("", (x, y) => $"{x} {nodes.Get(y)}")}"); } Console.WriteLine(txt); }
private static void FromTutorial() { var robApp = new RobotApplication(); if (robApp.Visible == 0) { robApp.Interactive = 1; robApp.Visible = 1; } robApp.Project.New(IRobotProjectType.I_PT_SHELL); var projectPrefs = robApp.Project.Preferences; projectPrefs.SetActiveCode(IRobotCodeType.I_CT_RC_THEORETICAL_REINF, "BAEL 91"); var meshParams = projectPrefs.MeshParams; meshParams.SurfaceParams.Method.Method = IRobotMeshMethodType.I_MMT_DELAUNAY; meshParams.SurfaceParams.Generation.Type = IRobotMeshGenerationType.I_MGT_ELEMENT_SIZE; meshParams.SurfaceParams.Generation.ElementSize = 0.5; meshParams.SurfaceParams.Delaunay.Type = IRobotMeshDelaunayType.I_MDT_DELAUNAY; IRobotStructure str = robApp.Project.Structure; str.Nodes.Create(1, 0, 0, 0); str.Nodes.Create(2, 3, 0, 0); str.Nodes.Create(3, 3, 3, 0); str.Nodes.Create(4, 0, 3, 0); str.Nodes.Create(5, 0, 0, 4); str.Nodes.Create(6, 3, 0, 4); str.Nodes.Create(7, 3, 3, 4); str.Nodes.Create(8, 0, 3, 4); str.Bars.Create(1, 1, 5); str.Bars.Create(2, 2, 6); str.Bars.Create(3, 3, 7); str.Bars.Create(4, 4, 8); str.Bars.Create(5, 5, 6); str.Bars.Create(6, 7, 8); var labels = str.Labels; var columnSectionName = "Rect. Column 30*30"; var label = labels.Create(IRobotLabelType.I_LT_BAR_SECTION, columnSectionName); var section = (RobotBarSectionData)label.Data; section.ShapeType = IRobotBarSectionShapeType.I_BSST_CONCR_COL_R; var concrete = (RobotBarSectionConcreteData)section.Concrete; concrete.SetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_B, 0.3); concrete.SetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_H, 0.3); section.CalcNonstdGeometry(); labels.Store(label); var selectionBars = str.Selections.Get(IRobotObjectType.I_OT_BAR); selectionBars.FromText("1 2 3 4"); str.Bars.SetLabel(selectionBars, IRobotLabelType.I_LT_BAR_SECTION, columnSectionName); var steelSections = projectPrefs.SectionsActive; if (steelSections.Add("RCAT") == 1) { Console.WriteLine("Steel section base RCAT not found..."); } selectionBars.FromText("5 6"); label = labels.Create(IRobotLabelType.I_LT_BAR_SECTION, "HEA 340"); str.Labels.Store(label); str.Bars.SetLabel(selectionBars, IRobotLabelType.I_LT_BAR_SECTION, "HEA 340"); var materialName = "Concrete 30"; label = labels.Create(IRobotLabelType.I_LT_MATERIAL, materialName); var material = (RobotMaterialData)label.Data; material.Type = IRobotMaterialType.I_MT_CONCRETE; material.E = 30000000000; // Young material.NU = 1 / (double)6; // Poisson material.RO = 25000; // Unit weight material.Kirchoff = material.E / (2 * (1 + material.NU)); str.Labels.Store(label); var points = (RobotPointsArray)robApp.CmpntFactory.Create(IRobotComponentType.I_CT_POINTS_ARRAY); points.SetSize(5); points.Set(1, 0, 0, 4); points.Set(2, 3, 0, 4); points.Set(3, 3, 3, 4); points.Set(4, 0, 3, 4); points.Set(5, 0, 0, 4); var slabSectionName = "Slab 30"; label = labels.Create(IRobotLabelType.I_LT_PANEL_THICKNESS, slabSectionName); var thickness = (RobotThicknessData)label.Data; thickness.MaterialName = materialName; thickness.ThicknessType = IRobotThicknessType.I_TT_HOMOGENEOUS; var thicknessData = (RobotThicknessHomoData)thickness.Data; thicknessData.ThickConst = 0.3; labels.Store(label); var objNumber = str.Objects.FreeNumber; str.Objects.CreateContour(objNumber, points); var slab = (RobotObjObject)str.Objects.Get(objNumber); slab.Main.Attribs.Meshed = 1; slab.SetLabel(IRobotLabelType.I_LT_PANEL_THICKNESS, slabSectionName); slab.Initialize(); points.Set(1, 1.1, 1.1, 4); points.Set(2, 2.5, 1.1, 4); points.Set(3, 2.5, 2.5, 4); points.Set(4, 1.1, 2.5, 4); points.Set(5, 1.1, 1.1, 4); var holeNumber = str.Objects.FreeNumber; str.Objects.CreateContour(holeNumber, points); var hole = (RobotObjObject)str.Objects.Get(holeNumber); hole.Main.Attribs.Meshed = 0; hole.Initialize(); var footName = "Foot"; label = labels.Create(IRobotLabelType.I_LT_SUPPORT, footName); var footData = (RobotNodeSupportData)label.Data; footData.UX = 1; footData.UY = 1; footData.UZ = 1; footData.KZ = 80000000; footData.RX = 1; footData.RY = 1; footData.RZ = 1; labels.Store(label); var selectionNodes = str.Selections.Get(IRobotObjectType.I_OT_NODE); selectionNodes.FromText("1 2 3 4"); str.Nodes.SetLabel(selectionNodes, IRobotLabelType.I_LT_SUPPORT, footName); //self weight on entire structure var caseSw = str.Cases.CreateSimple(1, "SW", IRobotCaseNature.I_CN_PERMANENT, IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR); caseSw.Records.New(IRobotLoadRecordType.I_LRT_DEAD); var loadRecord = (RobotLoadRecord)caseSw.Records.Get(1); loadRecord.SetValue(System.Convert.ToInt16(IRobotDeadRecordValues.I_DRV_Z), -1); loadRecord.SetValue(System.Convert.ToInt16(IRobotDeadRecordValues.I_DRV_ENTIRE_STRUCTURE), 0); //contour live load on the slab var caseLive = str.Cases.CreateSimple(2, "Live", IRobotCaseNature.I_CN_EXPLOATATION, IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR); var uniform = caseLive.Records.New(IRobotLoadRecordType.I_LRT_UNIFORM); loadRecord = (RobotLoadRecord)caseLive.Records.Get(uniform); loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PX), 0); loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PY), 0); loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PZ), -10000); //apply created load to the slab loadRecord.Objects.FromText(System.Convert.ToString(objNumber)); //linear wind load on the beam var caseWind = str.Cases.CreateSimple(3, "Wind", IRobotCaseNature.I_CN_WIND, IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR); uniform = caseWind.Records.New(IRobotLoadRecordType.I_LRT_BAR_UNIFORM); loadRecord = (RobotLoadRecord)caseWind.Records.Get(uniform); loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PX), 0); loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PY), 1000); loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PZ), 0); //apply created load to the beam loadRecord.Objects.FromText("5"); var calcEngine = robApp.Project.CalcEngine; calcEngine.GenerationParams.GenerateNodes_BarsAndFiniteElems = true; calcEngine.UseStatusWindow = true; if (calcEngine.Calculate() == 1) { Console.WriteLine("Calculation Failed!"); } else { Console.WriteLine("Done!"); } calcEngine = null; //CalcReinforcement(robApp, objNumber, labels, slab, str); }
private double _windz = 0.0; //the wind vector #endregion Fields #region Constructors /// <summary> /// Create the Robot model from scratch. /// </summary> /// <param name="_nodeInfo">A List of node objects.</param> /// <param name="_barInfo">A List of bar objects.</param> public RobotModel(IRobotApplication robot, IEnumerable<AnalyticalNode> nodeInfo, IEnumerable<AnalyticalBar> barInfo, IEnumerable<AnalyticalPlate> plateInfo) { robot.Project.New(RobotOM.IRobotProjectType.I_PT_SHELL); _project = robot.Project; if (_project == null) throw new Exception("The robot project could not be initialized."); //create the structure and the node and bar servers _structure = _project.Structure; _nodes = _structure.Nodes; _bars = _structure.Bars; _objects = _structure.Objects; List<int> forWindLoads = new List<int>(); List<int> forLiveLoads = new List<int>(); List<int> forBuildingLoads = new List<int>(); List<int> forDeadLoadsBars = new List<int>(); List<int> forDeadLoadsSlabs = new List<int>(); double windLoad = 0.0; double liveLoad = 0.0; double buildingLoad = 0.0; double fatManLoad = 300 * 4.45; //300lbs. -> Newton IRobotSimpleCase ll; IRobotSimpleCase dl; IRobotSimpleCase bl; IRobotSimpleCase wl; CreateLoadCases(out ll, out dl, out wl, out bl); CreateLoads(ll,dl, wl, bl); CreateBarEndRelease(_barInfo); CreateNodes(); CreateBars(forDeadLoadsBars); #region plates CreatePlates(liveLoad, forLiveLoads, windLoad, forWindLoads, buildingLoad, forBuildingLoads, forDeadLoadsSlabs, ll, wl, bl, fatManLoad, dl, forDeadLoadsBars); #endregion }
public void DoCommand(int cmd_id) { IRobotStructure structure = robot_app.Project.Structure; // Get bars and nodes IRobotCollection bars = structure.Bars.GetAll(); IRobotCollection nodes = structure.Nodes.GetAll(); // Create 3D points at nodes var points = new Dictionary <int, Point3D>(); for (int i = 1; i <= nodes.Count; i++) { var node = (IRobotNode)nodes.Get(i); points[i] = new Point3D(node.X, node.Y, node.Z); } // Create 3D vectors for each bar and index of bars connected to a node var vectors = new Dictionary <int, Vector3D>(); var vect_by_pt = new DefaultDict <int, List <Vector3D> >(); for (int i = 1; i <= bars.Count; i++) { var bar = (IRobotBar)bars.Get(i); var start_pt = points[bar.StartNode]; var end_pt = points[bar.EndNode]; vectors[i] = end_pt - start_pt; vect_by_pt[bar.StartNode].Add(vectors[i]); vect_by_pt[bar.EndNode].Add(vectors[i]); } ; foreach (KeyValuePair <int, Vector3D> vector in vectors) { // `u` is the vector corresponding to the bar Vector3D u = vector.Value; UnitVector3D u_norm = u.Normalize(); int start = bars.Get(vector.Key).StartNode; // TODO: How about the other end? // Find the most orthogonal vector `v` Vector3D most_orth_v = u; double cur_min = 1; foreach (Vector3D x in vect_by_pt[start]) { UnitVector3D x_norm = x.Normalize(); double dot_prod = Math.Abs(u_norm.DotProduct(x_norm)); if (dot_prod < cur_min) { most_orth_v = x; cur_min = dot_prod; } } if (cur_min > 0.95) { continue; } var v = most_orth_v; var v_norm = v.Normalize(); // Vector `a` is vector a orthogonal to `u` in (u,v) plane Vector3D a = v - u_norm.DotProduct(v) * u; UnitVector3D a_norm = a.Normalize(); // Vector `c` is orthogonal to `u` in the global (X,Y) plane UnitVector3D c = u_norm.CrossProduct(UnitVector3D.ZAxis); // Vector `d` is orthogonal to `c` and `u` UnitVector3D d = c.CrossProduct(u_norm); // Calculate the angles of `a` with `d` and `c` Angle theta1 = a.AngleTo(d); Angle theta2 = a.AngleTo(c); // Calculate gamma from `theta1` and `theta2` Angle gamma = (theta2.Degrees < 90) ? theta1 : -theta1; double gamma_up = (gamma.Degrees < 0) ? gamma.Degrees + 90 : gamma.Degrees - 90; // Set `Gamma` attribute of bar IRobotBar bar = bars.Get(vector.Key); bar.Gamma = gamma_up; } // Redraw all views robot_app.Project.ViewMngr.Refresh(); }