public override Value Evaluate(FSharpList <Value> args) { FSharpList <Value> pts = ((Value.List)args[0]).Item; FamilySymbol fs = (FamilySymbol)((Value.Container)args[1]).Item; FamilyInstance ac = null; //if the adapative component already exists, then move the points if (Elements.Any()) { //mutate Element e; //...we attempt to fetch it from the document... if (dynUtils.TryGetElement(this.Elements[0], typeof(FamilyInstance), out e)) { ac = e as FamilyInstance; ac.Symbol = fs; } else { //create ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs); Elements[0] = ac.Id; } } else { //create ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs); Elements.Add(ac.Id); } if (ac == null) { throw new Exception("An adaptive component could not be found or created."); } IList <ElementId> placePointIds = new List <ElementId>(); placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(ac); if (placePointIds.Count() != pts.Count()) { throw new Exception("The input list of points does not have the same number of values required by the adaptive component."); } // Set the position of each placement point int i = 0; foreach (ElementId id in placePointIds) { ReferencePoint point = dynRevitSettings.Doc.Document.GetElement(id) as ReferencePoint; XYZ pt = (XYZ)((Value.Container)pts.ElementAt(i)).Item; point.Position = pt; i++; } return(Value.NewContainer(ac)); }
public override Value Evaluate(FSharpList <Value> args) { if (!args[0].IsList) { throw new Exception("A list of UVs is required to place the Adaptive Component."); } FSharpList <Value> uvs = ((Value.List)args[0]).Item; var faceRef = ((Value.Container)args[1]).Item as Reference; var f = faceRef == null ? (Face)((Value.Container)args[1]).Item : (Face)dynRevitSettings.Doc.Document.GetElement(faceRef.ElementId).GetGeometryObjectFromReference(faceRef); var fs = (FamilySymbol)((Value.Container)args[2]).Item; FamilyInstance ac = null; //if the adapative component already exists, then move the points if (Elements.Any()) { //mutate Element e; //...we attempt to fetch it from the document... if (dynUtils.TryGetElement(this.Elements[0], typeof(FamilyInstance), out e)) { ac = e as FamilyInstance; ac.Symbol = fs; } else { //create ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs); Elements[0] = ac.Id; } } else { //create ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs); Elements.Add(ac.Id); } if (ac == null) { throw new Exception("An adaptive component could not be found or created."); } IList <ElementId> placePointIds = new List <ElementId>(); placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(ac); if (placePointIds.Count() != uvs.Count()) { throw new Exception("The input list of UVs does not have the same number of values required by the adaptive component."); } // Set the position of each placement point int i = 0; foreach (ElementId id in placePointIds) { var uv = (UV)((Value.Container)uvs.ElementAt(i)).Item; var point = dynRevitSettings.Doc.Document.GetElement(id) as ReferencePoint; var peref = dynRevitSettings.Revit.Application.Create.NewPointOnFace(f.Reference, uv); point.SetPointElementReference(peref); i++; } return(Value.NewContainer(ac)); }
public override Value Evaluate(FSharpList <Value> args) { if (!args[0].IsList) { throw new Exception("A list of UVs is required to place the Adaptive Component."); } FSharpList <Value> parameters = ((Value.List)args[0]).Item; var curveRef = ((Value.Container)args[1]).Item as Reference; var c = curveRef == null ? (Curve)((Value.Container)args[1]).Item : (Curve)dynRevitSettings.Doc.Document.GetElement(curveRef.ElementId).GetGeometryObjectFromReference(curveRef); var fs = (FamilySymbol)((Value.Container)args[2]).Item; FamilyInstance ac = null; //if the adapative component already exists, then move the points if (Elements.Any()) { //...we attempt to fetch it from the document... if (dynUtils.TryGetElement(this.Elements[0], out ac)) { ac.Symbol = fs; } else { //create ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs); Elements[0] = ac.Id; } } else { //create ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs); Elements.Add(ac.Id); } if (ac == null) { throw new Exception("An adaptive component could not be found or created."); } IList <ElementId> placePointIds = new List <ElementId>(); placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(ac); if (placePointIds.Count() != parameters.Count()) { throw new Exception("The input list of UVs does not have the same number of values required by the adaptive component."); } // Set the position of each placement point int i = 0; foreach (ElementId id in placePointIds) { var t = ((Value.Number)parameters.ElementAt(i)).Item; var point = dynRevitSettings.Doc.Document.GetElement(id) as ReferencePoint; var ploc = new PointLocationOnCurve(PointOnCurveMeasurementType.NonNormalizedCurveParameter, t, PointOnCurveMeasureFrom.Beginning); var peref = dynRevitSettings.Revit.Application.Create.NewPointOnEdge(c.Reference, ploc); point.SetPointElementReference(peref); i++; } return(Value.NewContainer(ac)); }
public override Value Evaluate(FSharpList <Value> args) { FSharpList <Value> pts = ((Value.List)args[0]).Item; var fs = (FamilySymbol)((Value.Container)args[1]).Item; FamilyInstance ac; var instData = new List <FamilyInstanceCreationData>(); var sw = new Stopwatch(); //if the adapative component already exists, then move the points if (Elements.Any()) { //mutate //...we attempt to fetch it from the document... if (dynUtils.TryGetElement(Elements[0], out ac)) { sw.Start(); ac.Symbol = fs; sw.Stop(); Debug.WriteLine(string.Format("{0} elapsed for updating family type on AC.", sw.Elapsed)); sw.Reset(); } else { sw.Start(); //create ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs); Elements[0] = ac.Id; sw.Stop(); Debug.WriteLine(string.Format("{0} elapsed for creating an AC.", sw.Elapsed)); sw.Reset(); } } else { sw.Start(); //create ac = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(dynRevitSettings.Doc.Document, fs); Elements.Add(ac.Id); sw.Stop(); Debug.WriteLine(string.Format("{0} elapsed for creating an AC.", sw.Elapsed)); sw.Reset(); } if (ac == null) { throw new Exception("An adaptive component could not be found or created."); } IList <ElementId> placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(ac); if (placePointIds.Count() != pts.Count()) { throw new Exception("The input list of points does not have the same number of values required by the adaptive component."); } sw.Start(); // Set the position of each placement point int i = 0; foreach (ElementId id in placePointIds) { var point = dynRevitSettings.Doc.Document.GetElement(id) as ReferencePoint; var pt = (XYZ)((Value.Container)pts.ElementAt(i)).Item; point.Position = pt; i++; } sw.Stop(); Debug.WriteLine(string.Format("{0} elapsed for updating placement points of the AC.", sw.Elapsed)); sw.Reset(); return(Value.NewContainer(ac)); }