Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Help needed] errors exporting with cq-cli

Aperta
#42 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

Inizia da cq_cli/main.py e dai percorsi di conversione in cq_cli/cqcodecs/cq_codec_step.py e cq_codec_gltf.py. Esegui lo script fornito tramite cq-cli e verifica come vengono valorizzati build_result e first_result rispetto all’esecuzione con cq-editor. Il lavoro è completato quando lo script segnalato viene gestito in modo coerente e la conversione STEP e GLTF non fallisce più con questi errori di risultato vuoto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hello all,

I made some code for creating parts with cadquery and now i want to export with cq-cli to differents formats such as STEP or GLTF.

# CadQuery 2.x script: 320 mm vented rotor with 5 x M12 holes on 114.3 mm PCD

import os, math
import cadquery as cq
from cadquery import exporters

# --------------------
# Parameters (mm)
# --------------------
rotor_od = 320.0              # outer diameter
r_outer = rotor_od / 2.0

# Friction ring geometry
ring_inner_radius = 120.0     # inner radius of friction ring (adjust as needed)
plate_thickness = 5.0         # thickness of each friction plate
air_gap = 8.0                 # vent gap between plates
t_total = plate_thickness * 2 + air_gap

# Hub and mounting
pcd = 114.3                    # pitch circle diameter for bolt holes
bolt_count = 5
bolt_hole_d = 12.5             # M12 typical clearance hole (adjust to fit)
center_bore_d = 70.0           # assumed center bore; confirm with your hub
hub_radius = max(pcd / 2.0 + 8.0, center_bore_d / 2.0 + 8.0)  # leave margin around holes

# Vane and spoke layout (simplified straight vanes)
vane_count = 24
vane_width = 8.0               # tangential width of each vane
spoke_width = 8.0              # tangential width of spokes connecting hub-to-ring
# radial length of vanes across the vented ring
vane_radial_len = max(0.0, r_outer - ring_inner_radius)
# radial length of spokes between hub and ring inner radius
spoke_radial_len = max(0.0, ring_inner_radius - hub_radius)

# --------------------
# Helper functions
# --------------------
def polar_points(radius, count, start_deg=0.0):
    return [
        (radius * math.cos(math.radians(start_deg + i * 360.0 / count)),
         radius * math.sin(math.radians(start_deg + i * 360.0 / count)))
        for i in range(count)
    ]

# --------------------
# Build vented rotor
# --------------------
base = cq.Workplane("XY")

# Top and bottom friction plates (annular rings)
top_plate = (
    base.circle(r_outer)
        .circle(ring_inner_radius)
        .extrude(plate_thickness)
)
bottom_plate = (
    base.circle(r_outer)
        .circle(ring_inner_radius)
        .extrude(plate_thickness)
        .translate((0, 0, plate_thickness + air_gap))
)

rotor = top_plate.union(bottom_plate)

# Central hub (solid disc) to carry bore and bolt holes
hub = base.circle(hub_radius).extrude(t_total)
rotor = rotor.union(hub)

# Vanes: straight rectangular bridges across the air gap
# Constructed as boxes centered in Z across the air gap
if vane_radial_len > 0:
    for i in range(vane_count):
        angle = i * 360.0 / vane_count
        vane = (cq.Workplane("XY")
                .box(vane_radial_len, vane_width, air_gap)  # X=radial, Y=tangential, Z=gap
                .translate((ring_inner_radius + vane_radial_len / 2.0, 0, plate_thickness + air_gap / 2.0))
                .rotate((0, 0, 0), (0, 0, 1), angle))
        rotor = rotor.union(vane)

# Spokes: connect hub to ring inner radius through the air gap
if spoke_radial_len > 0:
    for i in range(vane_count):
        angle = i * 360.0 / vane_count
        spoke = (cq.Workplane("XY")
                 .box(spoke_radial_len, spoke_width, air_gap)
                 .translate((hub_radius + spoke_radial_len / 2.0, 0, plate_thickness + air_gap / 2.0))
                 .rotate((0, 0, 0), (0, 0, 1), angle))
        rotor = rotor.union(spoke)

# Center bore
rotor = rotor.cut(base.circle(center_bore_d / 2.0).extrude(t_total))

# Bolt holes on PCD (through all)
bolt_radius = pcd / 2.0
bolt_pts = polar_points(bolt_radius, bolt_count, start_deg=0.0)
bolt_cuts = cq.Workplane("XY").pushPoints(bolt_pts).circle(bolt_hole_d / 2.0).extrude(t_total)
rotor = rotor.cut(bolt_cuts)

# Combine into single solid for clean exports / measurements
rotor = rotor.combine()


# Final result for display/export tools
result = rotor

When i try to export to step with the simplest command : /cq-cli --codec step --infile "
eb98df729aff4c99812502be7a9f7fcb/generated_22fdb39fedc14ac6afffc2b3f48fe4d2.py"

i have this error :
Conversion codec error: Traceback (most recent call last):
File "/mnt/c/0-sources/Perso/DesignerAgent/venv_cq/lib/python3.12/site-packages/cq_cli/main.py", line 550, in main
converted = codec_module.convert(
^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/0-sources/Perso/DesignerAgent/venv_cq/lib/python3.12/site-packages/cq_cli/cqcodecs/cq_codec_step.py", line 15, in convert
shape = build_result.results[0].shape
~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

and to GLTF :
Conversion codec error: Traceback (most recent call last):
File "/mnt/c/0-sources/Perso/DesignerAgent/venv_cq/lib/python3.12/site-packages/cq_cli/main.py", line 550, in main
converted = codec_module.convert(
^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/0-sources/Perso/DesignerAgent/venv_cq/lib/python3.12/site-packages/cq_cli/cqcodecs/cq_codec_gltf.py", line 14, in convert
if type(build_result.first_result.shape).name == "Assembly":
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'shape'

I'm not sure my script is fully correct but it works in cq editor :

Image

Do you have any hints or tips or myabe know what can cause this please ?

Thanks in advance

Regards

Lingua principale
Python
Stelle
30
Fork
10
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CadQuery/cq-cli

Tutte le issue di CadQuery/cq-cli

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.