本文整理汇总了C#中Autodesk.ControlPoints方法的典型用法代码示例。如果您正苦于以下问题:C# Autodesk.ControlPoints方法的具体用法?C# Autodesk.ControlPoints怎么用?C# Autodesk.ControlPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autodesk
的用法示例。
在下文中一共展示了Autodesk.ControlPoints方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
/// <summary>
/// Convert a DS BSplineCurve to a Revit NurbSpline
/// </summary>
/// <param name="crv"></param>
/// <returns></returns>
private static Autodesk.Revit.DB.Curve Convert(Autodesk.DesignScript.Geometry.NurbsCurve crv)
{
if (crv.Degree == 1 && crv.ControlPoints().Length == 2 && !crv.IsRational)
{
return Autodesk.Revit.DB.Line.CreateBound(crv.ControlPoints()[0].ToXyz(),
crv.ControlPoints()[1].ToXyz());
}
if (crv.Degree <= 2)
{
throw new Exception("Could not convert the curve to a Revit curve");
}
// presumably checking if the curve is circular is quite expensive, we don't do it
return Autodesk.Revit.DB.NurbSpline.Create(crv.ControlPoints().ToXyzs(),
crv.Weights(),
crv.Knots(),
crv.Degree,
crv.IsClosed,
crv.IsRational );
}
示例2: Convert
private static Autodesk.Revit.DB.Curve Convert(Autodesk.DesignScript.Geometry.NurbsCurve crv)
{
// line
if (crv.Degree == 1 && crv.ControlPoints().Length == 2 && !crv.IsRational)
{
return Autodesk.Revit.DB.Line.CreateBound(crv.ControlPoints()[0].ToXyz(false),
crv.ControlPoints()[1].ToXyz(false));
}
// polyline - not allowed
if (crv.Degree == 1)
{
throw new Exception(
"Degree 1 Nurbs Curves are not allowed in Revit! Try splitting the curve into "
+
"individual linear pieces");
}
// bezier
if (crv.Degree == 2 && crv.ControlPoints().Count() == 3 && !crv.IsRational)
{
var converted = NurbsUtils.ElevateBezierDegree(crv, 3);
return Autodesk.Revit.DB.NurbSpline.Create(converted.ControlPoints().ToXyzs(false),
converted.Weights(),
converted.Knots(),
converted.Degree,
converted.IsClosed,
converted.IsRational);
}
// degree 2 curve
if (crv.Degree == 2)
{
// TODO: general NURBS degree elevation
var numSamples = crv.ControlPoints().Count() + 1;
var pts = Enumerable.Range(0, numSamples).Select(x => x/(double)numSamples)
.Select(crv.PointAtParameter);
var resampledCrv = NurbsCurve.ByPointsTangents(
pts,
crv.TangentAtParameter(0).Normalized(),
crv.TangentAtParameter(1).Normalized());
return Autodesk.Revit.DB.NurbSpline.Create(resampledCrv.ControlPoints().ToXyzs(false),
resampledCrv.Weights(),
resampledCrv.Knots(),
resampledCrv.Degree,
resampledCrv.IsClosed,
resampledCrv.IsRational);
}
// general implementation
return Autodesk.Revit.DB.NurbSpline.Create(crv.ControlPoints().ToXyzs(false),
crv.Weights(),
crv.Knots(),
crv.Degree,
crv.IsClosed,
crv.IsRational);
}