public void Rotate_ZAxis() { var famSym = FamilyType.ByName("Box"); var pt = Point.ByCoordinates(0, 1, 2); var famInst = FamilyInstance.ByPoint(famSym, pt); Assert.NotNull(famInst); var transform = famInst.InternalFamilyInstance.GetTransform(); double[] rotationAngles; TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles); Assert.AreEqual(0.0, rotationAngles[0]); RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument.Regenerate(); famInst.SetRotation(30); transform = famInst.InternalFamilyInstance.GetTransform(); TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles); Assert.AreEqual(30.0, rotationAngles[0] * 180 / Math.PI, 1.0e-6); famInst.SetRotation(60); transform = famInst.InternalFamilyInstance.GetTransform(); TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles); Assert.AreEqual(60.0, rotationAngles[0] * 180 / Math.PI, 1.0e-6); }
/// <summary> /// Create a column. /// </summary> /// <param name="curve">The curve which defines the center line of the column.</param> /// <param name="level">The level with which you'd like the column to be associated.</param> /// <param name="structuralColumnType">The structural column type representing the column.</param> /// <returns></returns> public static StructuralFraming ColumnByCurve( Autodesk.DesignScript.Geometry.Curve curve, Revit.Elements.Level level, Revit.Elements.FamilyType structuralColumnType) { if (curve == null) { throw new System.ArgumentNullException("curve"); } if (level == null) { throw new System.ArgumentNullException("level"); } if (structuralColumnType == null) { throw new System.ArgumentNullException("structuralColumnType"); } var start = curve.PointAtParameter(0); var end = curve.PointAtParameter(1); // Revit will throw an exception if you attempt to create a column whose // base is above its top. if (end.Z <= start.Z) { throw new Exception(Properties.Resources.InvalidColumnBaseLocation); } return(new StructuralFraming(curve.ToRevitType(), level.InternalLevel, Autodesk.Revit.DB.Structure.StructuralType.Column, structuralColumnType.InternalFamilySymbol)); }
public void FacingOrientation() { var famSym = FamilyType.ByName("Box"); var pt = Point.ByCoordinates(0, 1, 2); var famInst = FamilyInstance.ByPoint(famSym, pt); Assert.NotNull(famInst); var dir = famInst.FacingOrientation; dir.IsAlmostEqualTo(Vector.ByCoordinates(0.0, 0.0, 1.0)); }
public void ByCoordinates_ProducesValidFamilyInstanceWithCorrectLocation() { var famSym = FamilyType.ByName("Box"); var famInst = FamilyInstance.ByCoordinates(famSym, 0, 1, 2); Assert.NotNull(famInst); var position = famInst.Location; position.ShouldBeApproximately(Point.ByCoordinates(0, 1, 2)); // no unit conversion var internalPos = InternalLocation(famInst.InternalElement as Autodesk.Revit.DB.FamilyInstance); (internalPos * UnitConverter.HostToDynamoFactor(UnitType.UT_Length)).ShouldBeApproximately( Point.ByCoordinates(0, 1, 2)); }
public void ByPoint_NullPoint() { var famSym = FamilyType.ByName("Box"); Assert.Throws(typeof(System.ArgumentNullException), () => FamilyInstance.ByPoint(famSym, null)); }
/// <summary> /// Create a brace. /// </summary> /// <param name="curve">The cruve which defines the center line of the brace.</param> /// <param name="level">The level with which you'd like the brace to be associated.</param> /// <param name="structuralFramingType">The structural framing type representing the brace.</param> /// <returns></returns> public static StructuralFraming BraceByCurve(Autodesk.DesignScript.Geometry.Curve curve, Revit.Elements.Level level, Revit.Elements.FamilyType structuralFramingType) { if (curve == null) { throw new System.ArgumentNullException("curve"); } if (level == null) { throw new System.ArgumentNullException("level"); } if (structuralFramingType == null) { throw new System.ArgumentNullException("structuralFramingType"); } return(new StructuralFraming(curve.ToRevitType(), level.InternalLevel, Autodesk.Revit.DB.Structure.StructuralType.Brace, structuralFramingType.InternalFamilySymbol)); }