protected override void TrySolveInstance(IGH_DataAccess DA) { Autodesk.Revit.DB.Element element = null; if (!DA.GetData("Element", ref element)) { return; } DA.SetData("Category", element?.Category); DA.SetData("Type", element?.Document.GetElement(element.GetTypeId())); DA.SetData("Name", element?.Name); }
void TrySolveInstance ( IGH_DataAccess DA, Autodesk.Revit.DB.Document doc, ref Autodesk.Revit.DB.Element element ) { var type = GetType(); var ReconstructInfo = type.GetMethod($"Reconstruct{type.Name}", BindingFlags.Instance | BindingFlags.NonPublic); var parameters = ReconstructInfo.GetParameters(); var arguments = new object[parameters.Length]; try { arguments[0] = doc; arguments[1] = element; var args = new object[] { DA, null, null }; foreach (var parameter in parameters) { var paramIndex = parameter.Position - 2; if (paramIndex < 0) { continue; } args[1] = paramIndex; try { switch (Params.Input[paramIndex].Access) { case GH_ParamAccess.item: GetInputDataInfo.MakeGenericMethod(parameter.ParameterType).Invoke(this, args); break; case GH_ParamAccess.list: GetInputDataListInfo.MakeGenericMethod(parameter.ParameterType.GetGenericArguments()[0]).Invoke(this, args); break; default: throw new NotImplementedException(); } } catch (TargetInvocationException e) { throw e.InnerException; } finally { arguments[parameter.Position] = args[2]; args[2] = null; } } ReconstructInfo.Invoke(this, arguments); } catch (TargetInvocationException e) { throw e.InnerException; } finally { element = (Autodesk.Revit.DB.Element)arguments[1]; } }