Hello can anyone help me with the faces in the brep class. When generating it only 3 faces list. When baked into the gui it showns all faces in the brep object. It look like it is interpeting it als a folded single surface.
Func<Brep> FindCut = () =>
{
Brep brep = null;
var tp = new Plane(this.Axis.PointAt(0.5), this.Plane.ZAxis, this.Plane.XAxis);
Rhino.Geometry.Intersect.Intersection.BrepPlane(Container.Input, tp, 0.1, out Curve[x] crvs, out Point3d[x] pts);
if (crvs != null && crvs.Count() > 0 && crvs[0].IsClosed)
{
Curve tc = crvs[0];
tc.Translate(-this.Axis.Direction / 2.0);
var lst = tc.DuplicateSegments().ToList();
("crv count " + lst.Count).Show();
var bs = tc.DuplicateSegments().ToList().ConvertAll(x =>
{
return Extrusion.CreateExtrusion(tc, Axis.Direction).ToBrep();
});
brep = Brep.JoinBreps(bs, 0.1)[0];
tc.Bake();
("TEST2" + brep.Faces.Count).Show();
if (brep.SolidOrientation == BrepSolidOrientation.Inward) {brep.Flip();}
}
return brep;
};
Hi Dale,
Ok it is a part converter for rhino to tekla. What i try to find out cuts in profiles. The Problem is what the function
Extrusion.CreateExtrusion(tc, Axis.Direction).ToBrep();
Only gives me 1 Face when in Code. When baked into the DocObject it is ok. But I want to process this within the code. This must be a mistace in the RhinoCommon. Try to extrude a Polyline. And when look at the face count.
Ok I give you an example code which is more reasonable:
public static void ErrorTest()
{
var i = new Interval(-50, 50);
var p = new Rectangle3d(Rhino.Geometry.Plane.WorldXY, i, i).ToNurbsCurve();
var r = new Line(new Point3d(0,0,0), new Point3d(0, 0, 500)).ToNurbsCurve();
var b = Rhino.Geometry.Brep.CreateFromSweep(r, p, true, 0.1)[0];
Rhino.RhinoApp.WriteLine("faces:" + b.Faces.Count);
Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(b);
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var interval = new Interval(-50, 50);
var rectangle = new Rectangle3d(Plane.WorldXY, interval, interval);
var shape = new PolylineCurve(rectangle.ToPolyline());
var rail = new LineCurve(new Point3d(0, 0, 0), new Point3d(0, 0, 500));
var tolerance = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
var out_breps = Rhino.Geometry.Brep.CreateFromSweep(rail, shape, true, tolerance);
if (null != out_breps && out_breps.Length > 0)
{
var brep = out_breps[0];
// The rail and shape curves are degree=1 curves. Thus, the underlying surface
// will have kinks. Because kinked surface can cause problems down stream, Rhino
// always splits kinked surfaces when adding Breps to the document. Since
// we are not adding this Brep to the document, lets split the kinked
// surfaces ourself.
brep.Faces.SplitKinkyFaces();
RhinoApp.WriteLine("Face count: " + brep.Faces.Count);
}
return Result.Success;
}