ukaea / paramak

Create parametric 3D fusion reactor CAD models
https://paramak.readthedocs.io/en/main/
36 stars 12 forks source link

Error with circular ports rotated 180° #548

Closed RemDelaporteMathurin closed 3 years ago

RemDelaporteMathurin commented 3 years ago

How to reproduce:

import paramak

test_component = paramak.PortCutterCircular(
    distance=1,
    z_pos=0,
    radius=1,
    azimuth_placement_angle=[0, 180],
    #azimuth_placement_angle=[90, 270],
)

test_component.export_stl('out.stl')

Error

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    test_component.export_stl('out.stl')
  File "/home/paramak/shape.py", line 692, in export_stl
    exporters.exportShape(self.solid, "STL", f, tolerance)
  File "/home/paramak/shape.py", line 125, in solid
    self.create_solid()
  File "/home/paramak/parametric_shapes/extruded_circle_shape.py", line 88, in create_solid
    solid = self.rotate_solid(solid)
  File "/home/paramak/shape.py", line 608, in rotate_solid
    solid = solid.union(i)
  File "/opt/conda/lib/python3.7/site-packages/cadquery/cq.py", line 2913, in union
    r = r.clean()
  File "/opt/conda/lib/python3.7/site-packages/cadquery/occ_impl/shapes.py", line 343, in clean
    upgrader.Build()
OCP.Standard.Standard_NullObject: BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt
RemDelaporteMathurin commented 3 years ago

Moreover, I've isolated the bug to pure cadquery commands and it seems it only occurs when workplane is "XZ". Perhaps a good issue for CQ ?

import cadquery as cq

def create_solid(workplane):
    solid0 = (
        cq.Workplane(workplane) 
        .moveTo(0, 0)
        .circle(1)
        .extrude(1, both=False)
    )

    solid1 = solid0.rotate((0, 0, -1), (0, 0, 1), 0)
    solid2 = solid0.rotate((0, 0, -1), (0, 0, 1), 180)
    solid = cq.Workplane(workplane)

    solid = solid.union(solid1)
    solid = solid.union(solid2)
    return solid

solid = create_solid("XY") # works
solid = create_solid("XZ") # does not work
solid = create_solid("YZ") # does not work
RemDelaporteMathurin commented 3 years ago

Funny enough, the following seems to work

import cadquery as cq

def create_solid(workplane):
    solid0 = (
        cq.Workplane(workplane)
        .moveTo(0, 0)
        .circle(1)
        .extrude(1, both=False)
    )

    solid1 = solid0.rotate((0, 0, -1), (0, 0, 1), 0)
    solid2 = solid0.rotate((0, 0, -1), (0, 0, 1), 180)
    solid = cq.Workplane(workplane)

    solid = solid.union(solid1)
    solid = solid.union(solid2, clean=False)
    return solid

solid = create_solid("XY") # works
solid = create_solid("XZ") # works
solid = create_solid("YZ") # works
billingsley-john commented 3 years ago

This works locally on CadQuery 2.0, so may be an issue with CadQuery master.

UPDATE: Confirmed that this is an issue with CadQuery master

RemDelaporteMathurin commented 3 years ago

I opened an issue in CQ https://github.com/CadQuery/cadquery/issues/519

billingsley-john commented 3 years ago

Note: This issue is not isolated to the port cutters. The issue also occurs in the underlying ExtrudeCircleShape class