public void ForTest(UIDocument uidoc, Document revitDoc) { ElementId ele = null; Selection selection = uidoc.Selection; ICollection <ElementId> element = selection.GetElementIds(); foreach (ElementId eleID in element) { ele = eleID; break; } Element e = revitDoc.GetElement(ele); Form ff = e as Form; var dd = ff.get_CurveLoopReferencesOnProfile(0, 0); GeometryElement gg = ff.get_Geometry(new Options()); List <string> types = new List <string>(); List <int> CPPoint = new List <int>(); List <List <XYZ> > SPLINE_POINTs = new List <List <XYZ> >(); double THICK_LIMIT = 1000 / TRANS_UNIT; foreach (Solid item in gg) { foreach (Face face in item.Faces) { HermiteFace HS = face as HermiteFace; } List <Curve> CURVES = new List <Curve>(); foreach (Edge edge in item.Edges) { Curve cc = edge.AsCurve(); HermiteSpline HS = cc as HermiteSpline; //HS.ComputeDerivatives(0, true); //var CP = HS.ControlPoints; types.Add(cc.GetType().Name); if (HS != null) { CPPoint.Add(HS.ControlPoints.Count); var der1 = HS.ComputeDerivatives(0, true); var der2 = HS.ComputeDerivatives(0.25, true); List <XYZ> tmp = GetSplitedPointsFromEachType(HS, 0); SPLINE_POINTs.Add(tmp); CURVES.Add(cc); } else if (cc.Length > THICK_LIMIT) { CURVES.Add(cc); } } FilterIndicatedFlattenClosedCurves(CURVES); // SaveTest(SPLINE_POINTs); //Dictionary<int, FlattenGroup> DATA = GetPairFlattenedData(SPLINE_POINTs); //Plattening(DATA); } }
/***************************************************/ public static oM.Geometry.NurbsCurve FromRevit(this HermiteSpline curve) { if (curve == null) { return(null); } return(NurbSpline.Create(curve).FromRevit()); }
Stream(ArrayList data, HermiteSpline hermiteSpline) { data.Add(new Snoop.Data.ClassSeparator(typeof(HermiteSpline))); data.Add(new Snoop.Data.Enumerable("Control points", hermiteSpline.ControlPoints)); data.Add(new Snoop.Data.Bool("Is periodic", hermiteSpline.IsPeriodic)); data.Add(new Snoop.Data.Enumerable("Parameters", hermiteSpline.Parameters)); data.Add(new Snoop.Data.Enumerable("Tangents", hermiteSpline.Tangents)); }
// Use this for initialization public void SetDisplaySplines(HermiteSpline startSpline, HermiteSpline cyclicSpline) { if (!display.gameObject.activeSelf) { display.gameObject.SetActive(true); } this.startSpline.Spline = startSpline; this.cyclicSpline.Spline = cyclicSpline; //_endSpline.Spline = endSpline; }
public ElementId CreateSplineWall(XYZ[] pts, ElementId baseLevelId, ElementId topLevelId, ElementId famId, bool closed) { Wall wall = Wall.Create(doc, HermiteSpline.Create(pts, false), baseLevelId, closed); if (famId != null) { wall.WallType = doc.GetElement(famId) as WallType; } wall.get_Parameter(BuiltInParameter.WALL_HEIGHT_TYPE).Set(topLevelId); return(wall.Id); }
private void CreateJsonReadyTangentData(HermiteSpline hermiteSpline) { Transform[] tangentsToExport = hermiteSpline.GetAllTangents; Array.Resize(ref GetJsonHandling.GetSplineData.TangentData, tangentsToExport.Length); for (int i = 0; i < tangentsToExport.Length; i++) { GetJsonHandling.GetSplineData.TangentData[i] = new TransformDummy(tangentsToExport[i].Index, tangentsToExport[i].Position) { UserData = tangentsToExport[i].UserData as HermiteSpline.TangentData }; } }
private static ElementId createModelCurve(Document document, Curve curve, SketchPlane sp = null) { Line line = curve as Line; Arc arc = curve as Arc; Ellipse ellipse = curve as Ellipse; HermiteSpline spline = curve as HermiteSpline; NurbSpline nbSpline = curve as NurbSpline; if (line != null && null == sp) { XYZ normal = getVertVec(line.Direction).Normalize(); XYZ origin = line.GetEndPoint(0); sp = SketchPlane.Create(document, Plane.CreateByNormalAndOrigin(normal, origin)); } else if (arc != null && null == sp) { XYZ normal = arc.Normal; sp = SketchPlane.Create(document, Plane.CreateByNormalAndOrigin(normal, arc.Center)); } else if (ellipse != null && null == sp) { XYZ normal = ellipse.Normal; sp = SketchPlane.Create(document, Plane.CreateByNormalAndOrigin(normal, ellipse.Center)); } else if (spline != null && null == sp) { Transform tran = spline.ComputeDerivatives(0, false); XYZ normal = getVertVec(tran.BasisX).Normalize(); XYZ origin = spline.GetEndPoint(0); sp = SketchPlane.Create(document, Plane.CreateByNormalAndOrigin(normal, origin)); } else if (nbSpline != null && null == sp) { Transform tran = nbSpline.ComputeDerivatives(0, false); XYZ normal = getVertVec(tran.BasisX).Normalize(); XYZ origin = nbSpline.GetEndPoint(0); sp = SketchPlane.Create(document, Plane.CreateByNormalAndOrigin(normal, origin)); } if (sp == null) { throw new ArgumentException("Not valid sketchplane to create curve:" + curve.GetType().Name); } // // create model line with curve and the specified sketch plane. ModelCurve mCurve = document.Create.NewModelCurve(curve, sp); return((null != mCurve) ? mCurve.Id : ElementId.InvalidElementId); }
public void IsLineLike_Curve_CorrectlyIdentifiesNonStraightHermiteWithStraightControlPoints() { var points = Enumerable.Range(0, 10) .Select(x => new XYZ(x, 0, 0)); var hs = HermiteSpline.Create( points.ToList(), false, new HermiteSplineTangents() { StartTangent = new XYZ(0, 0, 1), EndTangent = new XYZ(1, 0, 0) }); Assert.False(CurveUtils.IsLineLike(hs)); }
/// <summary> /// 將線段進行點分割 /// </summary> /// <param name="curve"></param> /// <param name="num"></param> /// <returns></returns> private List <XYZ> GetSplitedPointsFromEachType(Curve curve, int num) { int kk = 0; string CurveType = curve.GetType().Name; List <XYZ> tmp = new List <XYZ>(); int SplitedNum = Convert.ToInt32(curve.Length * TRANS_UNIT / 200); double span = num == 16 ? 16 : 1.0 / SplitedNum; switch (CurveType) { case "HermiteSpline": HermiteSpline HS = curve as HermiteSpline; for (double i = 0; i <= 1; i += span) { tmp.Add(HS.ComputeDerivatives(i, true).Origin); kk++; } break; case "Line": Line line = curve as Line; double Len = curve.Length / SplitedNum; for (int i = 0; i <= SplitedNum; i++) { XYZ newPoint = new XYZ(line.Origin.X + line.Direction.X * Len * i, line.Origin.Y + line.Direction.Y * Len * i, line.Origin.Z + line.Direction.Z * Len * i); tmp.Add(newPoint); } break; case "Arc": break; default: break; } return(tmp); }
protected override void Initialize() { base.Initialize(); Setup.Initialize(Editor.graphics); Setup.ShowCurves = true; Setup.ShowDirectionVectors = true; Setup.ShowLines = true; Setup.ShowPoints = true; MySpline = new HermiteSpline(); //Custom ctr-Test //MySpline = new HermitSpline(new Transform[] { // new Transform(new Vector2(0, 0)), // new Transform(new Vector2(250, 0)), // new Transform(new Vector2(0, 250)) //}); MySpline.Loop = false; MySpline.TangentSelected += MySpline_TangentSelected; MySpline.TangentDeselected += MySpline_TangentDeselected; GetSpline = MySpline; CenterSpline(); MySplineWalker = new Car(); MySplineWalker.CreateSplineWalker(MySpline, SplineWalker.SplineWalkerMode.Loop, 7); MySplineWalker.LoadContent(Editor.Content, Editor.Font); MySplineMarker = new Marker(); MySplineMarker.CreateSplineWalker(MySpline, SplineWalker.SplineWalkerMode.Once, 0, false, autoStart: false); MySplineMarker.LoadContent(Editor.Content); SetMultiSampleCount(8); Editor.SetDisplayStyle = Forms.Services.GFXService.DisplayStyle.TopRight; Editor.ShowCursorPosition = false; Editor.ShowFPS = false; }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; Reference r = uidoc.Selection.PickObject(ObjectType.Element, "Select Element"); Options geometryOptions = new Options(); geometryOptions.ComputeReferences = false; GeometryElement geomElem = doc.GetElement(r).get_Geometry(geometryOptions); List <NurbSpline> cadSplines = new List <NurbSpline>(); IList <XYZ> controlPoints = new List <XYZ>(); List <double> weights = new List <double>(); List <double> knots = new List <double>(); if (null != geomElem) { foreach (var o in geomElem) { GeometryInstance gi = o as GeometryInstance; GeometryElement instanceGeometryElement = gi.GetInstanceGeometry(); foreach (GeometryObject instanceObj in instanceGeometryElement) { if (instanceObj.GetType().ToString().Contains("NurbSpline")) { //TaskDialog.Show("r", instanceObj.GetType().ToString()); NurbSpline nurb = instanceObj as NurbSpline; cadSplines.Add(nurb); controlPoints = nurb.CtrlPoints; //weights = nurb.Weights; weights = nurb.Weights.Cast <double>().ToList(); //knots = nurb.Knots; knots = nurb.Knots.Cast <double>().ToList(); } break; } } } double scale = 0.3048; #region Test //List<XYZ> controlPoints = new List<XYZ>(); //controlPoints.Add(new XYZ(0 / scale, 0 / scale, 0 / scale)); //controlPoints.Add(new XYZ(5 / scale, 5 / scale, 2 / scale)); //controlPoints.Add(new XYZ(10 / scale, 10 / scale, 5 / scale)); //controlPoints.Add(new XYZ(15 / scale, 10 / scale, 5 / scale)); //controlPoints.Add(new XYZ(20 / scale, 5 / scale, 4 / scale)); //controlPoints.Add(new XYZ(25 / scale, 5 / scale, 3 / scale)); //List<double> weights = new List<double>(); //weights.Add(1.0); //weights.Add(1.0); //weights.Add(1.0); //weights.Add(1.0); //weights.Add(1.0); //weights.Add(1.0); //List<double> knots = new List<double>(); //knots.Add(0); //1revit //knots.Add(0); //2 //knots.Add(0); //3 //knots.Add(0); //4 //knots.Add(10.76); //5 //knots.Add(21.51); //6 //knots.Add(32.27); //7 //knots.Add(32.27); //knots.Add(32.27); //9 //knots.Add(32.27);//revit #endregion HermiteSpline hermspline = HermiteSpline.Create(controlPoints, false); //Curve nurbSpline = NurbSpline.Create(hermspline); Curve nurbSpline = NurbSpline.CreateCurve(3, knots, controlPoints, weights); //XYZ startPoint = nurbSpline.GetEndPoint(0); Transform nurbsTr = nurbSpline.ComputeDerivatives(0, true); XYZ startPoint = nurbsTr.Origin; //PrintPoint("a", nurbsTr.Origin); #region Test Plane //Plane geomPlane = Autodesk.Revit.DB.Plane.CreateByOriginAndBasis(nurbsTr.Origin, nurbsTr.BasisY.Normalize(), nurbsTr.BasisZ.Normalize()); //Plane geomPlane = Autodesk.Revit.DB.Plane.CreateByOriginAndBasis(nurbSpline.GetEndPoint(0), nurbsTr.BasisY.Normalize(), nurbsTr.BasisZ.Normalize()); //Frame f = new Frame(nurbSpline.GetEndPoint(0), nurbsTr.BasisY.Normalize(), nurbsTr.BasisZ.Normalize(), nurbsTr.BasisX.Normalize()); //Plane geomPlane = Autodesk.Revit.DB.Plane.CreateByThreePoints(XYZ.Zero, XYZ.BasisX, XYZ.BasisZ); //Plane geomPlane = Plane.CreateByNormalAndOrigin(nurbsTr.BasisX.Normalize(), nurbSpline.GetEndPoint(1)); funziona //Plane geomPlane = Plane.CreateByThreePoints(startPoint, startPoint + nurbsTr.BasisX.Normalize(), startPoint + XYZ.BasisZ); #endregion //XYZ curveDir = controlPoints[1] - controlPoints[0]; XYZ curveDir = nurbsTr.BasisX; XYZ perpDir = curveDir.CrossProduct(startPoint + XYZ.BasisZ).Normalize(); Plane perpPlane = Plane.CreateByNormalAndOrigin(curveDir, startPoint); //Plane vertPlane = Plane.CreateByThreePoints(startPoint, perpPlane.XVec, XYZ.BasisZ); Plane vertPlane = perpPlane; //PrintPoint("per", perpDir); List <PtCoord> pointsCoordinates = new List <PtCoord>(); using (var form = new FormAddActiveView("Enter coordinates in clockwise order")) { form.ShowDialog(); //if the user hits cancel just drop out of macro if (form.DialogResult == System.Windows.Forms.DialogResult.Cancel) { return(Result.Cancelled); } string[] inputs = form.TextString.Split(';'); foreach (string coord in inputs) { string[] xy = coord.Split(','); pointsCoordinates.Add(new PtCoord(Double.Parse(xy[0]) / (scale * 1000), Double.Parse(xy[1]) / (scale * 1000))); } } // List<PtCoord> pointsCoordinates = new List<PtCoord>(){new PtCoord(5,0), new PtCoord(2,2), new PtCoord(-14,0), new PtCoord(2,-2)}; List <XYZ> pts = VertexPoints(nurbsTr.Origin, pointsCoordinates, vertPlane); XYZ pt1 = nurbsTr.Origin; XYZ pt2 = pt1 + vertPlane.XVec * 5; XYZ pt3 = pt2 + vertPlane.YVec * 2 + vertPlane.XVec * 2; XYZ pt4 = pt3 - vertPlane.XVec * 12; XYZ pt5 = pt4 - vertPlane.YVec * 2 + vertPlane.XVec * 2; Line l1 = Line.CreateBound(pt1, pt2); Line l2 = Line.CreateBound(pt2, pt3); Line l3 = Line.CreateBound(pt3, pt4); Line l4 = Line.CreateBound(pt4, pt5); Line l5 = Line.CreateBound(pt5, pt1); // // var profileLoop = CurveLoop.Create(new List<Curve>{l1, l2, l3, l4, l5}); var profileLoop = LoopPoints(pts); //double rotAngle = -2.543 * Math.PI / 180; double rotAngle = -15 * Math.PI / 180; var transform = Transform.CreateRotationAtPoint(nurbsTr.BasisX, rotAngle, nurbsTr.Origin); profileLoop.Transform(transform); var loops = new List <CurveLoop> { profileLoop }; var path = CurveLoop.Create(new List <Curve> { nurbSpline }); WireframeBuilder builder = new WireframeBuilder(); builder.AddCurve(nurbSpline); //Solid solid = GeometryCreationUtilities.CreateSweptGeometry(path,0,nurbSpline.GetEndParameter(0),loops); Solid solid = GeometryCreationUtilities.CreateFixedReferenceSweptGeometry(path, 0, nurbSpline.GetEndParameter(0), loops, XYZ.BasisZ); using (Transaction t = new Transaction(doc, "create spline")) { t.Start(); ElementId categoryId = new ElementId(BuiltInCategory.OST_Floors); DirectShape ds = DirectShape.CreateElement(doc, categoryId); ds.SetShape(builder); ds.Name = "RhinoSpline"; SketchPlane sp = SketchPlane.Create(doc, vertPlane); uidoc.ActiveView.SketchPlane = sp; //uidoc.ActiveView.ShowActiveWorkPlane(); ModelLine line1 = doc.Create.NewModelCurve(l1, sp) as ModelLine; ModelLine line2 = doc.Create.NewModelCurve(l2, sp) as ModelLine; ModelLine line3 = doc.Create.NewModelCurve(l3, sp) as ModelLine; ModelLine line4 = doc.Create.NewModelCurve(l4, sp) as ModelLine; ModelLine line5 = doc.Create.NewModelCurve(l5, sp) as ModelLine; List <GeometryObject> gs = new List <GeometryObject>(); gs.Add(solid); //DirectShape directShape = DirectShape.CreateElement(doc, categoryId); ds.AppendShape(gs); t.Commit(); } return(Result.Succeeded); }
private ICurve HermiteSplineToSpeckle(HermiteSpline spline, string units = null) { var nurbs = DB.NurbSpline.Create(spline); return(NurbsToSpeckle(nurbs, units ?? ModelUnits)); }
internal void RecalculateLength() { HermiteSpline.ApproximateLength( Node.Position, Node.Rotation.ToEuler(), ForwardNode.Position, ForwardNode.Rotation.ToEuler()); }
public void SetSplineControllers(HermiteSpline startSpline, HermiteSpline cyclicSpline) { this.startSpline = startSpline; this.cyclicSpline = cyclicSpline; }
private void Stream(ArrayList data, HermiteSpline hermiteSpline) { data.Add(new Snoop.Data.ClassSeparator(typeof(HermiteSpline))); data.Add(new Snoop.Data.Enumerable("Control points", hermiteSpline.ControlPoints)); data.Add(new Snoop.Data.Bool("Is periodic", hermiteSpline.IsPeriodic)); data.Add(new Snoop.Data.Enumerable("Parameters", hermiteSpline.Parameters)); data.Add(new Snoop.Data.Enumerable("Tangents", hermiteSpline.Tangents)); }
protected override void OnPaint(PaintEventArgs e) { e.Graphics.Clear(BackColor); e.Graphics.SmoothingMode = SmoothingMode.HighQuality; ICurve <Vector2> spline = null; HermiteSpline <Vector2> hermite = null; switch (CurveMode.SelectedIndex) { default: case 0: case 1: var curve = new Curve <Vector2>(Spline.Points); curve.DefaultInterpolator = Interpolators <Vector2> .Linear; if (CurveMode.SelectedIndex == 1) { curve.DefaultInterpolator = Interpolators <Vector2> .Cubic; } spline = curve; break; case 2: spline = hermite = Spline; break; case 3: spline = hermite = HermiteSpline <Vector2> .CatmullRom( Spline.Points ); break; case 4: spline = hermite = HermiteSpline <Vector2> .Cardinal( Spline.Points, Tension.Value / 100f ); break; } using (var arrowPen = new Pen(Color.Blue, 2f)) { if (hermite != null) { foreach (var pt in hermite) { e.Graphics.DrawLine( arrowPen, pt.Value.X, pt.Value.Y, pt.Value.X + pt.Data.Velocity.X, pt.Value.Y + pt.Data.Velocity.Y ); } } } var mousePos = PointToClient(Cursor.Position); var closestPosition = spline.Search( (p, v) => (float)Math.Sqrt( Math.Pow(v.X - mousePos.X, 2) + Math.Pow(v.Y - mousePos.Y, 2) ) ); if ((hermite != null) && closestPosition.HasValue) { foreach (var split in hermite.Split(closestPosition.Value)) { DrawSpline(split, e.Graphics, Color.Yellow); } } else { DrawSpline(spline, e.Graphics, Color.White); } if (closestPosition.HasValue) { using (var closestPen = new Pen(Color.Green, 1.75f)) { var closestPoint = spline[closestPosition.Value]; e.Graphics.DrawLine( closestPen, mousePos.X, mousePos.Y, closestPoint.X, closestPoint.Y ); e.Graphics.DrawEllipse( closestPen, closestPoint.X - 3f, closestPoint.Y - 3f, 6f, 6f ); } } }
public override Expression Evaluate(FSharpList<Expression> args) { var pts = ((Expression.List)args[0]).Item; hs = null; FSharpList<Expression> containers = Utils.convertSequence(pts); List<XYZ> ctrlPts = new List<XYZ>(); foreach (Expression e in containers) { if (e.IsContainer) { XYZ pt = (XYZ)((Expression.Container)(e)).Item; ctrlPts.Add(pt); } } if (pts.Count() > 0) { hs = this.UIDocument.Application.Application.Create.NewHermiteSpline(ctrlPts, false); } return Expression.NewContainer(hs); }
public void SetSpline(HermiteSpline spline) { Spline = spline; RefreshSplinePoints(); }
private static bool AreSimilar(HermiteSpline a, HermiteSpline b, double tolerance) { return(CompareRandomParameterLocationDistances(a, b, tolerance)); }
public void SingleValue() { var c = new HermiteSpline<double> { {0, 5, 0} }; Assert.AreEqual(5.0, c[-1]); Assert.AreEqual(5.0, c[0]); Assert.AreEqual(5.0, c[1]); }
public void TwoValues() { var c = new HermiteSpline<double> { {0, 5, 0}, {1, 10, 0} }; Assert.AreEqual(5.0, c[-1]); Assert.AreEqual(5.0, c[0]); Assert.AreEqual(10.0, c[1]); Assert.AreEqual(10.0, c[2]); }
private bool ConvertHbCurve(HbCurve hbCurve, ref Curve curve) { try { curve = null; XYZ xyz1, xyz2, xyz3; if (hbCurve is HbLine) { HbLine hbLine = (HbLine)hbCurve; if (!ConvertHbXyz(hbLine.PointStart, out xyz1)) { return(false); } if (!ConvertHbXyz(hbLine.PointEnd, out xyz2)) { return(false); } curve = Line.CreateBound(xyz1, xyz2); } else if (hbCurve is HbArc) { HbArc hbArc = (HbArc)hbCurve; if (!ConvertHbXyz(hbArc.PointStart, out xyz1)) { return(false); } if (!ConvertHbXyz(hbArc.PointEnd, out xyz2)) { return(false); } if (!ConvertHbXyz(hbArc.PointMid, out xyz3)) { return(false); } curve = Arc.Create(xyz1, xyz2, xyz3); } else if (hbCurve is HbEllipse) { HbEllipse hbEllipse = (HbEllipse)hbCurve; if (!ConvertHbXyz(hbEllipse.PointFirst, out xyz1)) { return(false); } if (!ConvertHbXyz(hbEllipse.PointSecond, out xyz2)) { return(false); } XYZ center, xVec, yVec; double radX, radY, param0, param1; CalculateEllipsePoints(xyz1, xyz2, hbEllipse.RadiusY, hbEllipse.Mode, out center, out radX, out radY, out xVec, out yVec, out param0, out param1); curve = Ellipse.CreateCurve(center, radX, radY, xVec, yVec, param0, param1); //curve = Ellipse.Create(center, radX, radY, xVec, yVec, param0, param1); //2018 upgrade } else if (hbCurve is HbNurbSpline) { HbNurbSpline hbNurbSpline = (HbNurbSpline)hbCurve; List <XYZ> points = new List <XYZ>(); foreach (HbXYZ point in hbNurbSpline.Points) { if (!ConvertHbXyz(point, out xyz1)) { return(false); } points.Add(xyz1); } List <double> weights = new List <double>(); // Note that we are just using fixed weights for now. It doesn't appear that Revit is actually using these values anyway. for (int i = 0; i < hbNurbSpline.Points.Count; i++) { weights.Add(1.0); } //curve = NurbSpline.Create(points, weights); // Fails if < 4 points although manually can create with 2 or 3 points. curve = NurbSpline.CreateCurve(points, weights); //TODO This failed in older versions if < 4 points although manually can create with 2 or 3 points. Is this fixed in 2017? } else if (hbCurve is HbHermiteSpline) { HbHermiteSpline hbHermiteSpline = (HbHermiteSpline)hbCurve; List <XYZ> points = new List <XYZ>(); foreach (HbXYZ point in hbHermiteSpline.Points) { if (!ConvertHbXyz(point, out xyz1)) { return(false); } points.Add(xyz1); } curve = HermiteSpline.Create(points, false); } return(true); } catch (Exception exception) { this.ErrorMessage = "Error in ConvertHbCurve: " + exception.Message + "."; curve = null; return(false); } }
private ICurve HermiteSplineToSpeckle(HermiteSpline spline) { var nurbs = DB.NurbSpline.Create(spline); return(NurbsToSpeckle(nurbs)); }
Stream(ArrayList data, Curve crv) { data.Add(new Snoop.Data.ClassSeparator(typeof(Curve))); try { data.Add(new Snoop.Data.Double("Approximate length", crv.ApproximateLength)); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Approximate length", ex)); } try { data.Add(new Snoop.Data.Double("Length", crv.Length)); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Length", ex)); } try { data.Add(new Snoop.Data.Double("Period", crv.Period)); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Period", ex)); } try { data.Add(new Snoop.Data.Bool("Is bound", crv.IsBound)); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Is bound", ex)); } try { data.Add(new Snoop.Data.Bool("Is cyclic", crv.IsCyclic)); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Is cyclic", ex)); } try { data.Add(new Snoop.Data.Xyz("Start point", crv.GetEndPoint(0))); data.Add(new Snoop.Data.Xyz("End point", crv.GetEndPoint(1))); } catch (System.Exception) { // if the curve is unbound, those don't mean anything data.Add(new Snoop.Data.String("Start point", "N/A")); data.Add(new Snoop.Data.String("End point", "N/A")); } try { data.Add(new Snoop.Data.Double("Start parameter", crv.GetEndParameter(0))); data.Add(new Snoop.Data.Double("End parameter", crv.GetEndParameter(1))); } catch (System.Exception) { // if the curve is unbound, those don't mean anything data.Add(new Snoop.Data.String("Start parameter", "N/A")); data.Add(new Snoop.Data.String("End parameter", "N/A")); } try { data.Add(new Snoop.Data.Object("Start point reference", crv.GetEndPointReference(0))); data.Add(new Snoop.Data.Object("End point reference", crv.GetEndPointReference(1))); } catch (System.Exception) { // if the curve is unbound, those don't mean anything data.Add(new Snoop.Data.String("Start point reference", "N/A")); data.Add(new Snoop.Data.String("End point reference", "N/A")); } try { data.Add(new Snoop.Data.Object("Reference", crv.Reference)); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Reference", ex)); } try { data.Add(new Snoop.Data.Object("Derivative at Start", crv.ComputeDerivatives(0.0, normalized: true))); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Derivative at Start", ex)); } try { data.Add(new Snoop.Data.Object("Derivative at Center", crv.ComputeDerivatives(0.5, normalized: true))); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Derivative at Center", ex)); } try { data.Add(new Snoop.Data.Object("Derivative at End", crv.ComputeDerivatives(1.0, normalized: true))); } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Derivative at End", ex)); } try { data.Add(new Snoop.Data.CategorySeparator("Tesselated Points")); } catch { data.Add(new Snoop.Data.String("Tesselated Points", "N/A")); } try { System.Collections.Generic.IList <XYZ> pts = crv.Tessellate(); int i = 0; foreach (XYZ pt in pts) { data.Add(new Snoop.Data.Xyz(string.Format("PT [{0:d}]", i++), pt)); } } catch (System.Exception ex) { data.Add(new Snoop.Data.Exception("Xyz", ex)); } Line line = crv as Line; if (line != null) { Stream(data, line); return; } Arc arc = crv as Arc; if (arc != null) { Stream(data, arc); return; } Ellipse ellipse = crv as Ellipse; if (ellipse != null) { Stream(data, ellipse); return; } NurbSpline nurbSpline = crv as NurbSpline; if (nurbSpline != null) { Stream(data, nurbSpline); return; } HermiteSpline hermiteSpline = crv as HermiteSpline; if (hermiteSpline != null) { Stream(data, hermiteSpline); return; } }