• API
• FAQ
• Tools
• Archive
daily pastebin goal
46%
SHARE
TWEET

# Untitled

a guest Jul 12th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Autodesk.Revit.Creation.FamilyItemFactory.NewSweep()
2.
3. Autodesk.Revit.Exceptions.InvalidOperationException
4. The attempted operation is not permitted in this type of family.
5.
6. // sweepPath is a CurveByPoints instance.
7. if (null != sweepPath)
8.             {
9.                 acTrans.Start("Cable");
10.                 // create a circle as bottom shape for the cable
11.                 IList<XYZ> points = sweepPath.GeometryCurve.Tessellate();
12.                 XYZ center = points[0];
13.                 Plane workingPlane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, center);
14.                 Arc bottomShape = Arc.Create(workingPlane, _radius, 0, 2 * Math.PI);
15.
16.                 // create profile
17.                 CurveArray curveArray = new CurveArray();
18.                 curveArray.Append(bottomShape);
19.                 CurveArrArray arrArray = new CurveArrArray();
20.                 arrArray.Append(curveArray);
21.                 SweepProfile profile = _rvApp.Create.NewCurveLoopsProfile(arrArray) as SweepProfile;
22.
23.                 // create path
24.                 XYZ sweepPathDirection = points[1] - points[0];
25.                 double angle = sweepPathDirection.AngleTo(XYZ.BasisZ);
26.                 XYZ direction = sweepPathDirection.CrossProduct(XYZ.BasisZ);
27.                 Line axis = Line.CreateUnbound(center, direction);
28.                 ElementTransformUtils.RotateElement(familydoc, sweepPath.Id, axis, angle);
29.                 CurveArray path = new CurveArray();
30.                 path.Append(sweepPath.GeometryCurve);
31.
32.                 // create sketch plane
33.                 Plane plane = Plane.CreateByNormalAndOrigin(new XYZ(10, 0, 0), refPointArray.get_Item(0).Position);
34.                 SketchPlane pathPlane = SketchPlane.Create(familydoc, plane);
35.
36.                 // create the cable
37.                 // Sweep sweep = familydoc.FamilyCreate.NewSweep(true, curveArray, pathPlane, profile, 0, ProfilePlaneLocation.Start);
38.                 ReferenceArray refArray = new ReferenceArray();
39.                 refArray.Append(sweepPath.GeometryCurve.Reference);
40.                 Sweep sweep = familydoc.FamilyCreate.NewSweep(true, refArray, profile, 0, ProfilePlaneLocation.Start);
41.                 acTrans.Commit();
42.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top