Cannot make holes, or cannot combine objects

95 views
Skip to first unread message

Khoroshyy Petro

unread,
Aug 20, 2022, 5:01:16 PM8/20/22
to CadQuery
Hi list.
The following works fine
------
import cadquery as cq
PCB = cq.Workplane("front").lineTo(0, 53.3).lineTo(68.6, 53.3).lineTo(68.6,0).lineTo(0,0).close().extrude(1)
p_thickness = 3
PCB
# parameter definitions
ar_screw_height = 7.0
ar_screw_ID = 2.7
ar_screw_OD = 5.0
coord_holes = ((14,2.5),
( 15.3,50.7),
(66.1,33.5),
(66.1,7.6))

PCB = PCB.translate((0,0,ar_screw_height+p_thickness))
#PCB = PCB.faces(">Z").workplane().pushPoints(coord_holes).hole(ar_screw_ID)
post1 = cq.Workplane("XY").center(coord_holes[0][0],coord_holes[0][1]).circle(ar_screw_OD/2.0).circle(ar_screw_ID/2.0).extrude(1.0*(ar_screw_height+p_thickness),True)
post2 = cq.Workplane("XY").center(coord_holes[1][0],coord_holes[1][1]).circle(ar_screw_OD/2.0).circle(ar_screw_ID/2.0).extrude(1.0*(ar_screw_height+p_thickness),True)
post3 = cq.Workplane("XY").center(coord_holes[2][0],coord_holes[2][1]).circle(ar_screw_OD/2.0).circle(ar_screw_ID/2.0).extrude(1.0*(ar_screw_height+p_thickness),True)
post4 = cq.Workplane("XY").center(coord_holes[3][0],coord_holes[3][1]).circle(ar_screw_OD/2.0).circle(ar_screw_ID/2.0).extrude(1.0*(ar_screw_height+p_thickness),True)

arduino = PCB.union(post1).union(post2).union(post3).union(post4)
#arduino = arduino.faces(">Z").workplane(invert=False).pushPoints(coord_holes).hole(ar_screw_ID)
arduino
-----
But If i comment out 
#PCB = PCB.faces(">Z").workplane(invert=False).pushPoints(coord_holes).hole(ar_screw_ID)
then I am failing on PCB.union  command 
21 arduino = PCB.union(post1).union(post2).union(post3).union(post4)
     22 #arduino = arduino.faces(">Z").workplane(invert=False).pushPoints(coord_holes).hole(ar_screw_ID)
     23 arduino

~/miniconda3/envs/jcq3/lib/python3.8/site-packages/cadquery/cq.py in union(self, toUnion, clean, glue, tol)
   3312 
   3313         if clean:
-> 3314             r = r.clean()
   3315 
   3316         return self.newObject([r])

~/miniconda3/envs/jcq3/lib/python3.8/site-packages/cadquery/occ_impl/shapes.py in clean(self)
    391         upgrader = ShapeUpgrade_UnifySameDomain(self.wrapped, True, True, True)
    392         upgrader.AllowInternalEdges(False)
--> 393         upgrader.Build()
    394 
    395         return self.__class__(upgrader.Shape())

Standard_NullObject: BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt
[11]:




and if I try to make holes after unification:
using 
arduino = arduino.faces(">Z").workplane(invert=False).pushPoints(coord_holes).hole(ar_screw_ID)
I get the same error:
Standard_NullObject                       Traceback (most recent call last)
/tmp/ipykernel_7633/2009801332.py in <cell line: 22>()
     20 
     21 arduino = PCB.union(post1).union(post2).union(post3).union(post4)
---> 22 arduino = arduino.faces(">Z").workplane(invert=False).pushPoints(coord_holes).hole(ar_screw_ID)
     23 arduino

~/miniconda3/envs/jcq3/lib/python3.8/site-packages/cadquery/cq.py in hole(self, diameter, depth, clean)
   2945         )  # local coordinates!
   2946 
-> 2947         return self.cutEach(lambda loc: h.moved(loc), True, clean)
   2948 
   2949     # TODO: duplicated code with _extrude and extrude

~/miniconda3/envs/jcq3/lib/python3.8/site-packages/cadquery/cq.py in cutEach(self, fcn, useLocalCoords, clean)
   2791 
   2792         if clean:
-> 2793             s = s.clean()
   2794 
   2795         return self.newObject([s])

~/miniconda3/envs/jcq3/lib/python3.8/site-packages/cadquery/occ_impl/shapes.py in clean(self)
    391         upgrader = ShapeUpgrade_UnifySameDomain(self.wrapped, True, True, True)
    392         upgrader.AllowInternalEdges(False)
--> 393         upgrader.Build()
    394 
    395         return self.__class__(upgrader.Shape())

Standard_NullObject: BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt
[11]:

--

Is it a bug or I am missing something in the cadquerry logic?
Thanks.
Petro.

 
______________________________

Khoroshyy Petro

unread,
Aug 21, 2022, 9:16:48 AM8/21/22
to CadQuery
Hi,
I have found the following work around.
If I move posts by 1E-6mm relatively to holes. They unity works.
import cadquery as cq

import cadquery as cq
PCB = cq.Workplane("front").lineTo(0, 53.3).lineTo(68.6, 53.3).lineTo(68.6,0).lineTo(0,0).close().extrude(1)
p_thickness = 3
PCB
# parameter definitions
ar_screw_height = 7.0
ar_screw_ID = 2.7
ar_screw_OD = 5.0
coord_holes = ((14,2.5),
( 15.3,50.7),
(66.1,33.5),
(66.1,7.6))

PCB = PCB.translate((0,0,ar_screw_height+p_thickness))
PCB = PCB.faces(">Z").workplane().pushPoints(coord_holes).hole(ar_screw_ID)
post1 = cq.Workplane("XY").center(coord_holes[0][0]-1e-6,coord_holes[0][1]).circle(ar_screw_OD/2.0).circle(ar_screw_ID/2.0).extrude(1.0*(ar_screw_height+p_thickness),True)
post2 = cq.Workplane("XY").center(coord_holes[1][0]-1e-6,coord_holes[1][1]).circle(ar_screw_OD/2.0).circle(ar_screw_ID/2.0).extrude(1.0*(ar_screw_height+p_thickness),True)
post3 = cq.Workplane("XY").center(coord_holes[2][0]-1e-6,coord_holes[2][1]).circle(ar_screw_OD/2.0).circle(ar_screw_ID/2.0).extrude(1.0*(ar_screw_height+p_thickness),True)
post4 = cq.Workplane("XY").center(coord_holes[3][0]-1e-6,coord_holes[3][1]).circle(ar_screw_OD/2.0).circle(ar_screw_ID/2.0).extrude(1.0*(ar_screw_height+p_thickness),True)

arduino = PCB.union(post1).union(post2).union(post3).union(post4)
arduino

But why it does not in the first place?
Any idea?
Petro.

--
______________________________
Petro Khoroshyy

Lorenz Neureuter

unread,
Aug 21, 2022, 10:02:01 AM8/21/22
to Khoroshyy Petro, CadQuery
Hi Petro,

Another workaround is to call union with clean=False.  There are known issues with clean=True.  You can find them on GitHub labeled "ShapeUpgrade_UnifySameDomain" and "OCC kernel issue".  
If you see "ShapeUpgrade_UnifySameDomain" in the trace then the issue is likely related to clean=True.

Lorenz

--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/CAEoO5zriqZfa0jVkfu3%3Dmyb6fS_w6V29%2BRiTf-6PMyo5NMdFWw%40mail.gmail.com.

Khoroshyy Petro

unread,
Aug 21, 2022, 10:17:28 AM8/21/22
to Lorenz Neureuter, CadQuery
Hi Lorenz.
Thanks a lot for the information.
Best.
Petro.

--
______________________________
Petro Khoroshyy
Reply all
Reply to author
Forward
0 new messages