- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
after successfully creating sweeps in a Project doc, with support from Revitalizer, I decided to try this in a Family doc.
I managed to create the sweep Profile, and transform it so that it is perpendicular to the sweep path, see pic:
In order to call FamilyCreate.NewSweep, I created the following parameters:
path,
pathPlane_l,
sweepProfile_l,
The path Parameter is a circle as follows:
CurveArray path = new CurveArray();
XYZ Center = new XYZ(0,0,0);
double planeRadius = 2d;
Plane plane = new Plane(XYZ.BasisZ, center);
Arc arc1 = Arc.Create(plane, planeRadius, 0.0, Math.PI);
Arc arc2 = Arc.Create(plane, planeRadius, Math.PI, Math.PI * 2);
path.Append(arc1);
path.Append(arc2);
The SketchPlane is as follows:
SketchPlane pathPlane_l = SketchPlane.Create(famDoc, plane);
The sweep Profile is created as follows:
var _profilepoints = new List<XYZ>() {
MmToFootPoint(new XYZ(-10,0,0)),
MmToFootPoint(new XYZ(-11.36,-7.7,0)),
MmToFootPoint(new XYZ(-14.15,-10.49,0)),
MmToFootPoint(new XYZ(-13,-16.5,0)),
MmToFootPoint(new XYZ(-11,-16.5,0)),
MmToFootPoint(new XYZ(-10.27,-13.78,0)),
MmToFootPoint(new XYZ(-9.41,-12.5,0)),
MmToFootPoint(new XYZ(-7.95,-12,0)),
MmToFootPoint(new XYZ(-6.49,-12.5,0)),
MmToFootPoint(new XYZ(-5.63,-13.78,0)),
MmToFootPoint(new XYZ(-4.91,-16.5,0)),
MmToFootPoint(new XYZ(-2.91,-16.5,0)),
MmToFootPoint(new XYZ(-2.18,-13.78,0)),
MmToFootPoint(new XYZ(-1.4,-12.5,0)),
MmToFootPoint(new XYZ(0,-12,0)),
MmToFootPoint(new XYZ(1.4,-12.5 ,0)),
MmToFootPoint(new XYZ(2.18,-13.78,0)),
MmToFootPoint(new XYZ(2.91,-16.5,0)),
MmToFootPoint(new XYZ(4.91,-16.5,0)),
MmToFootPoint(new XYZ(5.63,-13.78,0)),
MmToFootPoint(new XYZ(6.49,-12.5,0)),
MmToFootPoint(new XYZ(7.95,-12,0)),
MmToFootPoint(new XYZ(9.41,-12.5,0)),
MmToFootPoint(new XYZ(10.27,-13.78,0)),
MmToFootPoint(new XYZ(11,-16.5,0)),
MmToFootPoint(new XYZ(13,-16.5,0)),
MmToFootPoint(new XYZ(14.15,-10.49,0)),
MmToFootPoint(new XYZ(11.36,-7.7,0)),
MmToFootPoint(new XYZ(10,0,0)),
MmToFootPoint(new XYZ(-10,0,0))
};
profileLoop = new CurveLoop();
for (int i = 0; i < (_profilepoints.Count - 1); i++)
{
Line line = Line.CreateBound(_profilepoints[i], _profilepoints[i + 1]);
profileLoop.Append(line);
}
//transform it into the sweep plane
var tangent = initV.Direction.CrossProduct(XYZ.BasisZ);
//translate the profile to the starting point
var startingPointOfSweep = initV.GetEndPoint(0);
Curve curve = profileLoop.First();
var startPointOfProfile = curve.GetEndPoint(0);
var translation = startingPointOfSweep - startPointOfProfile;
var transform = Transform.CreateTranslation(translation);
profileLoop.Transform(transform);
//flip the profile vertical around this tangent
transform = Transform.CreateRotationAtPoint(tangent, Math.PI / 2.0, startingPointOfSweep);
profileLoop.Transform(transform);
CurveArray arr = new CurveArray();
foreach (var item in profileLoop)
{
arr.Append(item);
start = item.GetEndPoint(0); ;
fin = item.GetEndPoint(1);
var l_ = Creator.CreateModelLine(famDoc, start, fin);
}
curveArrArr.Clear();
curveArrArr.Append(arr);
SweepProfile sweepProfile_l = famDoc.Application.Create.NewCurveLoopsProfile(curveArrArr);
This call cracks:
Sweep solid = famDoc.FamilyCreate.NewSweep(
true,
path,
pathPlane_l,
sweepProfile_l,
0,
ProfilePlaneLocation.Start);
Error message:
{"One of the conditions for the inputs was not satisfied. Consult the documentation for requirements for each argument."} System.Exception {Autodesk.Revit.Exceptions.ArgumentException}
What am I doing wrong?
Regards,Dirk
Solved! Go to Solution.