public static StructuralFraming ByCurveLevelUpVectorAndType(Autodesk.DesignScript.Geometry.Curve curve, Level level, Autodesk.DesignScript.Geometry.Vector upVector, StructuralType structuralType, FamilyType structuralFramingType) { if (curve == null) { throw new System.ArgumentNullException("curve"); } if (level == null) { throw new System.ArgumentNullException("level"); } if (upVector == null) { throw new System.ArgumentNullException("upVector"); } if (structuralFramingType == null) { throw new System.ArgumentNullException("structuralFramingType"); } return(new StructuralFraming(curve.ToRevitType(), upVector.ToXyz(), level.InternalLevel, structuralType.ToRevitType(), structuralFramingType.InternalFamilySymbol)); }
/// <summary> /// Place a Revit family instance given the FamilyType (also known as the FamilySymbol in the Revit API) /// on a surface derived from a backing Revit face as reference, a reference direction and a point location where to place the family. /// /// Note: The FamilyType should be workplane based and the input surface must be created from a Revit Face. The reference direction defines the rotation of the instance on the reference, and thus cannot be perpendicular to the face. /// </summary> /// <param name="familyType">Family Type. Also called Family Symbol.</param> /// <param name="face">Surface geometry derived from a Revit face as reference element</param> /// <param name="location">Point on the face where the instance is to be placed</param> /// <param name="referenceDirection">A vector that defines the direction of placement of the family instance</param> /// <returns>FamilyInstance</returns> public static FamilyInstance ByFace(FamilyType familyType, Surface face, Point location, Vector referenceDirection) { if (familyType == null) { throw new ArgumentNullException("familyType"); } if (face == null) { throw new ArgumentNullException("face"); } if (location == null) { throw new ArgumentNullException("location"); } if (referenceDirection == null) { throw new ArgumentNullException("referenceDirection"); } var reference = ElementFaceReference.TryGetFaceReference(face); return(new FamilyInstance(familyType.InternalFamilySymbol, reference.InternalReference, location.ToXyz(), referenceDirection.ToXyz())); }
/// <summary> /// Create a Dimension for an Element in the specified direction and view. /// </summary> /// <param name="view">View to place dimension in</param> /// <param name="element">The element of generated Dimension</param> /// <param name="direction">The direction to create Dimension</param> /// <param name="line">location of the dimension</param> /// <param name="suffix">Suffix</param> /// <param name="prefix">Prefix</param> /// <returns></returns> public static Dimension ByElementDirection(Revit.Elements.Views.View view, Revit.Elements.Element element, Autodesk.DesignScript.Geometry.Vector direction, [DefaultArgument("null")] Autodesk.DesignScript.Geometry.Line line, string suffix = "", string prefix = "") { var revitDirection = direction.ToRevitType(); List <Autodesk.Revit.DB.PlanarFace> planars = new List <PlanarFace>(); ReferenceArray array = new ReferenceArray(); var opt = new Options(); opt.ComputeReferences = true; var faces = element.InternalGeometry(false).OfType <Autodesk.Revit.DB.Solid>().SelectMany(x => x.Faces.OfType <Autodesk.Revit.DB.PlanarFace>()); var references = faces.Select(x => x.Reference); Line revitLine = null; foreach (var face in faces) { var isParallel = direction.IsParallel(face.FaceNormal.ToVector()); if (isParallel) { array.Append(face.Reference); planars.Add(face); } } if (planars.Count < 2) { throw new Exception(string.Format(Properties.Resources.NotEnoughDataError, "Surface on this Direction")); } if (line == null) { revitLine = Line.CreateBound(planars[0].Origin, planars[0].Origin.Add(direction.ToXyz())); } else { revitLine = (Line)line.ToRevitType(true); } return(new Dimension(view.InternalView, revitLine, array, suffix, prefix)); }