[Share knowledge] Slice a Solid3D

[Share knowledge] Slice a Solid3D

doanphung
Participant Participant
170 Views
0 Replies
Message 1 of 1

[Share knowledge] Slice a Solid3D

doanphung
Participant
Participant

I know some members are stuck with the 'Slice' API. I will share my experience.
My math is to slice a 3D cube with a plane (made of 3 points) and return a 3D cube that remains. Also, there is a Point3D on the same side as the Output-Solid.
If you have a better solution, Don't hesitate to leave a comment. 
It's a pleasure to participate in the discussion in this forum.

-------------------------------

Solid3d getSolid(Transaction trans, Solid3d solid, Point3d pt1, Point3d pt2, Point3d pt3, Point3d pointDirect)
{
Autodesk.AutoCAD.Geometry.Plane slicingPlane = new Autodesk.AutoCAD.Geometry.Plane(pt1, pt2, pt3);
double dotProduct = slicingPlane.Normal.DotProduct(pointDirect - slicingPlane.PointOnPlane);

Solid3d OutputSolid1 = null;
// Determine the side based on the dot product
if (dotProduct > 0)
{
solid.Slice(slicingPlane, false);
OutputSolid1 = solid;
}
else if (dotProduct < 0)
{
OutputSolid1 = solid.Slice(slicingPlane, true);
}
slicingPlane.Dispose();
return OutputSolid1;
}

return OutputSolid; // solid3D;

 
0 Likes
171 Views
0 Replies
Replies (0)