Loft fills my hollow structure

180 views
Skip to first unread message

Liam Nordvall

unread,
Jan 27, 2024, 11:16:19 AM1/27/24
to CadQuery
I've created three different scetches that should make a hollow structure. Placing only the sketches works fine but when I loft between two of them for example the wall and topBezel sketch then it fills my hollow structure
Here is my code:
import cadquery as cq
from cadquery import Workplane, Sketch, Vector, Location

extruded_objects = cq.Workplane()  # Reset the global variable

outline = cq.importers.importDXF("batmanLogo.dxf").wires().val()

offsetDir = 1

wall = cq.Sketch().face(outline, mode='c', tag='outline')
wall.wires(tag='outline').offset(1.6)
wall.wires(tag='outline').offset(0, mode='s')

topBezel = cq.Sketch().face(outline, mode='c', tag='outline')
topBezel.wires(tag='outline').offset(1.6+offsetDir)
topBezel.wires(tag='outline').offset(-1.6+offsetDir, mode='s')

bottomBezel = cq.Sketch().face(outline, mode='c', tag='outline')
bottomBezel.wires(tag='outline').offset(1.6+offsetDir)
bottomBezel.wires(tag='outline').offset(-1.6+offsetDir, mode='s')

result = cq.Workplane().center(0, 0)

result = result.placeSketch(wall).extrude(1)    

result = result.faces('>Z').workplane().placeSketch(wall,
                                 topBezel.moved(Location(Vector(0, 0, 1.6))),
                                 ).loft()

result = result.faces('>Z').workplane().placeSketch(wall).extrude(2)    


cq.exporters.export(result, "C:/Users/Liam Nordvall NA22/Documents/3DFiles/output.stl")

If I run this I get a 3d model but the model is not hollow in the loft section. If I achieve it I want to set the offsetDir to zero to make the bezels look inwards instead. All help is needed! Thankyou!
output.stl

Lorenz

unread,
Jan 30, 2024, 8:57:05 PM1/30/24
to CadQuery
> the model is not hollow in the loft section

See the Sketch docs https://cadquery.readthedocs.io/en/latest/sketch.html
"When lofting only outer wires are taken into account and inner wires are silently ignored."

For example, loft with either wall or rect yields the same result here:

```py
import cadquery as cq

wall = cq.Sketch().rect(4, 8).wires().offset(-1, mode="s")
base = cq.Workplane().placeSketch(wall).extrude(1)

# loft ignores the inner wire in wall
result1 = (
    base.faces(">Z")
    .workplane()
    .placeSketch(wall, wall.moved(cq.Location((0, 0, 1))))
    .loft()
)

rect = cq.Sketch().rect(4, 8)
result2 = (
    base.faces(">Z")
    .workplane()
    .placeSketch(rect, rect.moved(cq.Location((0, 0, 1))))
    .loft()
)

# result1 and result2 are identical
```

Sorry I don't have a solution, only pointing out that lofting behavior is expected as documented.

Jeremy Wright

unread,
Jan 31, 2024, 10:14:34 AM1/31/24
to Lorenz, CadQuery

--
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/6555ec61-22e3-4a2a-b46c-338d95b7228fn%40googlegroups.com.

Adam Urbanczyk

unread,
Jan 31, 2024, 12:14:57 PM1/31/24
to CadQuery
Below is what you likely intended to do. It does not solve the problem of bad wires with too many edges though. Solve it first and then chamfers should work.

import cadquery as cq
from cadquery import Workplane, Sketch, Vector, Location

extruded_objects = cq.Workplane()  # Reset the global variable

outline = cq.importers.importDXF(r"batmanLogo.dxf").wires().val()
outline = outline.translate(-outline.Center())

offsetDir = 1


base = cq.Sketch().face(outline)


wall = cq.Sketch().face(outline, mode='c', tag='outline')
wall.wires(tag='outline').offset(1.6)
wall.wires(tag='outline').offset(0, mode='s')

topBezel1 = cq.Sketch().face(outline, mode='c', tag='outline')
topBezel2 = cq.Sketch().face(outline, mode='c', tag='outline')

topBezel1.wires(tag='outline').offset(1.6+offsetDir)
topBezel2.wires(tag='outline').offset(-1.6+offsetDir)


bottomBezel = cq.Sketch().face(outline, mode='c', tag='outline')
bottomBezel.wires(tag='outline').offset(1.6+offsetDir)
bottomBezel.wires(tag='outline').offset(-1.6+offsetDir, mode='s')

result = cq.Workplane().placeSketch(wall).extrude(1)

result = (
    result
    .faces('>Z').tag('ref')
    .placeSketch(
        wall,
        topBezel1.moved(Location(Vector(0, 0, 1.6))),
    ).loft()
    .faces(tag='ref')
    .placeSketch(
        base,
        topBezel2.moved(Location(Vector(0, 0, 1.6))),
    ).loft(combine='cut')
)

result = result.faces('>Z').placeSketch(wall).extrude(2)

Liam Nordvall

unread,
Feb 1, 2024, 2:33:42 AM2/1/24
to CadQuery
Yeah I was thinking about that aswell but take in consideration that the angles could be really high and I'm concerned that your solution will cause intersection problems. But ofcourse I will try it and return with an answer. Thank you for your support!

Liam Nordvall

unread,
Feb 1, 2024, 2:34:30 AM2/1/24
to CadQuery
Yeah I was expecting that the loft takes the outher wires and creates a solid. Will continue looking for soultions. Thank you! 
Reply all
Reply to author
Forward
0 new messages