There is no Trim option in Rhino8 Common Curve.Offset() API.
Are there any plans to add this option? Or, I would like to ask if there is another way.
Rhino5 Common Curve.Offset() API trims by default even though there is no option.
There is no Trim option in Rhino8 Common Curve.Offset() API.
Are there any plans to add this option? Or, I would like to ask if there is another way.
Rhino5 Common Curve.Offset() API trims by default even though there is no option.
Hello Masaki
What you showed seems to use the Grasshopper API, but Trim is not possible in the Rhino Common API.
Hello Tr1004sm,
Grasshopper does not have an API for processing geometry.
I used RhinoCommon within Grasshopper.
So I use RhinoCommon in Rhino, curve will be trimmed.
Perhaps you are not Joining curves?
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.curve/joincurves
It is also possible that the curve is not on a plane.
If the problem persists, please upload the 3dm file.
Oh, of course it would be nice to be able to control it, but I want trims automatically. There is one thing I missed, but this curve is not 2D. In the case of 2D, it can be trimmed with API, but 3D curves cannot be trimmed with API.
As mentioned earlier, trimming was done with the same 3D curve sample when using the Rhino5 Common API.
Hi @tr1004sm,
Can you post a 3dm file that contains both the before offset and after offset curves?
Thanks,
– Dale
I used the code below and it is a sample.
var Offset_Cvr = crv.Offset(Plane.WorldXY, 1, 0.01, CurveOffsetCornerStyle.Sharp);
test.3dm (46.2 KB)
Hi @tr1004sm,
Try using one of the other two Curve.Offset overrides - the ones take a point and vector as input (instead of a plane).
– Dale
I’ve tried this and I get the same result, there seems to be no automatic trimming going on. The solution I found to be working is to perform a curve boolean operation on the offset curves and I suspect that is what Rhino is doing in the command when the Trim option is active.
I have done my code in Grasshopper, but it should translate to a RhinoCommon command quite easily I hope.
private void RunScript(Curve curve, double dist, double tol, ref object a)
{
// first find the plane that the curve is in, don't assume XY
if (curve.TryGetPlane(out Plane p, tol))
{
// then offset on the found plane. You may want to use two different
// tolerances for finding the plane (can be quite loose) and
// the offset itself (should be quite strict)
Curve[] offset = curve.Offset(p, -dist, tol, CurveOffsetCornerStyle.Sharp);
if (null != offset)
{
// the offset curves are not yet trimmed, so perform a curve boolean
// from the center of the bounding box of the curve.
BoundingBox bb = curve.GetBoundingBox(p, out Box worldBox);
// use the world box center position as input for the curve boolean
Point3d at = worldBox.Center;
// perform the curve boolean
CurveBooleanRegions result = Curve.CreateBooleanRegions(offset, p, new[]{at}, false, tol);
if (null != result)
{
// there should be one region
if (result.RegionCount == 1)
{
// get the resulting curve(s) and finish
a = result.RegionCurves(0);
return;
}
else
{
Print($"There are {result.RegionCount} regions {at}");
}
}
a = offset;
}
else
{
Print("Failed to offset");
}
}
else
{
Print("Curve is not planar");
}
}
}
Hi @tr1004sm,
I am able to repeat this this, and have logged the issue.
https://mcneel.myjetbrains.com/youtrack/issue/RH-80488
Thanks for reporting.
– Dale