本文整理汇总了C#中XYZ.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# XYZ.GetLength方法的具体用法?C# XYZ.GetLength怎么用?C# XYZ.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XYZ
的用法示例。
在下文中一共展示了XYZ.GetLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public Result Execute(
ExternalCommandData revit,
ref string message,
ElementSet elements)
{
UIApplication uiapp = revit.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
using( Transaction tx = new Transaction( doc ) )
{
tx.Start( "Create Sloped Slab" );
double width = 19.685039400;
double length = 59.055118200;
double height = 9.84251968503937;
XYZ[] pts = new XYZ[] {
new XYZ( 0.0, 0.0, height ),
new XYZ( width, 0.0, height ),
new XYZ( width, length, height ),
new XYZ( 0, length, height )
};
CurveArray profile
= uiapp.Application.Create.NewCurveArray();
Line line = null;
int n = pts.GetLength( 0 );
XYZ q = pts[n - 1];
foreach( XYZ p in pts )
{
line = Line.CreateBound( q, p );
profile.Append( line );
q = p;
}
Level level
= new FilteredElementCollector( doc )
.OfClass( typeof( Level ) )
.Where<Element>(
e => e.Name.Equals( "CreateSlopedSlab" ) )
.FirstOrDefault<Element>() as Level;
if( null == level )
{
level = doc.Create.NewLevel( height );
level.Name = "Sloped Slab";
}
Floor floor = doc.Create.NewSlab(
profile, level, line, 0.5, true );
tx.Commit();
}
return Result.Succeeded;
}
示例2: ToSphericalCoordinates
public static void ToSphericalCoordinates(XYZ input, out double r, out double theta, out double phi)
{
// set length
r = input.GetLength();
// if the length is too small the angles will be degenerate, just set them as 0
if (Math.Abs(r) < System.Double.Epsilon)
{
theta = 0;
phi = 0;
return;
}
// get the length of the projection on the xy plane
var rInXYPlane = (new XYZ(input.X, input.Y, 0)).GetLength();
// if projected length is 0, xyz is pointing up, down, or is origin
if (Math.Abs(rInXYPlane) < System.Double.Epsilon)
{
// this should have already been detected when r is 0, but check anyway
if (Math.Abs(input.Z) < System.Double.Epsilon)
{
theta = 0;
phi = 0;
return;
}
else // determine whether vector is above or below - if above phi is 0
{
theta = 0;
phi = input.Z > 0 ? 0 : Math.PI;
return;
}
}
// if x is 0, this indicates vector is at 90 or 270
if (Math.Abs(input.X) < System.Double.Epsilon)
{
theta = input.Y > 0 ? Math.PI / 2 : 3 * Math.PI / 2;
}
else
{
theta = Math.Atan(input.Y / input.X);
}
// phew...
phi = Math.Acos(input.Z / r);
}
示例3: DrawModelLineLoop
/// <summary>
/// Create model lines representing a closed
/// planar loop in the given sketch plane.
/// </summary>
static void DrawModelLineLoop(
SketchPlane sketchPlane,
XYZ[] corners)
{
Autodesk.Revit.Creation.Document factory
= sketchPlane.Document.Create;
int n = corners.GetLength( 0 );
for( int i = 0; i < n; ++i )
{
int j = 0 == i ? n - 1 : i - 1;
factory.NewModelCurve( Line.CreateBound(
corners[j], corners[i] ), sketchPlane );
}
}