Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Autodesk.Revit.Creation.FamilyItemFactory.NewSweep()
- Autodesk.Revit.Exceptions.InvalidOperationException
- The attempted operation is not permitted in this type of family.
- // sweepPath is a CurveByPoints instance.
- if (null != sweepPath)
- {
- acTrans.Start("Cable");
- // create a circle as bottom shape for the cable
- IList<XYZ> points = sweepPath.GeometryCurve.Tessellate();
- XYZ center = points[0];
- Plane workingPlane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, center);
- Arc bottomShape = Arc.Create(workingPlane, _radius, 0, 2 * Math.PI);
- // create profile
- CurveArray curveArray = new CurveArray();
- curveArray.Append(bottomShape);
- CurveArrArray arrArray = new CurveArrArray();
- arrArray.Append(curveArray);
- SweepProfile profile = _rvApp.Create.NewCurveLoopsProfile(arrArray) as SweepProfile;
- // create path
- XYZ sweepPathDirection = points[1] - points[0];
- double angle = sweepPathDirection.AngleTo(XYZ.BasisZ);
- XYZ direction = sweepPathDirection.CrossProduct(XYZ.BasisZ);
- Line axis = Line.CreateUnbound(center, direction);
- ElementTransformUtils.RotateElement(familydoc, sweepPath.Id, axis, angle);
- CurveArray path = new CurveArray();
- path.Append(sweepPath.GeometryCurve);
- // create sketch plane
- Plane plane = Plane.CreateByNormalAndOrigin(new XYZ(10, 0, 0), refPointArray.get_Item(0).Position);
- SketchPlane pathPlane = SketchPlane.Create(familydoc, plane);
- // create the cable
- // Sweep sweep = familydoc.FamilyCreate.NewSweep(true, curveArray, pathPlane, profile, 0, ProfilePlaneLocation.Start);
- ReferenceArray refArray = new ReferenceArray();
- refArray.Append(sweepPath.GeometryCurve.Reference);
- Sweep sweep = familydoc.FamilyCreate.NewSweep(true, refArray, profile, 0, ProfilePlaneLocation.Start);
- acTrans.Commit();
- }
Add Comment
Please, Sign In to add comment