public static int Remove(BHoMAdapter adapter, object request = null, ActionConfig actionConfig = null, bool active = false) { if (!active) { return(0); } IRequest actualRequest = null; if (!adapter.SetupRemoveRequest(request, out actualRequest)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(request)}` input."); return(0); } ActionConfig removeConfig = null; if (!adapter.SetupRemoveConfig(actionConfig, out removeConfig)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(actionConfig)}` input."); return(0); } return(adapter.Remove(actualRequest, removeConfig)); }
public static Output <List <object>, bool> Push(BHoMAdapter adapter, IEnumerable <object> objects, string tag = "", PushType pushType = PushType.AdapterDefault, ActionConfig actionConfig = null, bool active = false) { var noOutput = BH.Engine.Reflection.Create.Output(new List <object>(), false); if (!active) { return(noOutput); } ActionConfig pushConfig = null; if (!adapter.SetupPushConfig(actionConfig, out pushConfig)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(actionConfig)}` input."); return(noOutput); } PushType pt = pushType; if (!adapter.SetupPushType(pushType, out pt)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(pushType)}` input."); return(noOutput); } List <object> result = adapter.Push(objects, tag, pt, pushConfig); return(BH.Engine.Reflection.Create.Output(result, objects?.Count() == result?.Count())); }
public static IEnumerable <object> Pull(BHoMAdapter adapter, object request = null, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null, bool active = false) { if (!active) { return(new List <object>()); } IRequest actualRequest = null; if (!adapter.SetupPullRequest(request, out actualRequest)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(request)}` input."); return(null); } ActionConfig pullConfig = null; if (!adapter.SetupPullConfig(actionConfig, out pullConfig)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(actionConfig)}` input."); return(null); } return(adapter.Pull(actualRequest, pullType, pullConfig)); }
public static Output <List <object>, bool> Execute(BHoMAdapter adapter, IExecuteCommand command, ActionConfig actionConfig = null, bool active = false) { Output <List <object>, bool> result = new Output <List <object>, bool>() { Item1 = null, Item2 = false }; if (!active) { return(result); } ActionConfig executeConfig = null; if (!adapter.SetupExecuteConfig(actionConfig, out executeConfig)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(actionConfig)}` input."); return(result); } result = adapter.Execute(command, executeConfig); // Item1 is the result of the Execute; Item2 the `success` bool. return(result != null ? result : new Output <List <object>, bool>() { Item1 = null, Item2 = false }); }
/*************************************/ /**** Override Method ****/ /*************************************/ public override object Run(List <object> inputs) { if (inputs.Count > 0) { BHoMAdapter adapter = inputs[0] as BHoMAdapter; Guid id = adapter.AdapterGuid; if (id != m_AdapterId) { m_AdapterId = id; adapter.DataUpdated += (sender, e) => ExpireSolution(); } } return(base.Run(inputs)); }
public static List <List <double> > St7GetNodeResults(BHoMAdapter st7Adapter, List <int> caseIds, St7NodeResultsTypes resultType, St7NodeResultComponent component, List <Node> nodes, bool active = false) { List <List <double> > results = new List <List <double> >(); if (!active) { return(results); } int err; // checking node ids double[] nodeResArray = new double[6]; foreach (Node node in nodes) { int UCSid = 1; int nodeId = st7Adapter.GetAdapterId <int>(node); if (node.Support != null) { UCSid = st7Adapter.GetAdapterId <int>(node.Support); } var interResults = new List <double>(); foreach (int loadcaseId in caseIds) { err = St7.St7GetNodeResultUCS(1, (int)resultType, UCSid, nodeId, loadcaseId, nodeResArray); if (component == St7NodeResultComponent.All) { interResults.AddRange(nodeResArray); } else { interResults.Add(nodeResArray[(int)component]); } } results.Add(interResults); } return(results); }
public static bool Move(BHoMAdapter source, BHoMAdapter target, object request = null, PullType pullType = PullType.AdapterDefault, ActionConfig pullConfig = null, PushType pushType = PushType.AdapterDefault, ActionConfig pushConfig = null, bool active = false) { if (!active) { return(false); } IRequest actualRequest = null; if (!source.SetupPullRequest(request, out actualRequest)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(request)}` input."); return(false); } ActionConfig pullCfg = null; if (!source.SetupPullConfig(pullConfig, out pullCfg)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(pullConfig)}` input."); return(false); } ActionConfig pushCfg = null; if (!source.SetupPushConfig(pushConfig, out pushCfg)) { BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(pushConfig)}` input."); return(false); } return(source.Move(target, actualRequest, pullType, pullCfg, pushType, pushCfg)); }
public static BeamResults St7GetBeamResults(BHoMAdapter st7Adapter, List <int> caseIds, St7ResultForceComponent component, St7BeamResultsTypes resultType = St7BeamResultsTypes.BeamForce, St7BeamResultAxis resultAxis = St7BeamResultAxis.Principal, int minStations = 1, List <Bar> beams = null, bool active = false) { if (!active) { return(null); } int err; int uID = 1; List <int> beamIds = new List <int>(); // checking node ids if (beams == null || beams.Count == 0) { int beamCount = 0; err = St7.St7GetTotal(1, St7.tyBEAM, ref beamCount); if (!St7Error(err)) { return(null); } beamIds = Enumerable.Range(1, beamCount).ToList(); } else { beamIds = beams.Select(bar => st7Adapter.GetAdapterId <int>(bar)).ToList(); } List <List <double> > positionResults = new List <List <double> >(); List <List <double> > valuesResults = new List <List <double> >(); List <List <int> > numberStations = new List <List <int> >(); List <List <int> > resultsPerStation = new List <List <int> >(); // output from strand 7 double[] beamPos = new double[St7.kMaxBeamResult]; double[] beamResult = new double[St7.kMaxBeamResult]; int numStations = 0; int numColumns = 0; foreach (int beamId in beamIds) { List <double> interPosResults = new List <double>(); List <double> interValues = new List <double>(); List <int> interStations = new List <int>(); List <int> interResPerStation = new List <int>(); foreach (int loadcaseId in caseIds) { err = St7.St7GetBeamResultArray(uID, (int)resultType, (int)resultAxis, beamId, minStations, loadcaseId, ref numStations, ref numColumns, beamPos, beamResult); interPosResults.AddRange(beamPos.Take(numStations)); interStations.Add(numStations); if (component == St7ResultForceComponent.All) { interResPerStation.Add(numColumns); } else { interResPerStation.Add(1); } if (component == St7ResultForceComponent.All) { interValues.AddRange(beamResult.Take(numStations * numColumns)); } else { for (int i = 0; i < numStations; i++) { interValues.Add(beamResult[(int)component + i * numColumns]); } } } numberStations.Add(interStations); positionResults.Add(interPosResults); valuesResults.Add(interValues); resultsPerStation.Add(interResPerStation); } return(new BeamResults(true, positionResults, valuesResults, numberStations, resultsPerStation)); }
public static BeamResults St7GetBeamResultsAtT(BHoMAdapter st7Adapter, List <int> caseIds, List <Bar> beams, List <double> t_params, St7ResultForceComponent component, St7BeamResultsTypes resultType = St7BeamResultsTypes.BeamForce, St7BeamResultAxis resultAxis = St7BeamResultAxis.Principal, bool active = false) { if (!active) { return(null); } int err; int uID = 1; err = St7.St7SetBeamResultPosMode(uID, St7.bpParam); List <List <double> > valuesResults = new List <List <double> >(); List <List <int> > resultsPerStation = new List <List <int> >(); // output from strand 7 double[] beamResult = new double[St7.kMaxBeamResult]; int numStations = 1; int numColumns = 0; for (int i = 0; i < beams.Count; i++) { Bar beam = beams[i]; double[] beamPos; if (i > t_params.Count - 1) { beamPos = new double[] { t_params[t_params.Count - 1] }; } else { beamPos = new double[] { t_params[i] } }; int beamId = st7Adapter.GetAdapterId <int>(beam); List <double> interValues = new List <double>(); List <int> interResPerStation = new List <int>(); foreach (int loadcaseId in caseIds) { err = St7.St7GetBeamResultArrayPos(uID, (int)resultType, (int)resultAxis, beamId, loadcaseId, numStations, beamPos, ref numColumns, beamResult); if (component == St7ResultForceComponent.All) { interResPerStation.Add(numColumns); } else { interResPerStation.Add(1); } if (component == St7ResultForceComponent.All) { interValues.AddRange(beamResult.Take(numStations * numColumns)); } else { for (int j = 0; j < numStations; j++) { interValues.Add(beamResult[(int)component + j * numColumns]); } } } valuesResults.Add(interValues); resultsPerStation.Add(interResPerStation); } return(new BeamResults(true, new List <List <double> >(), valuesResults, new List <List <int> >(), resultsPerStation)); }