// Get Load direction in Local Coordinate frame protected Vector3 getLocalDir(LineElement line, LineLoad.LoadDirection direction) { Vector3 dir = Vector3.Empty; switch (direction) { case LineLoad.LoadDirection.GlobalX: dir = toLocal(line, CommonAxes.GlobalAxes[0]); break; case LineLoad.LoadDirection.GlobalY: dir = toLocal(line, CommonAxes.GlobalAxes[1]); break; case LineLoad.LoadDirection.GlobalZ: dir = toLocal(line, CommonAxes.GlobalAxes[2]); break; case LineLoad.LoadDirection.Gravity: dir = Vector3.Scale(toLocal(line, CommonAxes.GlobalAxes[2]), -1); break; case LineLoad.LoadDirection.Local1: dir = CommonAxes.GlobalAxes[0]; break; case LineLoad.LoadDirection.Local2: dir = CommonAxes.GlobalAxes[1]; break; case LineLoad.LoadDirection.Local3: dir = CommonAxes.GlobalAxes[2]; break; default: break; } return dir; }
public RFLineLoad(LineLoad load, List <RFLine> baselines, int loadcase) { LineList = load.LineList; Comment = load.Comment; ID = load.ID; IsValid = load.IsValid; No = load.No; Tag = load.Tag; DistanceA = load.DistanceA; DistanceB = load.DistanceB; if (load.RelativeDistances) { DistanceA /= 100; DistanceB /= 100; } Magnitude1 = load.Magnitude1 / 1000; Magnitude2 = load.Magnitude2; if (load.Distribution != LoadDistributionType.ConcentratedNxQType && load.Distribution != LoadDistributionType.Concentrated2x2QType) { Magnitude2 /= 1000; } Magnitude3 = load.Magnitude3 / 1000; LoadArray = load.LoadArray; OverTotalLength = load.OverTotalLength; RelativeDistances = load.RelativeDistances; LoadDirType = load.Direction; LoadDistType = load.Distribution; LoadRefType = load.ReferenceTo; LoadType = load.Type; LoadCase = loadcase; BaseLines = baselines; ToModify = false; ToDelete = false; }
protected override void PopulateDbRow(Element element, DataRow row) { LineLoad lineLoad = element as LineLoad; Utility.Assign(row, APIObjectList.ColumnRes("ColN_CST_LineLoadId"), APIObjectList.GetIdDbValue(lineLoad)); Utility.Assign(row, APIObjectList.ColumnRes("ColN_CST_BeamId"), APIObjectList.GetIdDbValue(lineLoad.HostElement)); }
private float addToMomentDiagram(LineLoad load, float dirComponent, float position, float lineLength) { if (load is ConcentratedSpanLoad) { float P = ((ConcentratedSpanLoad)load).L; float pDist = ((ConcentratedSpanLoad)load).D; if (position < (pDist * lineLength)) { return(P * dirComponent * (1f - pDist) * position); } else { return(P * dirComponent * pDist * (lineLength - position)); } } else if (load is DistributedSpanLoad) { DistributedSpanLoad dLoad = load as DistributedSpanLoad; //if (position >= 0) // return -(dLoad.La * dirComponent * position / 2f) * (lineLength - position); float a, b, c, Ra, W, xt; a = dLoad.Da * lineLength; b = dLoad.Db * lineLength - a; c = lineLength - a - b; W = (dLoad.La + dLoad.Lb) * b / 2f; xt = Math.Abs(dLoad.La + dLoad.Lb) > float.Epsilon ? b * (dLoad.La + 2f * dLoad.Lb) / (3 * (dLoad.La + dLoad.Lb)) : 0.0f; Ra = W / lineLength * (lineLength - (a + xt)); if (b == 0f) { return(0f); } else if (position < a) { return(Ra * position * dirComponent); } else if (position <= (a + b)) { float Wx, y, xt2, y1; y1 = (dLoad.Lb - dLoad.La) * (position - a) / b; y = dLoad.La + y1; xt2 = Math.Abs(dLoad.La + y) > float.Epsilon ? (position - a) / 3f * (dLoad.La + 2 * y) / (dLoad.La + y) : 0.0f; Wx = (dLoad.La + y) * (position - a) / 2f; return((Ra * position - Wx * (position - a - xt2)) * dirComponent); } else { return((Ra * position - W * (position - a - xt)) * dirComponent); } } return(0f); }
public FactorLineLoadDialog(SlopeDefineCanvas canvas, LineLoad load) { InitializeComponent(); this.canvas = canvas; this.load = load; // get units dependent scaling factor and strings double factor; string coordUnits, loadUnits; switch (canvas.Units) { case Units.Metres: factor = 0.0254; coordUnits = "m"; loadUnits = "kN/m"; break; case Units.Millimetres: factor = 25.4; coordUnits = "mm"; loadUnits = "kN/m"; break; case Units.Feet: factor = 1.0 / 12.0; coordUnits = "ft"; loadUnits = "lbf/ft"; break; default: factor = 1.0; coordUnits = "in"; loadUnits = "lbf/ft"; break; } // set units labels node1Units.Content = coordUnits; node2Units.Content = coordUnits; nLoad1Units.Content = loadUnits; nLoad2Units.Content = loadUnits; tLoad1Units.Content = loadUnits; tLoad2Units.Content = loadUnits; // set node coordinates double xCoord, yCoord; xCoord = (load.Nodes[0].Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale; yCoord = (canvas.ActualHeight - load.Nodes[0].Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale; coords1.Content = string.Format("({0}, {1})", Math.Round(xCoord, 2), Math.Round(yCoord, 2)); xCoord = (load.Nodes[1].Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale; yCoord = (canvas.ActualHeight - load.Nodes[1].Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale; coords2.Content = string.Format("({0}, {1})", Math.Round(xCoord, 2), Math.Round(yCoord, 2)); // set existing load values (if present) MaterialBlock parent = canvas.Substructs.Find(delegate(MaterialBlock mb) { return(mb.Material.Name != "NULL" && mb.LineLoads.Contains(load)); }); isLoadedN.IsEnabled = parent != null && load.IsLoadedN; isLoadedN.IsChecked = nFactor.IsEnabled = parent != null && load.IsActiveN; nFactor.Text = string.Format("{0}", Math.Round(load.NFactor, 3)); nLoad1.Text = string.Format("{0}", Math.Round(load.NLoad1, 2)); nLoad2.Text = string.Format("{0}", Math.Round(load.NLoad2, 2)); isLoadedT.IsEnabled = parent != null && load.IsLoadedT; isLoadedT.IsChecked = tFactor.IsEnabled = parent != null && load.IsActiveT; tFactor.Text = string.Format("{0}", Math.Round(load.TFactor, 3)); tLoad1.Text = string.Format("{0}", Math.Round(load.TLoad1, 2)); tLoad2.Text = string.Format("{0}", Math.Round(load.TLoad2, 2)); }
public AddLineLoadDialog(SlopeCanvas canvas, LineLoad load) { InitializeComponent(); this.canvas = canvas; this.load = load; // get units dependent scaling factor and strings double factor; string coordUnits, loadUnits; switch (canvas.Units) { case Units.Metres: factor = 0.0254; coordUnits = "m"; loadUnits = "kN/m"; break; case Units.Millimetres: factor = 25.4; coordUnits = "mm"; loadUnits = "kN/m"; break; case Units.Feet: factor = 1.0 / 12.0; coordUnits = "ft"; loadUnits = "lbf/ft"; break; default: factor = 1.0; coordUnits = "in"; loadUnits = "lbf/ft"; break; } // set units labels node1Units.Content = coordUnits; node2Units.Content = coordUnits; nLoad1Units.Content = loadUnits; nLoad2Units.Content = loadUnits; tLoad1Units.Content = loadUnits; tLoad2Units.Content = loadUnits; // set node coordinates double xCoord, yCoord; xCoord = (load.Nodes[0].Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale; yCoord = (canvas.ActualHeight - load.Nodes[0].Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale; coords1.Content = string.Format("({0}, {1})", Math.Round(xCoord, 2), Math.Round(yCoord, 2)); xCoord = (load.Nodes[1].Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale; yCoord = (canvas.ActualHeight - load.Nodes[1].Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale; coords2.Content = string.Format("({0}, {1})", Math.Round(xCoord, 2), Math.Round(yCoord, 2)); // set existing load values (if present) isLoadedN.IsChecked = nLoad1.IsEnabled = nLoad2.IsEnabled = load.IsLoadedN; nLoad1.Text = string.Format("{0}", Math.Round(load.NLoad1, 2)); nLoad2.Text = string.Format("{0}", Math.Round(load.NLoad2, 2)); isLoadedT.IsChecked = tLoad1.IsEnabled = tLoad2.IsEnabled = load.IsLoadedT; tLoad1.Text = string.Format("{0}", Math.Round(load.TLoad1, 2)); tLoad2.Text = string.Format("{0}", Math.Round(load.TLoad2, 2)); }
private float[] requestXCtrlPts(LineLoad load) { float[] controlPoints = new float[2]; if (load is ConcentratedSpanLoad) { controlPoints[0] = ((ConcentratedSpanLoad)load).D - 0.00001f; controlPoints[1] = controlPoints[0] + 0.00002f; } else if (load is DistributedSpanLoad) { controlPoints[0] = ((DistributedSpanLoad)load).Da; controlPoints[1] = ((DistributedSpanLoad)load).Db; } return(controlPoints); }
private float addUniformForceDeflection(LineLoad load, float x, float lineLength, ref float angle, float a, float b, float c, float W, float w, float RA, float c1, float c3, float c5, float c6) { float flecha = 0.0f; if (x < a) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f + c1 * x; angle = RA * x * x / 2f + c1; } else if (x >= a && x <= a + b) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f - w * (float)Math.Pow(x - a, 4) / 24.0f + c3 * x; angle = RA * x * x / 2f - w * (float)Math.Pow(x - a, 3) / 6.0f + c3; } else if (x > a + b) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f - W * (float)Math.Pow(x - a - b / 2.0f, 3) / 6.0f + c5 * x + c6; angle = RA * x * x / 2f - W * (float)Math.Pow(x - a - b / 2.0f, 2) / 2f + c5; } return(flecha); }
private float addTriangularForceDeflection(LineLoad load, float lineLength, float x, ref float angle, float RA, float a, float b, float q, float c1, float c2, float d1, float d2, float e1, float e2) { float flecha = 0.0f; if (x < a) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f + c1 * x + c2; angle = RA * x * x / 2f + c1; } else if (x >= a && x <= a + b) { flecha = b > float.Epsilon ? RA * (float)Math.Pow(x, 3) / 6.0f - q * (float)Math.Pow(x - a, 5) / (120.0f * b) + d1 * x + d2 : 0.0f; angle = b > float.Epsilon ? RA * x * x / 2f - q * (float)Math.Pow(x - a, 4) / (24f * b) + d1 : 0.0f; } else if (x > a + b) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f - q * b * (float)Math.Pow(x - (a + 2.0f * b / 3.0f), 3) / 12.0f + e1 * x + e2; angle = RA * x * x / 2f - q * b * (float)Math.Pow(x - (a + 2f * b / 3f), 2) / 4f + e1; } return(flecha); }
/// <summary> /// /// </summary> /// <param name="app"></param> /// <param name="element"></param> /// <returns></returns> public static Revit.Element CloneElement(Application app, Revit.Element element) { Opening opening = element as Opening; if (opening != null) { return(CloneElement(app, opening)); } BoundaryConditions boundaryConditions = element as BoundaryConditions; if (boundaryConditions != null) { return(CloneElement(app, boundaryConditions)); } AreaLoad areaLoad = element as AreaLoad; if (areaLoad != null) { return(CloneElement(app, areaLoad)); } AreaReinforcement areaReinforcement = element as AreaReinforcement; if (areaReinforcement != null) { return(CloneElement(app, areaReinforcement)); } BeamSystem beamSystem = element as BeamSystem; if (beamSystem != null) { return(CloneElement(app, beamSystem)); } Dimension dimension = element as Dimension; if (dimension != null) { return(CloneElement(app, dimension)); } FamilyInstance familyInstance = element as FamilyInstance; if (familyInstance != null) { return(CloneElement(app, familyInstance)); } Floor floor = element as Floor; if (floor != null) { return(CloneElement(app, floor)); } Grid grid = element as Grid; if (grid != null) { return(CloneElement(app, grid)); } Group group = element as Group; if (group != null) { return(CloneElement(app, group)); } Level level = element as Level; if (floor != null) { return(CloneElement(app, floor)); } LineLoad lineLoad = element as LineLoad; if (lineLoad != null) { return(CloneElement(app, lineLoad)); } LoadCase loadCase = element as LoadCase; if (loadCase != null) { return(CloneElement(app, loadCase)); } LoadCombination loadCombination = element as LoadCombination; if (loadCombination != null) { return(CloneElement(app, loadCombination)); } LoadNature loadNature = element as LoadNature; if (loadNature != null) { return(CloneElement(app, loadNature)); } LoadUsage loadUsage = element as LoadUsage; if (loadUsage != null) { return(CloneElement(app, loadUsage)); } ModelCurve modelCurve = element as ModelCurve; if (modelCurve != null) { return(CloneElement(app, modelCurve)); } PointLoad pointLoad = element as PointLoad; if (pointLoad != null) { return(CloneElement(app, pointLoad)); } Rebar rebar = element as Rebar; if (rebar != null) { return(CloneElement(app, rebar)); } ReferencePlane referencePlane = element as ReferencePlane; if (referencePlane != null) { return(CloneElement(app, referencePlane)); } Room room = element as Room; if (room != null) { return(CloneElement(app, room)); } RoomTag roomTag = element as RoomTag; if (roomTag != null) { return(CloneElement(app, roomTag)); } SketchPlane sketchPlane = element as SketchPlane; if (sketchPlane != null) { return(CloneElement(app, sketchPlane)); } View3D view3D = element as View3D; if (view3D != null) { return(CloneElement(app, view3D)); } ViewDrafting viewDrafting = element as ViewDrafting; if (viewDrafting != null) { return(CloneElement(app, viewDrafting)); } ViewSection viewSection = element as ViewSection; if (viewSection != null) { return(CloneElement(app, viewSection)); } ViewSheet viewSheet = element as ViewSheet; if (viewSheet != null) { return(CloneElement(app, viewSheet)); } Wall wall = element as Wall; if (wall != null) { return(CloneElement(app, wall)); } // this element has not yet been exposed in the Creation Document class //Debug.Assert(false); return(null); }
private void Stream( ArrayList data, LineLoad lineload ) { data.Add( new Snoop.Data.ClassSeparator( typeof( LineLoad ) ) ); data.Add( new Snoop.Data.Bool( "Projected load", lineload.IsProjected ) ); data.Add( new Snoop.Data.Bool( "Uniform load", lineload.IsUniform ) ); data.Add( new Snoop.Data.Xyz( "Start point", lineload.StartPoint ) ); data.Add( new Snoop.Data.Xyz( "End point", lineload.EndPoint ) ); data.Add( new Snoop.Data.Xyz( "Force 1", lineload.ForceVector1 ) ); data.Add( new Snoop.Data.Xyz( "Force 2", lineload.ForceVector2 ) ); data.Add( new Snoop.Data.Xyz( "Moment 1", lineload.MomentVector1 ) ); data.Add( new Snoop.Data.Xyz( "Moment 2", lineload.MomentVector2 ) ); }
public static List <SpeckleObject> ToSpeckle(this LineLoad myLineLoad) { var myLoad = new Structural1DLoadLine { Name = myLineLoad.Name }; var points = myLineLoad.GetCurve().Tessellate(); myLoad.Value = new List <double>(); foreach (var p in points) { myLoad.Value.Add(p.X / Scale); myLoad.Value.Add(p.Y / Scale); myLoad.Value.Add(p.Z / Scale); } var forces = new StructuralVectorSix(new double[6]); forces.Value[0] = (myLineLoad.ForceVector1.X + myLineLoad.ForceVector2.X) / 2; forces.Value[1] = (myLineLoad.ForceVector1.Y + myLineLoad.ForceVector2.Y) / 2; forces.Value[2] = (myLineLoad.ForceVector1.Z + myLineLoad.ForceVector2.Z) / 2; forces.Value[3] = (myLineLoad.MomentVector1.X + myLineLoad.MomentVector2.X) / 2; forces.Value[4] = (myLineLoad.MomentVector1.Y + myLineLoad.MomentVector2.Y) / 2; forces.Value[5] = (myLineLoad.MomentVector1.Z + myLineLoad.MomentVector2.Z) / 2; if (myLineLoad.OrientTo == LoadOrientTo.HostLocalCoordinateSystem) { var hostTransform = myLineLoad.HostElement.GetLocalCoordinateSystem(); var b0 = hostTransform.get_Basis(0); var b1 = hostTransform.get_Basis(1); var b2 = hostTransform.get_Basis(2); var fx = forces.Value[0] * b0.X + forces.Value[1] * b1.X + forces.Value[2] * b2.X; var fy = forces.Value[0] * b0.Y + forces.Value[1] * b1.Y + forces.Value[2] * b2.Y; var fz = forces.Value[0] * b0.Z + forces.Value[1] * b1.Z + forces.Value[2] * b2.Z; var mx = forces.Value[3] * b0.X + forces.Value[4] * b1.X + forces.Value[5] * b2.X; var my = forces.Value[3] * b0.Y + forces.Value[4] * b1.Y + forces.Value[5] * b2.Y; var mz = forces.Value[3] * b0.Z + forces.Value[4] * b1.Z + forces.Value[5] * b2.Z; forces = new StructuralVectorSix(new double[] { fx, fy, fz, mx, my, mz }); } else if (myLineLoad.OrientTo == LoadOrientTo.WorkPlane) { var workPlane = ((SketchPlane)Doc.GetElement(myLineLoad.WorkPlaneId)).GetPlane(); var b0 = workPlane.XVec; var b1 = workPlane.YVec; var b2 = workPlane.Normal; var fx = forces.Value[0] * b0.X + forces.Value[1] * b1.X + forces.Value[2] * b2.X; var fy = forces.Value[0] * b0.Y + forces.Value[1] * b1.Y + forces.Value[2] * b2.Y; var fz = forces.Value[0] * b0.Z + forces.Value[1] * b1.Z + forces.Value[2] * b2.Z; var mx = forces.Value[3] * b0.X + forces.Value[4] * b1.X + forces.Value[5] * b2.X; var my = forces.Value[3] * b0.Y + forces.Value[4] * b1.Y + forces.Value[5] * b2.Y; var mz = forces.Value[3] * b0.Z + forces.Value[4] * b1.Z + forces.Value[5] * b2.Z; forces = new StructuralVectorSix(new double[] { fx, fy, fz, mx, my, mz }); } myLoad.Loading = forces; var myLoadCase = new StructuralLoadCase { Name = myLineLoad.LoadCaseName, ApplicationId = myLineLoad.LoadCase.UniqueId }; switch (myLineLoad.LoadCategoryName) { case "Dead Loads": myLoadCase.CaseType = StructuralLoadCaseType.Dead; break; case "Live Loads": myLoadCase.CaseType = StructuralLoadCaseType.Live; break; case "Seismic Loads": myLoadCase.CaseType = StructuralLoadCaseType.Earthquake; break; case "Snow Loads": myLoadCase.CaseType = StructuralLoadCaseType.Snow; break; case "Wind Loads": myLoadCase.CaseType = StructuralLoadCaseType.Wind; break; default: myLoadCase.CaseType = StructuralLoadCaseType.Generic; break; } myLoad.LoadCaseRef = myLoadCase.ApplicationId; myLoad.ApplicationId = myLineLoad.UniqueId; return(new List <SpeckleObject>() { myLoad, myLoadCase }); }
private float addToShearDiagram(LineLoad load, float dirComponent, float position, float lineLength) { if (load is ConcentratedSpanLoad) { float P = ((ConcentratedSpanLoad)load).L; float pDist = ((ConcentratedSpanLoad)load).D; if (position < (pDist * lineLength)) { return((P * dirComponent) / lineLength * position); } else { return(-(P * dirComponent) / lineLength * (lineLength - position)); } } else if (load is DistributedSpanLoad) { DistributedSpanLoad dLoad = load as DistributedSpanLoad; //return 0f; float a, b, c, Ra, W, xt; a = dLoad.Da * lineLength; b = dLoad.Db * lineLength - a; c = lineLength - a - b; if (b == 0) { return(0f); } else if (position >= a && position <= (a + b)) { W = (dLoad.La + dLoad.Lb) * b / 2f; xt = Math.Abs(dLoad.La + dLoad.Lb) > float.Epsilon ? b * (dLoad.La + 2f * dLoad.Lb) / (3 * (dLoad.La + dLoad.Lb)) : 0.0f; Ra = W / lineLength * (lineLength - (a + xt)); ///////////////////////////////////////// // Shear in a float shear_a = Ra; ///////////////////////////////////////// ///////////////////////////////////////// // Shear in a + b float Wx_b, shear_b; Wx_b = (dLoad.La + dLoad.La + dLoad.Lb - dLoad.La) * b / 2f; shear_b = Ra - Wx_b; ///////////////////////////////////////// ///////////////////////////////////////// // Line between a --- b float originalLine = (position - a) / b * ((shear_b - shear_a)) + shear_a; ///////////////////////////////////////// float Wx, y, xt2, y1; y1 = (dLoad.Lb - dLoad.La) * (position - a) / b; y = dLoad.La + y1; xt2 = Math.Abs(dLoad.La + y) > float.Epsilon ? (position - a) / 3f * (dLoad.La + 2 * y) / (dLoad.La + y) : 0.0f; Wx = (dLoad.La + y) * (position - a) / 2f; return((Ra - Wx - originalLine) * dirComponent); //return dirComponent * dLoad.La * (position - a) + dLoad.La * (dLoad.Db - dLoad.Da) * position; } } return(0f); }
private float addTriangularForceDeflection(LineLoad load, float lineLength, float x, ref float angle, float RA, float a, float b, float q, float c1, float c2, float d1, float d2, float e1, float e2) { float flecha = 0.0f; if (x < a) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f + c1 * x + c2; angle = RA * x * x / 2f + c1; } else if (x >= a && x <= a + b) { flecha = b > float.Epsilon ? RA * (float)Math.Pow(x, 3) / 6.0f - q * (float)Math.Pow(x - a, 5) / (120.0f * b) + d1 * x + d2 : 0.0f; angle = b > float.Epsilon ? RA * x * x / 2f - q * (float)Math.Pow(x - a, 4) / (24f * b) + d1 : 0.0f; } else if (x > a + b) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f - q * b * (float)Math.Pow(x - (a + 2.0f * b / 3.0f), 3) / 12.0f + e1 * x + e2; angle = RA * x * x / 2f - q * b * (float)Math.Pow(x - (a + 2f * b / 3f), 2) / 4f + e1; } return flecha; }
private float addUniformForceDeflection(LineLoad load, float x, float lineLength, ref float angle, float a, float b, float c, float W, float w, float RA, float c1, float c3, float c5, float c6) { float flecha = 0.0f; if (x < a) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f + c1 * x; angle = RA * x * x / 2f + c1; } else if (x >= a && x <= a + b) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f - w * (float)Math.Pow(x - a, 4) / 24.0f + c3 * x; angle = RA * x * x / 2f - w * (float)Math.Pow(x - a, 3) / 6.0f + c3; } else if (x > a + b) { flecha = RA * (float)Math.Pow(x, 3) / 6.0f - W * (float)Math.Pow(x - a - b / 2.0f, 3) / 6.0f + c5 * x + c6; angle = RA * x * x / 2f - W * (float)Math.Pow(x - a - b / 2.0f, 2) / 2f + c5; } return flecha; }
private float[] requestXCtrlPts(LineLoad load) { float[] controlPoints = new float[2]; if (load is ConcentratedSpanLoad) { controlPoints[0] = ((ConcentratedSpanLoad)load).D - 0.00001f; controlPoints[1] = controlPoints[0] + 0.00002f; } else if (load is DistributedSpanLoad) { controlPoints[0] = ((DistributedSpanLoad)load).Da; controlPoints[1] = ((DistributedSpanLoad)load).Db; } return controlPoints; }
private float addToShearDiagram(LineLoad load, float dirComponent, float position, float lineLength) { if (load is ConcentratedSpanLoad) { float P = ((ConcentratedSpanLoad)load).L; float pDist = ((ConcentratedSpanLoad)load).D; if (position < (pDist * lineLength)) return (P * dirComponent) / lineLength * position; else return -(P * dirComponent) / lineLength * (lineLength - position); } else if (load is DistributedSpanLoad) { DistributedSpanLoad dLoad = load as DistributedSpanLoad; //return 0f; float a, b, c, Ra, W, xt; a = dLoad.Da * lineLength; b = dLoad.Db * lineLength - a; c = lineLength - a - b; if (b == 0) return 0f; else if (position >= a && position <= (a + b)) { W = (dLoad.La + dLoad.Lb) * b / 2f; xt = Math.Abs(dLoad.La + dLoad.Lb) > float.Epsilon ? b * (dLoad.La + 2f * dLoad.Lb) / (3 * (dLoad.La + dLoad.Lb)) : 0.0f; Ra = W / lineLength * (lineLength - (a + xt)); ///////////////////////////////////////// // Shear in a float shear_a = Ra; ///////////////////////////////////////// ///////////////////////////////////////// // Shear in a + b float Wx_b, shear_b; Wx_b = (dLoad.La + dLoad.La + dLoad.Lb - dLoad.La) * b / 2f; shear_b = Ra - Wx_b; ///////////////////////////////////////// ///////////////////////////////////////// // Line between a --- b float originalLine = (position - a) / b * ((shear_b - shear_a)) + shear_a; ///////////////////////////////////////// float Wx, y, xt2, y1; y1 = (dLoad.Lb - dLoad.La) * (position - a) / b; y = dLoad.La + y1; xt2 = Math.Abs(dLoad.La + y) > float.Epsilon ? (position - a) / 3f * (dLoad.La + 2 * y) / (dLoad.La + y) : 0.0f; Wx = (dLoad.La + y) * (position - a) / 2f; return (Ra - Wx - originalLine) * dirComponent; //return dirComponent * dLoad.La * (position - a) + dLoad.La * (dLoad.Db - dLoad.Da) * position; } } return 0f; }
private float addToMomentDiagram(LineLoad load, float dirComponent, float position, float lineLength) { if (load is ConcentratedSpanLoad) { float P = ((ConcentratedSpanLoad)load).L; float pDist = ((ConcentratedSpanLoad)load).D; if (position < (pDist * lineLength)) return P * dirComponent * (1f - pDist) * position; else return P * dirComponent * pDist * (lineLength - position); } else if (load is DistributedSpanLoad) { DistributedSpanLoad dLoad = load as DistributedSpanLoad; //if (position >= 0) // return -(dLoad.La * dirComponent * position / 2f) * (lineLength - position); float a, b, c, Ra, W, xt; a = dLoad.Da * lineLength; b = dLoad.Db * lineLength - a; c = lineLength - a - b; W = (dLoad.La + dLoad.Lb) * b / 2f; xt = Math.Abs(dLoad.La + dLoad.Lb) > float.Epsilon ? b * (dLoad.La + 2f * dLoad.Lb) / (3 * (dLoad.La + dLoad.Lb)) : 0.0f; Ra = W / lineLength * (lineLength - (a + xt)); if (b == 0f) return 0f; else if (position < a) { return Ra * position * dirComponent; } else if (position <= (a + b)) { float Wx, y, xt2, y1; y1 = (dLoad.Lb - dLoad.La) * (position - a) / b; y = dLoad.La + y1; xt2 = Math.Abs(dLoad.La + y) > float.Epsilon ? (position - a) / 3f * (dLoad.La + 2 * y) / (dLoad.La + y) : 0.0f; Wx = (dLoad.La + y) * (position - a) / 2f; return (Ra * position - Wx * (position - a - xt2)) * dirComponent; } else { return (Ra * position - W * (position - a - xt)) * dirComponent; } } return 0f; }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { Debug.Assert(false, "This has not been tested since Revit 2010!"); UIApplication app = commandData.Application; Document doc = app.ActiveUIDocument.Document; Autodesk.Revit.Creation.Application ca = app.Application.Create; Autodesk.Revit.Creation.Document cd = doc.Create; // determine line load symbol to use: FilteredElementCollector symbols = new FilteredElementCollector(doc); symbols.OfClass(typeof(LineLoadType)); LineLoadType loadSymbol = symbols.FirstElement() as LineLoadType; // sketch plane and arrays of forces and moments: //Plane plane = ca.NewPlane( XYZ.BasisZ, XYZ.Zero ); // 2016 Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero); // 2017 using (Transaction t = new Transaction(doc)) { t.Start("Create New Line Load"); //SketchPlane skplane = cd.NewSketchPlane( plane ); // 2013 SketchPlane skplane = SketchPlane.Create(doc, plane); // 2014 XYZ forceA = new XYZ(0, 0, 5); XYZ forceB = new XYZ(0, 0, 10); List <XYZ> forces = new List <XYZ>(); forces.Add(forceA); forces.Add(forceB); XYZ momentA = new XYZ(0, 0, 0); XYZ momentB = new XYZ(0, 0, 0); List <XYZ> moments = new List <XYZ>(); moments.Add(momentA); moments.Add(momentB); BuiltInCategory bic = BuiltInCategory.OST_StructuralFraming; FilteredElementCollector beams = Util.GetElementsOfType( doc, typeof(FamilyInstance), bic); XYZ p1 = new XYZ(0, 0, 0); XYZ p2 = new XYZ(3, 0, 0); //List<XYZ> points = new List<XYZ>(); //points.Add( p1 ); //points.Add( p2 ); // create a new unhosted line load on points: //LineLoad lineLoadNoHost = cd.NewLineLoad( // points, forces, moments, // false, false, false, // loadSymbol, skplane ); // 2015 LineLoad lineLoadNoHost = LineLoad.Create(doc, p1, p2, forces[0], moments[0], loadSymbol, skplane); // 2016 Debug.Print("Unhosted line load works."); // create new line loads on beam: foreach (Element e in beams) { try { //LineLoad lineLoad = cd.NewLineLoad( // e, forces, moments, // false, false, false, // loadSymbol, skplane ); // 2015 AnalyticalModelSurface amsurf = e.GetAnalyticalModel() as AnalyticalModelSurface; LineLoad lineLoad = LineLoad.Create(doc, amsurf, 0, forces[0], moments[0], loadSymbol); // 2016 Debug.Print("Hosted line load on beam works."); } catch (Exception ex) { Debug.Print("Hosted line load on beam fails: " + ex.Message); } FamilyInstance i = e as FamilyInstance; AnalyticalModel am = i.GetAnalyticalModel(); foreach (Curve curve in am.GetCurves(AnalyticalCurveType.ActiveCurves)) { try { //LineLoad lineLoad = cd.NewLineLoad( // curve.Reference, forces, moments, // false, false, false, // loadSymbol, skplane ); // 2015 AnalyticalModelStick amstick = e.GetAnalyticalModel() as AnalyticalModelStick; LineLoad lineLoad = LineLoad.Create(doc, amstick, forces[0], moments[0], loadSymbol); // 2016 Debug.Print("Hosted line load on " + "AnalyticalModelFrame curve works."); } catch (Exception ex) { Debug.Print("Hosted line load on " + "AnalyticalModelFrame curve fails: " + ex.Message); } } } t.Commit(); } return(Result.Succeeded); }
/// <summary> /// Gets substruct (material block data) from file /// </summary> public void LoadSubstructData() { if (!File.Exists(FilePath)) { MessageBox.Show("Could not find input data file.", "Error"); return; } // get canvas dimensions/properties double originX = OriginOffsetX, originY = OriginOffsetY, scale = Scale, yHeight = ActualHeight; Units units = Units; // get units dependent scaling factor double factor; switch (units) { case Units.Metres: factor = 0.0254; break; case Units.Millimetres: factor = 25.4; break; case Units.Feet: factor = 1.0 / 12.0; break; default: factor = 1.0; break; } // Load material blocks from source canvas substructs = new List <MaterialBlock>(); using (TextReader tr = new StreamReader(FilePath)) { // advance to material block data while (!tr.ReadLine().Contains("MATERIAL BLOCK DATA")) { ; } tr.ReadLine(); tr.ReadLine(); int numMaterialBlocks = int.Parse(tr.ReadLine().Split('=')[1]); tr.ReadLine(); if (numMaterialBlocks > 0) { MaterialBlock block; MaterialType mtl; DrawingPoint p1, p2; LineConstraint newLC, existingLC; LineLoad newLL, existingLL; PointLoad newPL, existingPL; Point[] materialBoundPoints; bool[] isFixedX; bool[] isFixedY; bool[] isPrintPoint; string materialName; int numMaterialBoundPoints, numLineConstraints, numLineLoads, numPointLoads; double xCoord, yCoord; string[] coords, lineConstraint, lineLoad, pointLoad; for (int i = 0; i < numMaterialBlocks; i++) { tr.ReadLine(); materialName = tr.ReadLine().Split(new char[] { '\"' }, StringSplitOptions.RemoveEmptyEntries)[1]; mtl = materialTypes.Find(delegate(MaterialType mt) { return(mt.Name == materialName); }); numMaterialBoundPoints = int.Parse(tr.ReadLine().Split('=')[1]); materialBoundPoints = new Point[numMaterialBoundPoints]; isFixedX = new bool[numMaterialBoundPoints]; isFixedY = new bool[numMaterialBoundPoints]; isPrintPoint = new bool[numMaterialBoundPoints]; for (int j = 0; j < numMaterialBoundPoints; j++) { coords = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); xCoord = double.Parse(coords[0]); yCoord = double.Parse(coords[1]); materialBoundPoints[j].X = xCoord / (factor * Scale) * dpiX + OriginOffsetX; materialBoundPoints[j].Y = ActualHeight - (yCoord / (factor * Scale) * dpiY + OriginOffsetY); isFixedX[j] = coords[2] == bool.TrueString; isFixedY[j] = coords[3] == bool.TrueString; isPrintPoint[j] = coords[4] == bool.TrueString; } block = new MaterialBlock(this, mtl, materialBoundPoints); for (int j = 0; j < numMaterialBoundPoints; j++) { block.BoundaryPoints[j].IsFixedX = isFixedX[j]; block.BoundaryPoints[j].IsFixedY = isFixedY[j]; block.BoundaryPoints[j].IsPrintPoint = isPrintPoint[j]; } substructs.Add(block); numLineConstraints = int.Parse(tr.ReadLine().Split('=')[1]); for (int j = 0; j < numLineConstraints; j++) { lineConstraint = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); p1 = block.BoundaryPoints[int.Parse(lineConstraint[0])]; p2 = block.BoundaryPoints[int.Parse(lineConstraint[1])]; existingLC = null; foreach (MaterialBlock mb in substructs) { existingLC = mb.LineConstraints.Find(delegate(LineConstraint lc) { return(lc.Nodes.Contains(p1) && lc.Nodes.Contains(p2)); }); if (existingLC != null) { break; } } if (existingLC == null) { newLC = new LineConstraint(this, p1, p2, //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] , //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] , lineConstraint[2] == bool.TrueString, lineConstraint[3] == bool.TrueString); } else { block.LineConstraints.Add(existingLC); } //newLC = new LineConstraint( this , // block.BoundaryPoints[int.Parse( lineConstraint[0] )] , // block.BoundaryPoints[int.Parse( lineConstraint[1] )] , // lineConstraint[2] == bool.TrueString , // lineConstraint[3] == bool.TrueString ); //existingLC = null; //foreach ( MaterialBlock mb in substructs ) //{ // existingLC = mb.LineConstraints.Find( // delegate( LineConstraint lc ) // { // return lc.Nodes.Contains( newLC.Nodes[0] ) && lc.Nodes.Contains( newLC.Nodes[1] ); // } ); // if ( existingLC != null ) break; //} //if ( existingLC != null ) //{ // if ( !block.LineConstraints.Contains( existingLC ) ) // block.LineConstraints.Add( existingLC ); //} //else block.LineConstraints.Add( newLC ); } numLineLoads = int.Parse(tr.ReadLine().Split('=')[1]); for (int j = 0; j < numLineLoads; j++) { lineLoad = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); p1 = block.BoundaryPoints[int.Parse(lineLoad[0])]; p2 = block.BoundaryPoints[int.Parse(lineLoad[1])]; existingLL = null; foreach (MaterialBlock mb in substructs) { existingLL = mb.LineLoads.Find(delegate(LineLoad ll) { return(ll.Nodes.Contains(p1) && ll.Nodes.Contains(p2)); }); if (existingLL != null) { break; } } if (existingLL == null) { newLL = new LineLoad(this, p1, p2, //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] , //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] , lineLoad[2] == bool.TrueString, double.Parse(lineLoad[3]), double.Parse(lineLoad[4]), lineLoad[5] == bool.TrueString, double.Parse(lineLoad[6]), double.Parse(lineLoad[7])); } else { block.LineLoads.Add(existingLL); } //block.LineLoads.Add( new LineLoad( this , // block.BoundaryPoints[int.Parse( lineLoad[0] )] , // block.BoundaryPoints[int.Parse( lineLoad[1] )] , // lineLoad[2] == bool.TrueString , double.Parse( lineLoad[3] ) , double.Parse( lineLoad[4] ) , // lineLoad[5] == bool.TrueString , double.Parse( lineLoad[6] ) , double.Parse( lineLoad[7] ) ) ); } numPointLoads = int.Parse(tr.ReadLine().Split('=')[1]); for (int j = 0; j < numPointLoads; j++) { pointLoad = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); p1 = block.BoundaryPoints[int.Parse(pointLoad[0])]; existingPL = null; foreach (MaterialBlock mb in substructs) { existingPL = mb.PointLoads.Find(delegate(PointLoad pl) { return(pl.Node == p1); }); if (existingPL != null) { break; } } if (existingPL == null) { newPL = new PointLoad(this, p1, //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] , //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] , pointLoad[1] == bool.TrueString, double.Parse(pointLoad[2]), pointLoad[3] == bool.TrueString, double.Parse(pointLoad[4])); } else { block.PointLoads.Add(existingPL); } //block.PointLoads.Add( new PointLoad( this , // block.BoundaryPoints[int.Parse( pointLoad[0] )] , // pointLoad[1] == bool.TrueString , double.Parse( pointLoad[2] ) , // pointLoad[3] == bool.TrueString , double.Parse( pointLoad[4] ) ) ); } tr.ReadLine(); } } } // Set selected analysis phase to first (if present) if (source.AnalysisPhases.Count > 1) { ComboBox phaseList = (ComboBox)((Grid)((GroupBox)((Grid)((ScrollViewer)((Grid)this.Parent).Children[2]).Content).Children[1]).Content).Children[1]; AnalysisPhase initial = source.AnalysisPhases[1]; phaseList.SelectedItem = initial; } }