Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Python 3 Compatibility #374

Merged
merged 7 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf8 -*-
#!/usr/bin/python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# CadQuery script to generate connector models

Expand Down Expand Up @@ -50,7 +50,7 @@
__author__ = "hackscribble"
__Comment__ = 'model description for 4UCON 17809 series connectors using cadquery'

___ver___ = "0.2 16/04/2017"
___ver___ = "0.3 18/06/2020"


import cadquery as cq
Expand Down Expand Up @@ -100,7 +100,7 @@ def generate_pins(params):
pin_pitch=params.pin_pitch
num_pins=params.num_pins
pins = generate_2_pin_group(params, pin_1_side=True)
for i in range(1, num_pins / 2):
for i in range(1, num_pins // 2):
pins = pins.union(generate_2_pin_group(params, i % 2 == 0).translate((i*pin_pitch,0,0)))
return pins

Expand Down Expand Up @@ -133,7 +133,7 @@ def generate_contacts(params):
pin_pitch=params.pin_pitch
pair = generate_2_contact_group(params)
contacts = pair
for i in range(0, num_pins / 2):
for i in range(0, num_pins // 2):
contacts = contacts.union(pair.translate((i*pin_pitch,0,0)))
return contacts

Expand Down Expand Up @@ -180,7 +180,7 @@ def generate_body(params, calc_dim):
recess_small_width = seriesParams.recess_small_width
recess_height = seriesParams.recess_height

x_offset = (((num_pins / 2) - 1)*pin_pitch)/2.0
x_offset = (((num_pins // 2) - 1)*pin_pitch)/2.0
y_offset = -(1.5*pin_y_pitch)

# body
Expand Down Expand Up @@ -223,22 +223,22 @@ def generate_body(params, calc_dim):

# contact holes
body = body.faces(">Z").workplane().center(0, hole_offset)\
.rarray(pin_pitch, 1, (num_pins/2), 1).rect(hole_width, hole_length)\
.rarray(pin_pitch, 1, (num_pins//2), 1).rect(hole_width, hole_length)\
.center(0, -2*hole_offset)\
.rarray(pin_pitch, 1, (num_pins/2), 1).rect(hole_width, hole_length)\
.rarray(pin_pitch, 1, (num_pins//2), 1).rect(hole_width, hole_length)\
.cutBlind(-2)

# internal void
body = body.faces(">Z").workplane(offset=-hole_depth)\
.rarray(pin_pitch, 1, (num_pins/2), 1).rect(hole_width, top_void_width)\
.rarray(pin_pitch, 1, (num_pins//2), 1).rect(hole_width, top_void_width)\
.cutBlind(-(top_void_depth-hole_depth))

body = body.faces(">Z").workplane(offset=-top_void_depth)\
.rarray(pin_pitch, 1, (num_pins/2), 1).rect(hole_width, bottom_void_width)\
.rarray(pin_pitch, 1, (num_pins//2), 1).rect(hole_width, bottom_void_width)\
.cutBlind(-(body_height-top_void_depth))

# body end recesses
body = body.faces(">Z").workplane().center(body_length/2-recess_depth/2, 0)\
body = body.faces(">Z").workplane().center(body_length/2.0-recess_depth/2.0, 0)\
.rect(recess_depth, recess_small_width).cutBlind(-recess_height)

recess = cq.Workplane("XY").workplane(offset=foot_height+body_height).center(x_offset-body_length/2.0+recess_depth/2.0, y_offset)\
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

from collections import namedtuple
from conn_4ucon_global_params import generate_footprint_name

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys

Expand All @@ -9,7 +12,7 @@
manufacturer_tag = "4ucon "

def generate_footprint_name(series_name, num_pins, pin_pitch):
name = '4UCON_{:s}_02x{:02d}x{:.2f}mm_Vertical'.format(series_name, num_pins / 2, pin_pitch)
name = '4UCON_{:s}_02x{:02d}x{:.2f}mm_Vertical'.format(series_name, num_pins // 2, pin_pitch)
return name

"""
Expand Down
159 changes: 0 additions & 159 deletions cadquery/FCAD_script_generator/4UCON_17809/cq_models/ribbon.py

This file was deleted.

17 changes: 5 additions & 12 deletions cadquery/FCAD_script_generator/4UCON_17809/main_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf8 -*-
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# This was originaly derived from a cadquery script for generating PDIP models in X3D format
# from https://bitbucket.org/hyOzd/freecad-macros
Expand Down Expand Up @@ -48,7 +48,7 @@
__author__ = "scripts: maurice and hyOzd; models: hackscribble"
__Comment__ = '''make 3D models of 4UCON 17809 series connectors'''

___ver___ = "0.1 14/04/2017"
___ver___ = "0.2 18/06/2020"


import sys
Expand Down Expand Up @@ -106,16 +106,14 @@
import Draft
import ImportGui

from Gui.Command import *

import cq_cad_tools
reload(cq_cad_tools)
from cq_cad_tools import reload_lib
reload_lib(cq_cad_tools)

from cq_cad_tools import FuseObjs_wColors, GetListOfObjects, restore_Main_Tools, \
exportSTEP, close_CQ_Example, saveFCdoc, z_RotateObject, multiFuseObjs_wColors, \
checkRequirements

Gui.activateWorkbench("CadQueryWorkbench")

import FreeCADGui as Gui

if FreeCAD.GuiUp:
Expand All @@ -125,7 +123,6 @@

try:
# Gui.SendMsgToActiveView("Run")
from Gui.Command import *
Gui.activateWorkbench("CadQueryWorkbench")
import cadquery as cq
from Helpers import show
Expand All @@ -138,10 +135,6 @@

checkRequirements(cq)

try:
close_CQ_Example(App, Gui)
except: # catch *all* exceptions
print "CQ 030 doesn't open example file"


def export_one_part(modul, variant):
Expand Down
3 changes: 1 addition & 2 deletions cadquery/FCAD_script_generator/Altech/cq_parameters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

# -*- coding: utf8 -*-
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# This is derived from a cadquery script for generating QFP/GullWings models in X3D format.
#
Expand Down
14 changes: 5 additions & 9 deletions cadquery/FCAD_script_generator/Altech/main_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# This is derived from a cadquery script for generating Converter_DCDC 3D format
#
Expand Down Expand Up @@ -49,7 +49,7 @@
__author__ = "Stefan, based on Converter_DCDC script"
__Comment__ = 'make Altech connectors 3D models exported to STEP and VRML for Kicad StepUP script'

___ver___ = "1.3.3 2018-12-07"
___ver___ = "1.3.4 18/06/2020"

# maui import cadquery as cq
# maui from Helpers import show
Expand Down Expand Up @@ -93,7 +93,8 @@
# Import cad_tools
import cq_cad_tools
# Reload tools
reload(cq_cad_tools)
from cq_cad_tools import reload_lib
reload_lib(cq_cad_tools)
# Explicitly load all needed functions
from cq_cad_tools import FuseObjs_wColors, GetListOfObjects, restore_Main_Tools, \
exportSTEP, close_CQ_Example, exportVRML, saveFCdoc, z_RotateObject, Color_Objects, \
Expand Down Expand Up @@ -131,11 +132,6 @@

#checking requirements

try:
close_CQ_Example(FreeCAD, Gui)
except: # catch *all* exceptions
print "CQ 030 doesn't open example file"

import cq_parameters # modules parameters
from cq_parameters import *

Expand Down Expand Up @@ -431,5 +427,5 @@ def run():
for p in all_params[variant].pin_number:
make_3D_model(models_dir, variant, p)
else:
print("Parameters for %s doesn't exist in 'all_params', skipping. " % variant)
FreeCAD.Console.PrintMessage("\tParameters for %s doesn't exist in 'all_params', skipping. " % variant)
continue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf8 -*-
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# This is derived from a cadquery script for generating QFP/GullWings models in X3D format.
#
Expand Down
Loading