private CurveByPoints CreateCurveByPoints(CurveByPoints c, Curve gc, XYZ start, XYZ end) { //Add the geometry curves start and end points to a ReferencePointArray. ReferencePointArray refPtArr = new ReferencePointArray(); if (gc.GetType() == typeof(Line)) { ReferencePoint refPointStart = this.UIDocument.Document.FamilyCreate.NewReferencePoint(start); ReferencePoint refPointEnd = this.UIDocument.Document.FamilyCreate.NewReferencePoint(end); refPtArr.Append(refPointStart); refPtArr.Append(refPointEnd); } c = dynRevitSettings.Doc.Document.FamilyCreate.NewCurveByPoints(refPtArr); return(c); }
public override Value Evaluate(FSharpList <Value> args) { bool isRefCurve = Convert.ToBoolean(((Value.Number)args[1]).Item); //Build a sequence that unwraps the input list from it's Value form. IEnumerable <ReferencePoint> refPts = ((Value.List)args[0]).Item.Select( x => (ReferencePoint)((Value.Container)x).Item ); //Add all of the elements in the sequence to a ReferencePointArray. ReferencePointArray refPtArr = new ReferencePointArray(); foreach (var refPt in refPts) { refPtArr.Append(refPt); } //Standard logic for updating an old result, if it exists. if (this.Elements.Any()) { Element e; if (dynUtils.TryGetElement(this.Elements[0], typeof(CurveByPoints), out e)) { c = e as CurveByPoints; c.SetPoints(refPtArr); } else { //TODO: This method of handling bad elements may cause problems. Instead of overwriting // index in Elements, might be better to just add it the Elements and then do // this.DeleteElement(id, true) on the old index. c = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPtArr); this.Elements[0] = c.Id; } } else { c = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPtArr); this.Elements.Add(c.Id); } c.IsReferenceLine = isRefCurve; return(Value.NewContainer(c)); }
public override Value Evaluate(FSharpList <Value> args) { //Our eventual output. CurveByPoints c = null; var input = args[0]; Curve gc = (Curve)((Value.Container)args[0]).Item; XYZ start = gc.get_EndPoint(0); XYZ end = gc.get_EndPoint(1); //If we've made any elements previously... if (this.Elements.Any()) { Element e; //...try to get the first one... if (dynUtils.TryGetElement(this.Elements[0], typeof(CurveByPoints), out e)) { //..and if we do, update it's position. c = e as CurveByPoints; ReferencePointArray existingPts = c.GetPoints(); //update the points on the curve to match ReferencePointArrayIterator iter = existingPts.ForwardIterator(); existingPts.get_Item(0).Position = start; existingPts.get_Item(1).Position = end; } else { c = CreateCurveByPoints(c, gc, start, end); this.Elements[0] = c.Id; } } else { c = CreateCurveByPoints(c, gc, start, end); this.Elements.Add(c.Id); } return(Value.NewContainer(c)); }
public override Value Evaluate(FSharpList<Value> args) { //Build a sequence that unwraps the input list from it's Value form. IEnumerable<ReferencePoint> refPts = ((Value.List)args[0]).Item.Select( x => (ReferencePoint)((Value.Container)x).Item ); //Add all of the elements in the sequence to a ReferencePointArray. ReferencePointArray refPtArr = new ReferencePointArray(); foreach (var refPt in refPts) { refPtArr.Append(refPt); } //Standard logic for updating an old result, if it exists. if (this.Elements.Any()) { Element e; if (dynUtils.TryGetElement(this.Elements[0], out e)) { c = e as CurveByPoints; c.SetPoints(refPtArr); } else { //TODO: This method of handling bad elements may cause problems. Instead of overwriting // index in Elements, might be better to just add it the Elements and then do // this.DeleteElement(id, true) on the old index. c = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPtArr); this.Elements[0] = c.Id; } } else { c = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPtArr); this.Elements.Add(c.Id); } return Value.NewContainer(c); }
public override Value Evaluate(FSharpList <Value> args) { Autodesk.LibG.Geometry geometry = (Autodesk.LibG.Geometry)((Value.Container)args[0]).Item; Autodesk.LibG.Point point = geometry as Autodesk.LibG.Point; if (point != null) { XYZ xyz = new XYZ(point.x(), point.y(), point.z()); if (_revitPoint == null) { _revitPoint = this.UIDocument.Document.FamilyCreate.NewReferencePoint(xyz); this.Elements.Add(_revitPoint.Id); } else { _revitPoint.Position = xyz; } return(Value.NewContainer(_revitPoint)); } Autodesk.LibG.Line line = geometry as Autodesk.LibG.Line; if (line != null) { ReferencePointArray refPoints = new ReferencePointArray(); Autodesk.LibG.Point start_point = line.start_point(); Autodesk.LibG.Point end_point = line.end_point(); if (_curveByPoints == null) { _startPoint = ReferencePointFromPoint(start_point); _endPoint = ReferencePointFromPoint(end_point); refPoints.Append(_startPoint); refPoints.Append(_endPoint); _curveByPoints = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPoints); this.Elements.Add(_curveByPoints.Id); } else { _startPoint.Position = new XYZ(start_point.x(), start_point.y(), start_point.z()); _endPoint.Position = new XYZ(end_point.x(), end_point.y(), end_point.z()); } return(Value.Container.NewContainer(_curveByPoints)); } //Autodesk.LibG.BSplineCurve bspline = geometry as Autodesk.LibG.BSplineCurve; //if (bspline != null) //{ // ReferencePointArray refPoints = new ReferencePointArray(); // for (int i = 0; i <= 15; ++i) // { // double param = (double)i / 15.0; // Autodesk.LibG.Point p = bspline.point_at_parameter(param); // ReferencePoint refPoint = ReferencePointFromPoint(p); // refPoints.Append(refPoint); // } // if (_curveByPoints == null) // { // _curveByPoints = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPoints); // this.Elements.Add(_curveByPoints.Id); // } // else // { // _curveByPoints.SetPoints(refPoints); // } // foreach (ReferencePoint refPoint in refPoints) // { // refPoint.Visible = false; // } // return Value.Container.NewContainer(_curveByPoints); //} return(Value.Container.NewContainer(null)); // Surface // Solid }
public override Value Evaluate(FSharpList<Value> args) { Autodesk.LibG.Geometry geometry = (Autodesk.LibG.Geometry)((Value.Container)args[0]).Item; Autodesk.LibG.Point point = geometry as Autodesk.LibG.Point; if (point != null) { XYZ xyz = new XYZ(point.x(), point.y(), point.z()); if (_revitPoint == null) { _revitPoint = this.UIDocument.Document.FamilyCreate.NewReferencePoint(xyz); this.Elements.Add(_revitPoint.Id); } else { _revitPoint.Position = xyz; } return Value.NewContainer(_revitPoint); } Autodesk.LibG.Line line = geometry as Autodesk.LibG.Line; if (line != null) { ReferencePointArray refPoints = new ReferencePointArray(); Autodesk.LibG.Point start_point = line.start_point(); Autodesk.LibG.Point end_point = line.end_point(); if (_curveByPoints == null) { _startPoint = ReferencePointFromPoint(start_point); _endPoint = ReferencePointFromPoint(end_point); refPoints.Append(_startPoint); refPoints.Append(_endPoint); _curveByPoints = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPoints); this.Elements.Add(_curveByPoints.Id); } else { _startPoint.Position = new XYZ(start_point.x(), start_point.y(), start_point.z()); _endPoint.Position = new XYZ(end_point.x(), end_point.y(), end_point.z()); } return Value.Container.NewContainer(_curveByPoints); } //Autodesk.LibG.BSplineCurve bspline = geometry as Autodesk.LibG.BSplineCurve; //if (bspline != null) //{ // ReferencePointArray refPoints = new ReferencePointArray(); // for (int i = 0; i <= 15; ++i) // { // double param = (double)i / 15.0; // Autodesk.LibG.Point p = bspline.point_at_parameter(param); // ReferencePoint refPoint = ReferencePointFromPoint(p); // refPoints.Append(refPoint); // } // if (_curveByPoints == null) // { // _curveByPoints = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPoints); // this.Elements.Add(_curveByPoints.Id); // } // else // { // _curveByPoints.SetPoints(refPoints); // } // foreach (ReferencePoint refPoint in refPoints) // { // refPoint.Visible = false; // } // return Value.Container.NewContainer(_curveByPoints); //} return Value.Container.NewContainer(null); // Surface // Solid }
private CurveByPoints CreateCurveByPoints(CurveByPoints c, Curve gc, XYZ start, XYZ end) { //Add the geometry curves start and end points to a ReferencePointArray. ReferencePointArray refPtArr = new ReferencePointArray(); if (gc.GetType() == typeof(Line)) { ReferencePoint refPointStart = this.UIDocument.Document.FamilyCreate.NewReferencePoint(start); ReferencePoint refPointEnd = this.UIDocument.Document.FamilyCreate.NewReferencePoint(end); refPtArr.Append(refPointStart); refPtArr.Append(refPointEnd); } c = dynRevitSettings.Doc.Document.FamilyCreate.NewCurveByPoints(refPtArr); return c; }