.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[Share knowledge] Slice a Solid3D

0 REPLIES 0
Reply
Message 1 of 1
doanphung
83 Views, 0 Replies

[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

[Share knowledge] Slice a Solid3D

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;

 
Labels (1)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report