[Question] How can I cut a polyhedron and remove 1 part with python parts? [Solved]

Tags:
  • Allplan
  • Subtract
  • Polyhedron
  • PythonParts

I wrote a code which creates intersected polyhedron and polygon. I want to cut that polyhedron with that polygon and remove the remaining solid. I tried CutPolyhedronWithPlane function but it gives the attached error. I need help on this.

Attachments (3)

Type: image/png
Downloaded 17 times
Size: 16,90 KiB
Type: image/png
Downloaded 22 times
Size: 23,87 KiB
Type: image/png
Downloaded 16 times
Size: 18,93 KiB

Show solution Hide solution

Hi,
you put wrong type of arguments into the CutPolyhedronWithPlane. According to the signature, you must put a Polyhedron3D first, then a Plane3D. In the error, I can see two problems:

  • in the first argument you have put some tuple instead of a polyhedron you want to cut
  • in the second argument, you put a Polygon3D. not a Plane3D

Regarding the first problem: I don't know, what you have done with the polyhedron. I can only assume, you have used some function from geometry module, that returns a tuple of (error_code, polyhedron) (this is often the case) and you took the whole result, without unpacking it.

Regarding second problem: You cut the solid with a plane, not with a polygon. A plane is defined by one point and a vector. A polygon is a collection of points on a specific plane. Those are two different things.
You can get the plane, on which a polygon is situated with the GetPlane method. Again, this method returns a tuple of error_code and the plane! So unpack it first, like this:

err, plane = polygon.GetPlane()

Best,
Bart

Hi,
you put wrong type of arguments into the CutPolyhedronWithPlane. According to the signature, you must put a Polyhedron3D first, then a Plane3D. In the error, I can see two problems:

  • in the first argument you have put some tuple instead of a polyhedron you want to cut
  • in the second argument, you put a Polygon3D. not a Plane3D

Regarding the first problem: I don't know, what you have done with the polyhedron. I can only assume, you have used some function from geometry module, that returns a tuple of (error_code, polyhedron) (this is often the case) and you took the whole result, without unpacking it.

Regarding second problem: You cut the solid with a plane, not with a polygon. A plane is defined by one point and a vector. A polygon is a collection of points on a specific plane. Those are two different things.
You can get the plane, on which a polygon is situated with the GetPlane method. Again, this method returns a tuple of error_code and the plane! So unpack it first, like this:

err, plane = polygon.GetPlane()

Best,
Bart

Quote by bmarciniec
Hi,

you put wrong type of arguments into the CutPolyhedronWithPlane. According to the signature, you must put a Polyhedron3D first, then a Plane3D. In the error, I can see two problems:
in the first argument you have put some tuple instead of a polyhedron you want to cut
in the second argument, you put a Polygon3D. not a Plane3D

Regarding the first problem: I don't know, what you have done with the polyhedron. I can only assume, you have used some function from geometry module, that returns a tuple of (error_code, polyhedron) (this is often the case) and you took the whole result, without unpacking it.Regarding second problem: You cut the solid with a plane, not with a polygon. A plane is defined by one point and a vector. A polygon is a collection of points on a specific plane. Those are two different things.
You can get the plane, on which a polygon is situated with the GetPlane method. Again, this method returns a tuple of error_code and the plane! So unpack it first, like this:
err, plane = polygon.GetPlane()Best,

Bart

Thanks to you, I have realized I accidentally deleted the "err" from createpolyhedron part. For the second problem, I was aware of it, but I could not see that function. Thanks a lot. There will be more questions
Best,
Ümit