public override Value Evaluate(FSharpList <Value> args) { var particleSystem = (ParticleSystem)((Value.Container)args[0]).Item; return(Value.NewList( Utils.SequenceToFSharpList( particleSystem.Particles.Select(p => Value.NewContainer(p.getPosition()))))); }
public override Value Evaluate(FSharpList <Value> args) { var transform = (Transform)((Value.Container)args[0]).Item; Transform t = transform.Inverse; return(Value.NewContainer(t)); }
public override Value Evaluate(FSharpList <Value> args) { var watcher = (FileWatcher)((Value.Container)args[0]).Item; watcher.Reset(); return(Value.NewContainer(watcher)); }
public override Value Evaluate(FSharpList <Value> args) { var plane = (Autodesk.Revit.DB.Plane)((Value.Container)args[0]).Item; Transform t = Transform.get_Reflection(plane); return(Value.NewContainer(t)); }
public override Value Evaluate(FSharpList <Value> args) { var vector = (XYZ)((Value.Container)args[0]).Item; Transform t = Transform.get_Translation(vector); return(Value.NewContainer(t)); }
private Value makeCurveRef(object c, int count) { Reference r = c is CurveElement ? (c as CurveElement).GeometryCurve.Reference // curve element : (c as Curve).Reference; // geometry curve return(Value.NewContainer(r)); }
public override void Evaluate(FSharpList <Value> args, Dictionary <PortData, Value> outPuts) { var xyz = (XYZ)((Value.Container)args[0]).Item; var inputArg = ((Value.Container)args[1]).Item; XYZ pt; UV uv; double d; Edge e; double et; var face = inputArg is Face ? (Face)inputArg : null; if (face == null && !(inputArg is Plane)) { throw new Exception(" Project Point On Face needs Face or Plane as argument no. 1"); } if (face == null) { var pln = (Plane)inputArg; uv = new UV( pln.XVec.DotProduct(xyz - pln.Origin), pln.YVec.DotProduct(xyz - pln.Origin)); pt = pln.Origin + uv[0] * pln.XVec + uv[1] * pln.YVec; d = xyz.DistanceTo(pt); e = null; et = 0.0; } else { IntersectionResult ir = face.Project(xyz); pt = ir.XYZPoint; uv = ir.UVPoint; d = ir.Distance; e = null; et = 0; try { e = ir.EdgeObject; } catch { } try { et = ir.EdgeParameter; } catch { } } pts.Add(pt); outPuts[_xyzPort] = Value.NewContainer(xyz); outPuts[_uvPort] = Value.NewContainer(uv); outPuts[_dPort] = Value.NewNumber(d); outPuts[_edgePort] = Value.NewContainer(e); outPuts[_edgeTPort] = Value.NewNumber(et); }
public override void Evaluate(FSharpList <Value> args, Dictionary <PortData, Value> outPuts) { var origin = (XYZ)((Value.Container)args[0]).Item; var direction = (XYZ)((Value.Container)args[1]).Item; var rayLimit = ((Value.Number)args[2]).Item; var view = (View3D)((Value.Container)args[3]).Item; XYZ startpt = origin; int rayCount = 0; var bouncePts = FSharpList <Value> .Empty; var bounceElements = FSharpList <Value> .Empty; bouncePts = FSharpList <Value> .Cons(Value.NewContainer(origin), bouncePts); for (int ctr = 1; ctr <= rayLimit; ctr++) { var referenceIntersector = new ReferenceIntersector(view); IList <ReferenceWithContext> references = referenceIntersector.Find(startpt, direction); ReferenceWithContext rClosest = null; rClosest = FindClosestReference(references); if (rClosest == null) { break; } else { var reference = rClosest.GetReference(); var referenceElement = dynRevitSettings.Doc.Document.GetElement(reference); bounceElements = FSharpList <Value> .Cons(Value.NewContainer(referenceElement), bounceElements); var referenceObject = referenceElement.GetGeometryObjectFromReference(reference); var endpt = reference.GlobalPoint; if (startpt.IsAlmostEqualTo(endpt)) { break; } else { rayCount = rayCount + 1; currFace = referenceObject as Face; var endptUV = reference.UVPoint; var FaceNormal = currFace.ComputeDerivatives(endptUV).BasisZ; // face normal where ray hits FaceNormal = rClosest.GetInstanceTransform().OfVector(FaceNormal); // transformation to get it in terms of document coordinates instead of the parent symbol var directionMirrored = direction - 2 * direction.DotProduct(FaceNormal) * FaceNormal; //http://www.fvastro.org/presentations/ray_tracing.htm direction = directionMirrored; // get ready to shoot the next ray startpt = endpt; bouncePts = FSharpList <Value> .Cons(Value.NewContainer(endpt), bouncePts); } } } bouncePts.Reverse(); bounceElements.Reverse(); outPuts[intersections] = Value.NewList(bouncePts); outPuts[elements] = Value.NewList(bounceElements); }
public override Value Evaluate(FSharpList <Value> args) { Curve c = (Curve)((Value.Container)args[0]).Item; SketchPlane sp = (SketchPlane)((Value.Container)args[1]).Item; ModelCurve mc; XYZ spOrigin = sp.Plane.Origin; XYZ modelOrigin = XYZ.Zero; Transform trf = Transform.get_Translation(spOrigin); //trf = trf.Multiply(Transform.get_Rotation(spOrigin,XYZ.BasisZ,spOrigin.AngleOnPlaneTo(XYZ.BasisY,spOrigin))); //Curve ct = c.get_Transformed(trf); // http://wikihelp.autodesk.com/Revit/enu/2013/Help/00006-API_Developer's_Guide/0074-Revit_Ge74/0114-Sketchin114/0117-ModelCur117 // The SetPlaneAndCurve() method and the Curve and SketchPlane property setters are used in different situations. // When the new Curve lies in the same SketchPlane, or the new SketchPlane lies on the same planar face with the old SketchPlane, use the Curve or SketchPlane property setters. // If new Curve does not lay in the same SketchPlane, or the new SketchPlane does not lay on the same planar face with the old SketchPlane, you must simultaneously change the Curve value and the SketchPlane value using SetPlaneAndCurve() to avoid internal data inconsistency. if (this.Elements.Any()) { Element e; if (dynUtils.TryGetElement(this.Elements[0], typeof(ModelCurve), out e)) { mc = e as ModelCurve; mc.SketchPlane = sp; if (!mc.GeometryCurve.IsBound && c.IsBound) { c = c.Clone(); c.MakeUnbound(); } mc.GeometryCurve = c; } else { mc = this.UIDocument.Document.IsFamilyDocument ? this.UIDocument.Document.FamilyCreate.NewModelCurve(c, sp) : this.UIDocument.Document.Create.NewModelCurve(c, sp); this.Elements[0] = mc.Id; mc.SketchPlane = sp; } } else { mc = this.UIDocument.Document.IsFamilyDocument ? this.UIDocument.Document.FamilyCreate.NewModelCurve(c, sp) : this.UIDocument.Document.Create.NewModelCurve(c, sp); this.Elements.Add(mc.Id); mc.SketchPlane = sp; } mc.ChangeToReferenceLine(); return(Value.NewContainer(mc)); }
public override Value Evaluate(FSharpList <Value> args) { var curve = (Curve)((Value.Container)args[0]).Item; var trans = (Transform)((Value.Container)args[1]).Item; var crvTrans = curve.get_Transformed(trans); return(Value.NewContainer(crvTrans)); }
public override Value Evaluate(FSharpList <Value> args) { var a = (int)Math.Round(((Value.Number)args[0]).Item); var r = (int)Math.Round(((Value.Number)args[1]).Item); var g = (int)Math.Round(((Value.Number)args[2]).Item); var b = (int)Math.Round(((Value.Number)args[3]).Item); return(Value.NewContainer(System.Drawing.Color.FromArgb(a, r, g, b))); }
public override Value Evaluate(FSharpList <Value> args) { if (SelectedElement == null) { throw new Exception("Nothing selected."); } return(Value.NewContainer(SelectedElement)); }
public override Value Evaluate(FSharpList <Value> args) { Point origin = (Point)((Value.Container)args[0]).Item; Vector normal = (Vector)((Value.Container)args[1]).Item; _plane = Plane.by_origin_normal(origin, normal); return(Value.NewContainer(_plane)); }
public override Value Evaluate(FSharpList <Value> args) { var t = (Transform)((Value.Container)args[0]).Item; var pt = (XYZ)((Value.Container)args[1]).Item; XYZ tpt = GetPointTransformed(pt, t); return(Value.NewContainer(tpt)); }
public override Value Evaluate(FSharpList <Value> args) { //Grab our inputs and turn them into XYZs. XYZ ptA = this.getXYZ(((Value.Container)args[0]).Item); XYZ ptB = this.getXYZ(((Value.Container)args[1]).Item); //Return the calculated distance. return(Value.NewContainer(Units.Length.FromFeet(ptA.DistanceTo(ptB), dynSettings.Controller.UnitsManager))); }
public override Value Evaluate(FSharpList <Value> args) { Curve curve = (Curve)((Value.Container)args[0]).Item; double param = ((Value.Number)args[1]).Item; _vector = curve.normal_at_parameter(param); return(Value.NewContainer(_vector)); }
public override Value Evaluate(FSharpList <Value> args) { var transform = (Transform)((Value.Container)args[0]).Item; var scale = ((Value.Number)args[1]).Item; Transform t = transform.ScaleBasis(scale); return(Value.NewContainer(t)); }
public override Value Evaluate(FSharpList <Value> args) { var t1 = (Transform)((Value.Container)args[0]).Item; var t2 = (Transform)((Value.Container)args[1]).Item; Transform t = t1.Multiply(t2); return(Value.NewContainer(t)); }
public override Value Evaluate(FSharpList <Value> args) { View3D view = null; var eye = (XYZ)((Value.Container)args[0]).Item; var userUp = (XYZ)((Value.Container)args[1]).Item; var direction = (XYZ)((Value.Container)args[2]).Item; var name = ((Value.String)args[3]).Item; XYZ side; if (direction.IsAlmostEqualTo(userUp) || direction.IsAlmostEqualTo(userUp.Negate())) { side = XYZ.BasisZ.CrossProduct(direction); } else { side = userUp.CrossProduct(direction); } XYZ up = side.CrossProduct(direction); //need to reverse the up direction to get the //proper orientation - there might be a better way to handle this var orient = new ViewOrientation3D(eye, -up, direction); if (this.Elements.Any()) { Element e; if (dynUtils.TryGetElement(this.Elements[0], typeof(View3D), out e)) { view = (View3D)e; if (!view.ViewDirection.IsAlmostEqualTo(direction)) { view.Unlock(); view.SetOrientation(orient); view.SaveOrientationAndLock(); } if (view.Name != null && view.Name != name) { view.Name = CreateUniqueViewName(name); } } else { //create a new view view = dynViewBase.Create3DView(orient, name, false); Elements[0] = view.Id; } } else { view = Create3DView(orient, name, false); Elements.Add(view.Id); } return(Value.NewContainer(view)); }
public override Value Evaluate(FSharpList <Value> args) { Curve pathCurve = (Curve)((Value.Container)args[0]).Item; Curve crossSection = (Curve)((Value.Container)args[1]).Item; _solid = crossSection.sweep_as_solid(pathCurve); GraphicItem.persist(_solid); return(Value.NewContainer(_solid)); }
public override Value Evaluate(FSharpList <Value> args) { Point cp = (Point)((Value.Container)args[0]).Item; double r = ((Value.Number)args[1]).Item; Vector normal = (Vector)((Value.Container)args[2]).Item; _circle = Circle.by_center_point_radius_normal(cp, r, normal); return(Value.NewContainer(_circle)); }
public override Value Evaluate(FSharpList <Value> args) { Point origin = (Point)((Value.Container)args[0]).Item; Vector x_axis = (Vector)((Value.Container)args[1]).Item; Vector y_axis = (Vector)((Value.Container)args[2]).Item; _cs = CoordinateSystem.by_origin_vectors(origin, x_axis, y_axis); return(Value.NewContainer(_cs)); }
public override Value Evaluate(FSharpList <Value> args) { Curve curve = (Curve)((Value.Container)args[0]).Item; double dist = ((Value.Number)args[1]).Item; _point = curve.point_at_distance(dist); GraphicItem.persist(_point); return(Value.NewContainer(_point)); }
public override Value Evaluate(FSharpList <Value> args) { Surface surf = (Surface)((Value.Container)args[0]).Item; double dist = ((Value.Number)args[1]).Item; _solid = surf.thicken(dist); GraphicItem.persist(_solid); return(Value.NewContainer(_solid)); }
public override Value Evaluate(FSharpList <Value> args) { var origin = (XYZ)((Value.Container)args[0]).Item; var axis = (XYZ)((Value.Container)args[1]).Item; var angle = ((Value.Number)args[2]).Item; Transform t = Transform.get_Rotation(origin, axis, angle); return(Value.NewContainer(t)); }
public override Value Evaluate(FSharpList <Value> args) { Point sp = (Point)((Value.Container)args[0]).Item; Point ep = (Point)((Value.Container)args[1]).Item; _line = Line.by_start_point_end_point(sp, ep); _graphicItems.Add(_line); return(Value.NewContainer(_line)); }
public override Value Evaluate(FSharpList <Value> args) { Surface surf = (Surface)((Value.Container)args[0]).Item; double u = ((Value.Number)args[1]).Item; double v = ((Value.Number)args[2]).Item; _vector = surf.normal_at_parameter(u, v); return(Value.NewContainer(_vector)); }
public override Value Evaluate(FSharpList <Value> args) { this.ClearPreviousResults(); //unwrap the values IEnumerable <XYZ> nvals = ((Value.List)args[0]).Item.Select( x => (XYZ)((Value.Container)x).Item ); //unwrap the sample locations IEnumerable <XYZ> pts = ((Value.List)args[1]).Item.Select( x => (XYZ)((Value.Container)x).Item ); SpatialFieldManager = ((Value.Container)args[2]).Item as Autodesk.Revit.DB.Analysis.SpatialFieldManager; int idx = SpatialFieldManager.AddSpatialFieldPrimitive(); var samplePts = new FieldDomainPointsByXYZ(pts.ToList <XYZ>()); //for every sample location add a list //of valueatpoint objects. for now, we only //support one value per point IList <VectorAtPoint> valList = nvals.Select(n => new VectorAtPoint(new List <XYZ> { n })).ToList(); var sampleValues = new FieldValues(valList); int schemaIndex = 0; if (!SpatialFieldManager.IsResultSchemaNameUnique(DYNAMO_ANALYSIS_RESULTS_NAME, -1)) { IList <int> arses = SpatialFieldManager.GetRegisteredResults(); foreach (int i in arses) { AnalysisResultSchema arsTest = SpatialFieldManager.GetResultSchema(i); if (arsTest.Name == DYNAMO_ANALYSIS_RESULTS_NAME) { schemaIndex = i; break; } } } else { var ars = new AnalysisResultSchema(DYNAMO_ANALYSIS_RESULTS_NAME, "Resulting analyses from Dynamo."); schemaIndex = SpatialFieldManager.RegisterResult(ars); } SpatialFieldManager.UpdateSpatialFieldPrimitive(idx, samplePts, sampleValues, schemaIndex); PastResultIds.Add(idx); return(Value.NewContainer(idx)); }
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; //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)) { 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 = 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) { var point = dynRevitSettings.Doc.Document.GetElement(id) as ReferencePoint; var pt = (XYZ)((Value.Container)pts.ElementAt(i)).Item; point.Position = pt; i++; } return(Value.NewContainer(ac)); }
public override Value Evaluate(FSharpList <Value> args) { Curve curve = (Curve)((Value.Container)args[0]).Item; double param = ((Value.Number)args[1]).Item; _point = curve.point_at_parameter(param); GraphicItem.persist(_point); _graphicItems.Add(_point); return(Value.NewContainer(_point)); }