Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to draw a sweep Profile in a Project document using
GeometryCreationUtilities.CreateSweptGeometry and DirectShape.CreateElement
When I use a straight line for the sweepPath, all goes well. However, when I use an Arc, I get the following error:
exc = {"The Curve Loop does not lie in the plane orthogonal to the projPlaneNorm.\r\nParameter name: profileLoops"}I suspect that the error comes from creating the SweepProfile on a plane which is not perpendicular to the Initial Gradient of the Arc.
In the method, I tesselate() the Arc, which somes in as a Curve, and then use the first line Segment as a Normal to determine the plane on which the SweepProfile is created.
So the question is, how do I obtain the Initial Gradient of an Arc, without using the line segments from the Tesselate() function?
Dirk
Here is the call wo the method:
ModelArc upperArc = CreateModelCurve(doc, planeTop, arc_top); CurveLoop sweepes = new CurveLoop(); sweepes.Append(upperArc.GeometryCurve); Solid seal = sealProfile(doc, fi, sweepes);
Below are the methods:
Solid sealProfile(Document doc, FamilyInstance fi, CurveLoop sweeps)
{
CurveLoop profileLoop = null;
Solid solid = null;
Line initV = null;
ElementId categoryId = new ElementId(BuiltInCategory.OST_GenericModel);
DirectShape ds = null;
List<GeometryObject> solids = null;
try
{
//get the sweep, get plane per to first sweep vector,
//then you instantiate the cross-section in that plane to get it normal to the first sweep vector
double param = sweeps.First().GetEndParameter(0);
Curve firstCurve = sweeps.First();
XYZ xyz = firstCurve.GetEndPoint(0);
Transform tr = firstCurve.ComputeDerivatives(0, true);
var v = XYZ.BasisZ;
var v_normaltostartofarc = tr.OfVector(v);
//tilt this profile into the sweep path
XYZ endPoint1 = (sweeps.First() as Curve).Tessellate().ElementAt(0);
XYZ endPoint2 = (sweeps.First() as Curve).Tessellate().ElementAt(1);
initV = Line.CreateBound(endPoint1, endPoint2);
var tangent = initV.Direction.CrossProduct(XYZ.BasisZ);
Plane plane = new Plane(initV.Direction, endPoint1);
var _profilepoints = new List<XYZ>() {
MmToFootPlanePoint(plane,new UV(-10,0)),
MmToFootPlanePoint(plane,new UV(-11.36,-7.7)),
MmToFootPlanePoint(plane,new UV(-14.15,-10.49)),
MmToFootPlanePoint(plane,new UV(-13,-16.5)),
MmToFootPlanePoint(plane,new UV(-11,-16.5)),
MmToFootPlanePoint(plane,new UV(-10.27,-13.78)),
MmToFootPlanePoint(plane,new UV(-9.41,-12.5)),
MmToFootPlanePoint(plane,new UV(-7.95,-12)),
MmToFootPlanePoint(plane,new UV(-6.49,-12.5)),
MmToFootPlanePoint(plane,new UV(-5.63,-13.78)),
MmToFootPlanePoint(plane,new UV(-4.91,-16.5)),
MmToFootPlanePoint(plane,new UV(-2.91,-16.5)),
MmToFootPlanePoint(plane,new UV(-2.18,-13.78)),
MmToFootPlanePoint(plane,new UV(-1.4,-12.5)),
MmToFootPlanePoint(plane,new UV(0,-12)),
MmToFootPlanePoint(plane,new UV(1.4,-12.5 )),
MmToFootPlanePoint(plane,new UV(2.18,-13.78)),
MmToFootPlanePoint(plane,new UV(2.91,-16.5)),
MmToFootPlanePoint(plane,new UV(4.91,-16.5)),
MmToFootPlanePoint(plane,new UV(5.63,-13.78)),
MmToFootPlanePoint(plane,new UV(6.49,-12.5)),
MmToFootPlanePoint(plane,new UV(7.95,-12)),
MmToFootPlanePoint(plane,new UV(9.41,-12.5)),
MmToFootPlanePoint(plane,new UV(10.27,-13.78)),
MmToFootPlanePoint(plane,new UV(11,-16.5)),
MmToFootPlanePoint(plane,new UV(13,-16.5)),
MmToFootPlanePoint(plane,new UV(14.15,-10.49)),
MmToFootPlanePoint(plane,new UV(11.36,-7.7)),
MmToFootPlanePoint(plane,new UV(10,0)),
MmToFootPlanePoint(plane,new UV(-10,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);
}
//rotate profileLoop on plane into position
var angle = Math.PI / 2 + Angle.DegreeToRadiant(33.75);
var transform = Transform.CreateRotationAtPoint(plane.Normal, angle, endPoint1);
profileLoop.Transform(transform);
IList<CurveLoop> profileLoops = new List<CurveLoop>();
profileLoops.Add(profileLoop);
SolidOptions solOptions = new SolidOptions(ElementId.InvalidElementId, ElementId.InvalidElementId);
solid = GeometryCreationUtilities.CreateSweptGeometry(sweeps /*sweepPath*/, 0, param, profileLoops, solOptions);
categoryId = new ElementId(BuiltInCategory.OST_GenericModel);
ds = DirectShape.CreateElement(doc, categoryId, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
solids = new List<GeometryObject>() { solid };
ds.SetShape(solids);
ds.Name = "ExtrusionTest3";
//SolidSolidCutUtils
}
catch (Exception exc)
{
Debug.WriteLine(exc);
}
return solid;
} public ModelArc CreateModelCurve(Document document, Plane geomPlane, Arc geomArc)
{
// get handle to application from document
Autodesk.Revit.ApplicationServices.Application application = document.Application;
// Create a sketch plane in current document
SketchPlane sketch = SketchPlane.Create(document, geomPlane);
// Create a ModelArc element using the created geometry arc and sketch plane
ModelArc arc = document.Create.NewModelCurve(geomArc, sketch) as ModelArc;
return arc;
}
public static XYZ MmToFootPlanePoint(Plane plane, UV pt)
{
return plane.Origin + plane.XVec.Multiply(pt.U / 304.8) + plane.YVec.Multiply(pt.V / 304.8);
}
Solved! Go to Solution.