Пример #1
0
        //族实例化,创建族并对其进行旋转
        private FamilyInstance CreateFamlyInstance(DG.Point DGpoint, DG.Curve curve, FamilySymbol FamilySymbol, ExternalCommandData commandData)
        {
            UIDocument uiDoc = commandData.Application.ActiveUIDocument; //取得当前活动文档

            XYZ point = DGpoint.ToRevitType(false);                      //dynamo转Revit

            FamilyInstance familyInstance = uiDoc.Document.Create.NewFamilyInstance(point, FamilySymbol, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
            LocationPoint  locationPoint  = familyInstance.Location as LocationPoint;//自适应族基点
            XYZ            axisP          = new XYZ(point.X, point.Y, point.Z + 100);

            Autodesk.Revit.DB.Line axis = Autodesk.Revit.DB.Line.CreateBound(point, axisP);//旋转轴

            //计算旋转角度
            double ratio = curve.ParameterAtPoint(DGpoint);

            DG.Vector vector = curve.TangentAtParameter(ratio);

            MessageBox.Show(vector.ToString());

            DG.Vector vector1 = DG.Vector.ByCoordinates(vector.X, vector.Y, 0);//三维切向量的平面向量
            DG.Vector vectorY = DG.Vector.ByCoordinates(0, 1, 0);
            double    angle   = vector1.AngleWithVector(vectorY) / 180 * Math.PI;

            MessageBox.Show(angle.ToString());
            //locationPoint.Rotate(axis, angle);//旋转横梁
            ElementTransformUtils.RotateElement(uiDoc.Document, familyInstance.Id, axis, -angle);

            return(familyInstance);
        }
Пример #2
0
 /// <summary>
 /// This function creates a list of cut planes;
 /// Initial cut plane is normal plane to curve at given origin
 /// and the rest of the planes are generated from the initial plane
 /// and the given spacing.
 /// </summary>
 /// <param name="curve"></param>
 /// <param name="origin"></param>
 /// <returns>List containing all cut planes</returns>
 public List<Plane> GenerateCutPlanes(Curve curve, double origin)
 {
     List<Plane> Planes = new List<Plane>();
     if (origin > 0) Planes.Add(Plane.ByOriginNormal(curve.PointAtParameter(origin), curve.TangentAtParameter(origin)));
     else Planes.Add(Plane.ByOriginNormal((Point)Solid.Intersect(curve)[0], curve.TangentAtParameter(curve.ParameterAtPoint((Point)Solid.Intersect(curve)[0]))));
     return Planes;
 }