本文整理汇总了C#中XYZ类的典型用法代码示例。如果您正苦于以下问题:C# XYZ类的具体用法?C# XYZ怎么用?C# XYZ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XYZ类属于命名空间,在下文中一共展示了XYZ类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Application revit = commandData.Application;
Document curDoc = revit.ActiveDocument;
FamilySymbol symbol = null;
ElementSetIterator selIt = curDoc.Selection.Elements.ForwardIterator();
if (selIt.MoveNext())
{
FamilyInstance fi = selIt.Current as FamilyInstance;
symbol = fi.Symbol;
}
if (symbol == null)
{
message = "Please select a family instance!";
return IExternalCommand.Result.Cancelled;
}
XYZ startPoint = new XYZ(0, 30, 0);
FamilyInstance createdFamily = curDoc.Create.NewFamilyInstance(ref startPoint, symbol, Autodesk.Revit.Structural.Enums.StructuralType.UnknownFraming);
if (null == createdFamily)
{
message = "Create the family failed.";
return IExternalCommand.Result.Failed;
}
return IExternalCommand.Result.Succeeded;
}
示例2: ConvertBasePoint
/// <summary>
//MOVES THE CAMERA ACCORDING TO THE PROJECT BASE LOCATION
//function that changes the coordinates accordingly to the project base location to an absolute location (for BCF export)
//if the value negative is set to true, does the opposite (for opening BCF views)
/// </summary>
/// <param name="c">center</param>
/// <param name="view">view direction</param>
/// <param name="up">up direction</param>
/// <param name="negative">convert to/from</param>
/// <returns></returns>
public static ViewOrientation3D ConvertBasePoint(Document doc, XYZ c, XYZ view, XYZ up, bool negative)
{
//UIDocument uidoc = uiapp.ActiveUIDocument;
//Document doc = uidoc.Document;
//ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_ProjectBasePoint);
//FilteredElementCollector collector = new FilteredElementCollector(doc);
//System.Collections.Generic.IEnumerable<Element> elements = collector.WherePasses(filter).ToElements();
double angle = 0;
double x = 0;
double y = 0;
double z = 0;
//VERY IMPORTANT
//BuiltInParameter.BASEPOINT_EASTWEST_PARAM is the value of the BASE POINT LOCATION
//position is the location of the BPL related to Revit's absolute origini!
//if BPL is set to 0,0,0 not always it corresponds to Revit's origin
ProjectLocation projectLocation = doc.ActiveProjectLocation;
XYZ origin = new XYZ(0, 0, 0);
ProjectPosition position = projectLocation.get_ProjectPosition(origin);
int i = (negative) ? -1 : 1;
//foreach (Element element in elements)
//{
// MessageBox.Show(UnitUtils.ConvertFromInternalUnits(position.EastWest, DisplayUnitType.DUT_METERS).ToString() + " " + element.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsValueString() + "\n" +
// UnitUtils.ConvertFromInternalUnits(position.NorthSouth, DisplayUnitType.DUT_METERS).ToString() + " " + element.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsValueString() + "\n" +
// UnitUtils.ConvertFromInternalUnits(position.Elevation, DisplayUnitType.DUT_METERS).ToString() + " " + element.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsValueString() + "\n" +
// position.Angle.ToString() + " " + element.get_Parameter(BuiltInParameter.BASEPOINT_ANGLETON_PARAM).AsDouble().ToString());
//}
x = i * position.EastWest;
y = i * position.NorthSouth;
z = i * position.Elevation;
angle = i * position.Angle;
if (negative) // I do the addition BEFORE
c = new XYZ(c.X + x, c.Y + y, c.Z + z);
//rotation
double centX = (c.X * Math.Cos(angle)) - (c.Y * Math.Sin(angle));
double centY = (c.X * Math.Sin(angle)) + (c.Y * Math.Cos(angle));
XYZ newC = new XYZ();
if (negative)
newC = new XYZ(centX, centY, c.Z);
else // I do the addition AFTERWARDS
newC = new XYZ(centX + x, centY + y, c.Z + z);
double viewX = (view.X * Math.Cos(angle)) - (view.Y * Math.Sin(angle));
double viewY = (view.X * Math.Sin(angle)) + (view.Y * Math.Cos(angle));
XYZ newView = new XYZ(viewX, viewY, view.Z);
double upX = (up.X * Math.Cos(angle)) - (up.Y * Math.Sin(angle));
double upY = (up.X * Math.Sin(angle)) + (up.Y * Math.Cos(angle));
XYZ newUp = new XYZ(upX, upY, up.Z);
return new ViewOrientation3D(newC, newUp, newView);
}
示例3: CreateDimensionElement
/// <summary>
/// Create a new dimension element using the given
/// references and dimension line end points.
/// This method opens and commits its own transaction,
/// assuming that no transaction is open yet and manual
/// transaction mode is being used.
/// Note that this has only been tested so far using
/// references to surfaces on planar walls in a plan
/// view.
/// </summary>
public static void CreateDimensionElement(
View view,
XYZ p1,
Reference r1,
XYZ p2,
Reference r2)
{
Document doc = view.Document;
ReferenceArray ra = new ReferenceArray();
ra.Append( r1 );
ra.Append( r2 );
Line line = Line.CreateBound( p1, p2 );
using( Transaction t = new Transaction( doc ) )
{
t.Start( "Create New Dimension" );
Dimension dim = doc.Create.NewDimension(
view, line, ra );
t.Commit();
}
}
示例4: PointStringMm
/// <summary>
/// Возвращает строку для трехмерной точки XYZ
/// или вектора с координатами этой точки
/// преобразованную из футов в миллиметры
/// и отформатированную до двух знаков после запятой
/// </summary>
public static string PointStringMm( XYZ p )
{
return string.Format( "({0};{1};{2})",
RealString( p.X * _foot_to_mm ),
RealString( p.Y * _foot_to_mm ),
RealString( p.Z * _foot_to_mm ) );
}
示例5: Execute
public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Application revit = commandData.Application;
Document curDoc = revit.ActiveDocument;
//配置几何曲线
CurveArray curves = new CurveArray();
if (null == curves)
{
message = "Create the curves failed.";
return IExternalCommand.Result.Failed;
}
XYZ first = new XYZ(0, 0, 0);
XYZ second = new XYZ(10, 0, 0);
XYZ third = new XYZ(10, 10, 0);
XYZ fourth = new XYZ(0, 10, 0);
curves.Append(revit.Create.NewLine(ref first, ref second, true));
curves.Append(revit.Create.NewLine(ref second, ref third, true));
curves.Append(revit.Create.NewLine(ref third, ref fourth, true));
curves.Append(revit.Create.NewLine(ref fourth, ref first, true));
// 利用几何曲线,类型,标高等创建地板对象
Floor createdFloor = curDoc.Create.NewFloor(curves, true);
if (null == createdFloor)
{
message = "Create floor failed.!";
return IExternalCommand.Result.Failed;
}
return IExternalCommand.Result.Succeeded;
}
示例6: ParseXYZ
/// <summary>
/// de-serialize vector passed from UI trough options
/// </summary>
private static XYZ ParseXYZ(string value)
{
XYZ retVal = null;
//split string to components by removing seprator characters
string[] separator = new string[] { ",", "(", ")", " " };
string[] sList = new string[3] { "", "", "" };
sList = value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
//should remain only 3 values if everything is OK
try
{
double valX = double.Parse(sList[0]); //parsing values
double valY = double.Parse(sList[1]);
double valZ = double.Parse(sList[2]);
//if no exception then put it in return value
retVal = new XYZ(valX, valY, valZ);
}
catch (FormatException)
{
}
//return null if there is a problem or a value
return retVal;
}
示例7: CreateHelix
public void CreateHelix()
{
double increment = 0.1;
double current = 0;
XYZ startPt;
XYZ endPt;
XYZ zAxis = GeomUtils.kZAxis;
XYZ origin = GeomUtils.kOrigin;
Line line;
Plane plane = m_revitApp.Application.Create.NewPlane(zAxis, origin);
SketchPlane sketchPlane = SketchPlane.Create(m_revitApp.ActiveUIDocument.Document, plane);
CurveArray curveArray = new CurveArray();
startPt = new XYZ(Math.Cos(current), Math.Sin(current), current);
current += increment;
while (current <= GeomUtils.kTwoPi) {
endPt = new XYZ(Math.Cos(current), Math.Sin(current), current);
line = Line.CreateBound(startPt, endPt);
curveArray.Append(line);
startPt = endPt;
current += increment;
}
m_revitApp.ActiveUIDocument.Document.Create.NewModelCurveArray(curveArray, sketchPlane);
}
示例8: NewMaxBound
private static XYZ NewMaxBound(XYZ oldMaxBound, IList<XYZ> vertices)
{
XYZ maxBound = oldMaxBound;
foreach (XYZ vertex in vertices)
maxBound = new XYZ(Math.Max(maxBound.X, vertex.X), Math.Max(maxBound.Y, vertex.Y), Math.Max(maxBound.Z, vertex.Z));
return maxBound;
}
示例9: BuildOrientation3D
/// <summary>
/// Build Orientation3D object for eye point and a target point
/// </summary>
/// <param name="eyePoint"></param>
/// <param name="target"></param>
/// <returns></returns>
protected static ViewOrientation3D BuildOrientation3D(XYZ eyePoint, XYZ target)
{
var globalUp = XYZ.BasisZ;
var direction = target.Subtract(eyePoint);
var up = direction.CrossProduct(globalUp).CrossProduct(direction);
return new ViewOrientation3D(eyePoint, up, direction);
}
示例10: ImportInstance
internal ImportInstance(string satPath, XYZ translation = null)
{
translation = translation ?? XYZ.Zero;
TransactionManager.Instance.EnsureInTransaction(Document);
var options = new SATImportOptions()
{
Unit = ImportUnit.Foot
};
var id = Document.Import(satPath, options, Document.ActiveView);
var element = Document.GetElement(id);
var importInstance = element as Autodesk.Revit.DB.ImportInstance;
if (importInstance == null)
{
throw new Exception("Could not obtain ImportInstance from imported Element");
}
InternalSetImportInstance(importInstance);
InternalUnpinAndTranslateImportInstance(translation);
this.Path = satPath;
TransactionManager.Instance.TransactionTaskDone();
}
示例11: nextMove
private void nextMove()
{
lock (this) {
if (this.endPosition != null && !this.position.Equals (this.endPosition)) {
double realSpeed = this.speed / 1000.0 * moving.Interval;
double distance = getDistance (endPosition, position);
double u = realSpeed / (distance - realSpeed);
XYZ<double> nextPosition = new XYZ<double> (0, 0, 0);
nextPosition.x = (position.x + u * endPosition.x) / (1 + u);
nextPosition.y = (position.y + u * endPosition.y) / (1 + u);
nextPosition.z = (position.z + u * endPosition.z) / (1 + u);
this.position = nextPosition;
if (realSpeed >= distance)
this.position = this.endPosition;
this.minecraft.SendPacket (new object[] {
(byte)PacketID.PlayerPosition,
this.position.x,
this.position.y,
this.position.y + this.height,
this.position.z,
this.onGround
}
);
this.minecraft.map.updateMap ();
}
}
}
示例12: apply
public void apply()
{
if (m_particleA.isFree() || m_particleB.isFree())
{
XYZ a2b = m_particleA.getPosition().Subtract(m_particleB.getPosition());
double a2bDistance = Math.Abs(Math.Sqrt(a2b.X * a2b.X + a2b.Y * a2b.Y + a2b.Z * a2b.Z)); // MDJ vector norm http://mathworld.wolfram.com/VectorNorm.html != a2b.Normalize();
if (a2bDistance == 0)
{
a2b = new XYZ(0, 0, 0);
}
else
{
a2b = a2b / a2bDistance;
}
double springForce = -(a2bDistance - m_restLength) * m_springConstant;
XYZ Va2b = m_particleA.getVelocity() - m_particleB.getVelocity();
double dampingForce = -m_Damping * (a2b.DotProduct(Va2b));
// forceB is same as forceA in opposite direction
double r = springForce + dampingForce;
a2b = a2b * r;
if (m_particleA.isFree())
m_particleA.addForce(a2b);
if (m_particleB.isFree())
m_particleB.addForce(-a2b);
}
}
示例13: Evaluate
public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
{
var t = (Transform)((FScheme.Value.Container)args[0]).Item;
double width = ((FScheme.Value.Number)args[1]).Item;
double height = ((FScheme.Value.Number)args[2]).Item;
//ccw from upper right
var p0 = new XYZ(width / 2, height / 2, 0);
var p3 = new XYZ(-width / 2, height / 2, 0);
var p2 = new XYZ(-width / 2, -height / 2, 0);
var p1 = new XYZ(width / 2, -height / 2, 0);
p0 = t.OfPoint(p0);
p1 = t.OfPoint(p1);
p2 = t.OfPoint(p2);
p3 = t.OfPoint(p3);
var l1 = dynRevitSettings.Doc.Application.Application.Create.NewLineBound(p0, p1);
var l2 = dynRevitSettings.Doc.Application.Application.Create.NewLineBound(p1, p2);
var l3 = dynRevitSettings.Doc.Application.Application.Create.NewLineBound(p2, p3);
var l4 = dynRevitSettings.Doc.Application.Application.Create.NewLineBound(p3, p0);
var cl = new Autodesk.Revit.DB.CurveLoop();
cl.Append(l1);
cl.Append(l2);
cl.Append(l3);
cl.Append(l4);
return FScheme.Value.NewContainer(cl);
}
示例14: CreateAxis
/// <summary>
/// Creates IfcAxis2Placement3D object.
/// </summary>
/// <param name="file">
/// The IFC file.
/// </param>
/// <param name="origin">
/// The origin.
/// </param>
/// <param name="zDirection">
/// The Z direction.
/// </param>
/// <param name="xDirection">
/// The X direction.
/// </param>
/// <returns>
/// The handle.
/// </returns>
public static IFCAnyHandle CreateAxis(IFCFile file, XYZ origin, XYZ zDirection, XYZ xDirection)
{
IFCAnyHandle directionOpt = IFCAnyHandle.Create();
IFCAnyHandle refOpt = IFCAnyHandle.Create();
IFCAnyHandle location = IFCAnyHandle.Create();
if (origin != null)
{
IList<double> measure = new List<double>();
measure.Add(origin.X); measure.Add(origin.Y); measure.Add(origin.Z);
location = CreateCartesianPoint(file, measure);
}
else
{
location = ExporterIFCUtils.GetGlobal3DOriginHandle();
}
bool exportzDirectionAndxDirection = (zDirection != null && xDirection != null && (!MathUtil.IsAlmostEqual(zDirection[2], 1.0) || !MathUtil.IsAlmostEqual(xDirection[0], 1.0)));
if (exportzDirectionAndxDirection)
{
IList<double> axisPts = new List<double>();
axisPts.Add(zDirection.X); axisPts.Add(zDirection.Y); axisPts.Add(zDirection.Z);
directionOpt = CreateDirection(file, axisPts);
}
if (exportzDirectionAndxDirection)
{
IList<double> axisPts = new List<double>();
axisPts.Add(xDirection.X); axisPts.Add(xDirection.Y); axisPts.Add(xDirection.Z);
refOpt = CreateDirection(file, axisPts);
}
return file.CreateAxis2Placement3D(location, directionOpt, refOpt);
}
示例15: GetClosestFace
public static Tuple<Face, Reference> GetClosestFace(Document document, XYZ p)
{
Face resultFace = null;
Reference resultReference = null;
double min_distance = double.MaxValue;
FilteredElementCollector collector = new FilteredElementCollector(document);
var walls = collector.OfClass(typeof (Wall));
foreach (Wall wall in walls)
{
IList<Reference> sideFaces =
HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior);
// access the side face
Face face = document.GetElement(sideFaces[0]).GetGeometryObjectFromReference(sideFaces[0]) as Face;
var intersection = face.Project(p);
if (intersection != null)
{
if (intersection.Distance < min_distance)
{
resultFace = face;
resultReference = sideFaces[0];
min_distance = intersection.Distance;
}
}
}
//resultFace.
return new Tuple<Face,Reference>( resultFace, resultReference);
}