public static IBHoMObject SetTag(this IBHoMObject bHoMObject, string tag) { if (bHoMObject == null) { return(null); } IBHoMObject obj = bHoMObject.ShallowClone(); if (obj.Tags == null) { obj.Tags = new HashSet <string>(); } obj.Tags.Add(tag); return(obj); }
public static IBHoMObject SetRevitParameters(this IBHoMObject bHoMObject, List <string> paramNames, List <object> values) { if (bHoMObject == null) { return(null); } if (paramNames.Count != values.Count) { BH.Engine.Reflection.Compute.RecordError("Number of input names needs to be equal to the number of input values. Parameters have not been set."); return(bHoMObject); } List <RevitParameter> parameters = paramNames.Zip(values, (x, y) => new RevitParameter { Name = x, Value = y }).ToList(); RevitParametersToPush existingFragment = bHoMObject.Fragments.FirstOrDefault(x => x is RevitParametersToPush) as RevitParametersToPush; if (existingFragment != null) { foreach (RevitParameter parameter in existingFragment.Parameters) { if (paramNames.All(x => parameter.Name != x)) { parameters.Add(parameter); } } } RevitParametersToPush fragment = new RevitParametersToPush { Parameters = parameters }; IBHoMObject obj = bHoMObject.ShallowClone(); obj.Fragments = new FragmentSet(bHoMObject.Fragments.Where(x => !(x is RevitParametersToPush)).ToList()); obj.Fragments.Add(fragment); return(obj); }
public static IBHoMObject RemoveIdentifiers(this IBHoMObject bHoMObject) { if (bHoMObject == null) { return(null); } if (bHoMObject.Fragments == null) { return(bHoMObject); } if (bHoMObject.Fragments.Any(x => x is RevitIdentifiers)) { IBHoMObject obj = bHoMObject.ShallowClone(); obj.Fragments = new FragmentSet(bHoMObject.Fragments.Where(x => !(x is RevitIdentifiers)).ToList()); return(obj); } else { return(bHoMObject); } }
public static IBHoMObject SetRevitParameter(this IBHoMObject bHoMObject, string paramName, object value) { if (bHoMObject == null) { return(null); } List <RevitParameter> parameters = new List <RevitParameter> { new RevitParameter { Name = paramName, Value = value } }; RevitParametersToPush existingFragment = bHoMObject.Fragments.FirstOrDefault(x => x is RevitParametersToPush) as RevitParametersToPush; if (existingFragment != null) { foreach (RevitParameter parameter in existingFragment.Parameters) { if (parameter.Name != paramName) { parameters.Add(parameter); } } } RevitParametersToPush fragment = new RevitParametersToPush { Parameters = parameters }; IBHoMObject obj = bHoMObject.ShallowClone(); obj.Fragments = new FragmentSet(bHoMObject.Fragments.Where(x => !(x is RevitParametersToPush)).ToList()); obj.Fragments.Add(fragment); return(obj); }