From 8ff19d679cf81badfaac2ece23992e04834e0253 Mon Sep 17 00:00:00 2001 From: Misca1234 Date: Tue, 1 Jan 2019 20:07:36 +0100 Subject: [PATCH] Added a number of 3D model coaxial contacts --- .../Connector_Coaxial/cq_coaxial_amphenol.py | 715 +++++++++++++++ .../Connector_Coaxial/cq_coaxial_molex.py | 830 ++++++++++++++++++ .../Connector_Coaxial/cq_coaxial_samtec.py | 468 ++++++++++ .../Connector_Coaxial/cq_coaxial_te.py | 387 ++++++++ .../Connector_Coaxial/cq_common.py | 476 ++++++++++ .../Connector_Coaxial/main_generator.py | 234 +++++ 6 files changed, 3110 insertions(+) create mode 100644 cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_amphenol.py create mode 100644 cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_molex.py create mode 100644 cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_samtec.py create mode 100644 cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_te.py create mode 100644 cadquery/FCAD_script_generator/Connector_Coaxial/cq_common.py create mode 100644 cadquery/FCAD_script_generator/Connector_Coaxial/main_generator.py diff --git a/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_amphenol.py b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_amphenol.py new file mode 100644 index 00000000..1bc46e0e --- /dev/null +++ b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_amphenol.py @@ -0,0 +1,715 @@ +# -*- coding: utf-8 -*- +#!/usr/bin/python +# +# This is derived from a cadquery script for generating PDIP models in X3D format +# +# from https://bitbucket.org/hyOzd/freecad-macros +# author hyOzd +# This is a +# Dimensions are from Microchips Packaging Specification document: +# DS00000049BY. Body drawing is the same as QFP generator# + +## requirements +## cadquery FreeCAD plugin +## https://github.com/jmwright/cadquery-freecad-module + +## to run the script just do: freecad main_generator.py modelName +## e.g. c:\freecad\bin\freecad main_generator.py DIP8 + +## the script will generate STEP and VRML parametric models +## to be used with kicad StepUp script + +#* These are a FreeCAD & cadquery tools * +#* to export generated models in STEP & VRML format. * +#* * +#* cadquery script for generating QFP/SOIC/SSOP/TSSOP models in STEP AP214 * +#* Copyright (c) 2015 * +#* Maurice https://launchpad.net/~easyw * +#* All trademarks within this guide belong to their legitimate owners. * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., * +#* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * +#* * +#**************************************************************************** + + +import cq_common # modules parameters +from cq_common import * + +import sys +import math + + +class cq_coaxial_amphenol(): + + def __init__(self): + x = 0 + + + def get_model_name(self, modelID): + for n in self.all_params: + if n == modelID: + return self.all_params[modelID].modelName + return 'xxUNKNOWNxxx' + + + def get_dest_3D_dir(self, modelID): + for n in self.all_params: + if n == modelID: + return self.all_params[modelID].dest_dir_prefix + return 'Capacitor_SMD.3dshapes' + + def model_exist(self, modelID): + for n in self.all_params: + if n == modelID: + return True + + return False + + + def get_list_all(self): + list = [] + for n in self.all_params: + list.append(n) + + return list + + + def make_3D_model(self, modelID): + + destination_dir = self.get_dest_3D_dir(modelID) + params = self.all_params[modelID] + + + if modelID == 'SMA_Amphenol_132134': + case_top = self.make_top_SMA_Amphenol_132134(params) + show(case_top) + case = self.make_case_SMA_Amphenol_132134(params) + show(case) + elif modelID == 'SMA_Amphenol_901_144': + case_top = self.make_top_SMA_Amphenol_132134(params) + show(case_top) + case = self.make_case_SMA_Amphenol_132134(params) + show(case) + elif modelID == 'SMA_Amphenol_132134_11': + case_top = self.make_top_SMA_Amphenol_132134(params) + show(case_top) + case = self.make_case_SMA_Amphenol_132134(params) + show(case) + elif modelID == 'SMA_Amphenol_132134_14': + case_top = self.make_top_SMA_Amphenol_132134(params) + show(case_top) + case = self.make_case_SMA_Amphenol_132134(params) + show(case) + elif modelID == 'SMA_Amphenol_132134_16': + case_top = self.make_top_SMA_Amphenol_132134(params) + show(case_top) + case = self.make_case_SMA_Amphenol_132134(params) + show(case) + elif modelID == 'SMA_Amphenol_132289': + case_top = self.make_top_SMA_Amphenol_132134(params) + show(case_top) + case = self.make_case_SMA_Amphenol_132134(params) + show(case) + elif modelID == 'SMA_Amphenol_132134_10': + case_top = self.make_top_SMA_Amphenol_132134(params) + show(case_top) + case = self.make_case_SMA_Amphenol_132134(params) + show(case) + else: + FreeCAD.Console.PrintMessage('\r\n') + FreeCAD.Console.PrintMessage('ERROR: Model ID ' + str(modelID) + ' does not exist, exiting') + FreeCAD.Console.PrintMessage('\r\n') + sys.exit() + + pins = self.make_pin(params) + show(pins) + + npth_pins = self.make_npth_pins_dummy(params) + show(npth_pins) + + doc = FreeCAD.ActiveDocument + objs=GetListOfObjects(FreeCAD, doc) + + body_top_color_key = params.body_top_color_key + body_color_key = params.body_color_key + pin_color_key = params.pin_color_key + npth_pin_color_key = params.npth_pin_color_key + + body_top_color = shaderColors.named_colors[body_top_color_key].getDiffuseFloat() + body_color = shaderColors.named_colors[body_color_key].getDiffuseFloat() + pin_color = shaderColors.named_colors[pin_color_key].getDiffuseFloat() + npth_pin_color = shaderColors.named_colors[npth_pin_color_key].getDiffuseFloat() + + Color_Objects(Gui,objs[0],body_top_color) + Color_Objects(Gui,objs[1],body_color) + Color_Objects(Gui,objs[2],pin_color) + Color_Objects(Gui,objs[3],npth_pin_color) + + col_body_top=Gui.ActiveDocument.getObject(objs[0].Name).DiffuseColor[0] + col_body=Gui.ActiveDocument.getObject(objs[1].Name).DiffuseColor[0] + col_pin=Gui.ActiveDocument.getObject(objs[2].Name).DiffuseColor[0] + col_npth_pin=Gui.ActiveDocument.getObject(objs[3].Name).DiffuseColor[0] + + material_substitutions={ + col_body_top[:-1]:body_top_color_key, + col_body[:-1]:body_color_key, + col_pin[:-1]:pin_color_key, + col_npth_pin[:-1]:npth_pin_color_key + } + + expVRML.say(material_substitutions) + while len(objs) > 1: + FuseObjs_wColors(FreeCAD, FreeCADGui, doc.Name, objs[0].Name, objs[1].Name) + del objs + objs = GetListOfObjects(FreeCAD, doc) + + return material_substitutions + + + def make_npth_pins_dummy(self, params): + + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + + # Dummy + case = cq.Workplane("XY").workplane(offset=A1 + 1.0).moveTo(0.0, 0.0).circle(0.01, False).extrude(0.01) + + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + return (case) + + + def make_top_SMA_Amphenol_132134(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + BT = params.BT # Body cut + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + case = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle((AW1 / 2.0) - 1.0, False).extrude(AL1 - 1.0) + # + # Cut out center pin + # + case1 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(0.3, False).extrude(AL1 - 1.0) + case = case.cut(case1) + + case = case.translate((BX, BY, A1)) + + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + + def make_case_SMA_Amphenol_132134(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + BT = params.BT # Body cut + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + # + # Main body + # + case = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W, L).extrude(H) + # cut out under body + if BT > 0.001: + case1 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W / 2.0, 2.0 * L).extrude(BT) + case = case.cut(case1) + case1 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(2.0 * L, W / 2.0).extrude(BT) + case = case.cut(case1) + + # Base + case1 = cq.Workplane("XY").workplane(offset=AZ).moveTo(0.0, 0.0).circle((AW / 2.0), False).extrude(AL) + case = case.union(case1) + # Top cylinder + case1 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(0.0, 0.0).circle((AW1 / 2.0) - 0.2, False).extrude(AL1) + # Add the taps + tt = AZ1 + 0.4 + while tt < (AZ1 + AL1 - 0.6): +# while ty < (AY1 + 2.0): + case2 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).circle(AW1 / 2.0, False).extrude(0.2) + case2 = case2.faces(">Z").chamfer(0.08) + case2 = case2.faces(">Z").chamfer(0.08) + case2 = case2.rotate((0,0,0), (0,1,0), 5.0) + case2 = case2.translate((AX1, AY1, tt)) + case1 = case1.union(case2) + tt = tt + 0.4 + + # Cut out hollow + case2 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(0.0, 0.0).circle((AW1 / 2.0) - 0.4, False).extrude(AL1 + 2.0) + case1 = case1.cut(case2) + # Center pin + case2 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(0.3, False).extrude(AL1 - 1.0) + case3 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(0.1, False).extrude(AL1 - 1.0) + case2 = case2.cut(case3) + case1 = case1.union(case2) + + case = case.union(case1) + + case = case.translate((BX, BY, A1)) + + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + def make_pin(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + AW = params.AW # Appendix width + AW1 = params.AW1 # Appendix width 1 + AL = params.AL # Appendix length + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + if pin == None: + case = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).circle(0.01, False).extrude(0.01) + + elif len(pin) < 1: + case = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).circle(0.01, False).extrude(0.01) + + else: + case = None + for n in pin: + t = n[0] + x = n[1] + y = n[2] + w = n[3] + l = n[4] + ld = n[5] + if t == 'round': + case1 = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).circle(w / 2.0, False).extrude(0.0 - (ld + 1.0)) + case1 = case1.faces(" l: + case1 = case1.faces("X").fillet(w / 2.2) + else: + case1 = case1.faces("Y").fillet(l / 2.2) + elif t == 'rect1': + case1 = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).rect(w, l).extrude(0.0 - (ld + 1.0)) + if l > w: + case1 = case1.faces("Y").fillet(l / 2.2) + else: + case1 = case1.faces(" 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return (case) + + + ##enabling optional/default values to None + def namedtuple_with_defaults(typename, field_names, default_values=()): + + T = collections.namedtuple(typename, field_names) + T.__new__.__defaults__ = (None,) * len(T._fields) + if isinstance(default_values, collections.Mapping): + prototype = T(**default_values) + else: + prototype = T(*default_values) + T.__new__.__defaults__ = tuple(prototype) + return T + + Params = namedtuple_with_defaults("Params", [ + 'modelName', # modelName + 'A1', # Body PCB seperation + + 'W', # Width + 'L', # Length + 'H', # Height + 'BX', # Body center X + 'BY', # Body center Y + 'BT', # Body cut + + 'AW', # Appendix width + 'AL', # Appendix length + 'AX', # Appendix X + 'AY', # Appendix Y + 'AZ', # Appendix Z + + 'AW1', # Appendix width 1 + 'AL1', # Appendix length 1 + 'AX1', # Appendix X 1 + 'AY1', # Appendix Y 1 + 'AZ1', # Appendix Z 1 + + 'AW2', # Appendix width 2 + 'AL2', # Appendix length 2 + + 'pin', # pin + 'npth_pin_color_key', # NPTH Pin color + 'body_top_color_key', # Top color + 'body_color_key', # Body colour + 'pin_color_key', # Pin color + 'rotation', # Rotation if required + 'rotationy', # Rotation if required + 'translate', # Translate if required, even pins + 'dest_dir_prefix' # Destination directory + ]) + + + + all_params = { + + 'SMA_Amphenol_132134': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'SMA_Amphenol_132134_Vertical', # modelName + W = 07.00, # Body width + L = 07.00, # Body length + H = 01.50, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.30, # Body cut + + AW = 05.50, # Appendix width + AL = 01.50, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 01.50, # Appendix Z + + AW1 = 05.30, # Appendix width 1 + AL1 = 06.03, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 03.50, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, 0.0, 1.27, 1.27, 3.94], ['rect', -2.54, -2.54, 1.02, 1.02, 3.94], ['rect', 2.54, -2.54, 1.02, 1.02, 3.94], ['rect', -2.54, 2.54, 1.02, 1.02, 3.94], ['rect', 2.54, 2.54, 1.02, 1.02, 3.94]], + body_top_color_key = 'white body', # Top color + body_color_key = 'gold pins', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + rotation = 0, # Rotation if required + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + + 'SMA_Amphenol_901_144': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'SMA_Amphenol_901-144_Vertical', # modelName + W = 06.35, # Body width + L = 06.35, # Body length + H = 01.50, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.30, # Body cut + + AW = 04.50, # Appendix width + AL = 03.00, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 01.50, # Appendix Z + + AW1 = 05.30, # Appendix width 1 + AL1 = 05.02, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 04.50, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, 0.0, 1.27, 1.27, 3.94], ['rect', -2.54, -2.54, 1.02, 1.02, 3.94], ['rect', 2.54, -2.54, 1.02, 1.02, 3.94], ['rect', -2.54, 2.54, 1.02, 1.02, 3.94], ['rect', 2.54, 2.54, 1.02, 1.02, 3.94]], + body_top_color_key = 'white body', # Top color + body_color_key = 'gold pins', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + rotation = 0, # Rotation if required + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + + 'SMA_Amphenol_132134_11': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'SMA_Amphenol_132134-11_Vertical', # modelName + W = 06.35, # Body width + L = 06.35, # Body length + H = 02.50, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.60, # Body cut + + AW = 05.00, # Appendix width + AL = 01.00, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 02.50, # Appendix Z + + AW1 = 05.30, # Appendix width 1 + AL1 = 06.05, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 03.50, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, 0.0, 1.27, 1.27, 2.80], ['rect', -2.54, -2.54, 1.02, 1.02, 2.80], ['rect', 2.54, -2.54, 1.02, 1.02, 2.80], ['rect', -2.54, 2.54, 1.02, 1.02, 2.80], ['rect', 2.54, 2.54, 1.02, 1.02, 2.80]], + body_top_color_key = 'white body', # Top color + body_color_key = 'gold pins', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + rotation = 0, # Rotation if required + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + + 'SMA_Amphenol_132134_14': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'SMA_Amphenol_132134-14_Vertical', # modelName + W = 07.00, # Body width + L = 07.00, # Body length + H = 01.50, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.30, # Body cut + + AW = 05.50, # Appendix width + AL = 02.00, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 01.50, # Appendix Z + + AW1 = 05.20, # Appendix width 1 + AL1 = 05.85, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 03.50, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, 0.0, 0.61, 0.61, 3.94], ['rect', -2.54, -2.54, 1.02, 1.02, 3.94], ['rect', 2.54, -2.54, 1.02, 1.02, 3.94], ['rect', -2.54, 2.54, 1.02, 1.02, 3.94], ['rect', 2.54, 2.54, 1.02, 1.02, 3.94]], + body_top_color_key = 'white body', # Top color + body_color_key = 'gold pins', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + rotation = 0, # Rotation if required + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + + 'SMA_Amphenol_132134_16': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'SMA_Amphenol_132134-16_Vertical', # modelName + W = 07.00, # Body width + L = 07.00, # Body length + H = 01.50, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.30, # Body cut + + AW = 05.00, # Appendix width + AL = 01.50, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 01.50, # Appendix Z + + AW1 = 05.20, # Appendix width 1 + AL1 = 06.53, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 03.00, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, 0.0, 1.27, 1.27, 2.0], ['rect', -2.54, -2.54, 1.02, 1.02, 2.79], ['rect', 2.54, -2.54, 1.02, 1.02, 2.79], ['rect', -2.54, 2.54, 1.02, 1.02, 2.79], ['rect', 2.54, 2.54, 1.02, 1.02, 2.79]], + body_top_color_key = 'white body', # Top color + body_color_key = 'gold pins', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + rotation = 0, # Rotation if required + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + + 'SMA_Amphenol_132289': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'SMA_Amphenol_132289_EdgeMount', # modelName + W = 09.52, # Body width + L = 09.52, # Body length + H = 01.50, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.00, # Body cut + + AW = 05.00, # Appendix width + AL = 01.50, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 01.50, # Appendix Z + + AW1 = 05.30, # Appendix width 1 + AL1 = 09.65, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 03.00, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, -0.44, 0.76, 0.76, 2.0], ['rect1', -4.25, -3.835, 1.02, 1.85, 2.79], ['rect1', 4.25, -3.835, 1.02, 1.85, 2.79], ['rect1', -4.25, -0.3, 1.02, 1.02, 2.79], ['rect1', 4.25, -0.3, 1.02, 1.02, 2.79]], + body_top_color_key = 'white body', # Top color + body_color_key = 'gold pins', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + + rotation = 90, # Rotation if required + rotationy = 90, # Rotation if required + translate = [2.0, 0.0, 0.8], # translation + + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + + 'SMA_Amphenol_132134_10': Params( + # + # http://www.molex.com/pdm_docs/sd/734120110_sd.pdf + # + modelName = 'SMA_Amphenol_132134-10_Vertical', # modelName + W = 06.35, # Body width + L = 06.35, # Body length + H = 01.02, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.00, # Body cut + + AW = 06.00, # Appendix width + AL = 01.20, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 01.02, # Appendix Z + + AW1 = 06.00, # Appendix width 1 + AL1 = 05.35, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 02.22, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, 0.0, 1.27, 1.27, 1.27], ['rect4', -2.38, -2.38, 1.59, 1.59, 1.27], ['rect4', 2.38, -2.38, 1.59, 1.59, 1.27], ['rect4', -2.38, 2.38, 1.59, 1.59, 1.27], ['rect4', 2.38, 2.38, 1.59, 1.59, 1.27]], + body_top_color_key = 'white body', # Top color + body_color_key = 'gold pins', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + + rotation = 0, # Rotation if required + translate = [0.0, 0.0, 1.27], # translation + + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + } diff --git a/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_molex.py b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_molex.py new file mode 100644 index 00000000..dd7f22e4 --- /dev/null +++ b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_molex.py @@ -0,0 +1,830 @@ +# -*- coding: utf-8 -*- +#!/usr/bin/python +# +# This is derived from a cadquery script for generating PDIP models in X3D format +# +# from https://bitbucket.org/hyOzd/freecad-macros +# author hyOzd +# This is a +# Dimensions are from Microchips Packaging Specification document: +# DS00000049BY. Body drawing is the same as QFP generator# + +## requirements +## cadquery FreeCAD plugin +## https://github.com/jmwright/cadquery-freecad-module + +## to run the script just do: freecad main_generator.py modelName +## e.g. c:\freecad\bin\freecad main_generator.py DIP8 + +## the script will generate STEP and VRML parametric models +## to be used with kicad StepUp script + +#* These are a FreeCAD & cadquery tools * +#* to export generated models in STEP & VRML format. * +#* * +#* cadquery script for generating QFP/SOIC/SSOP/TSSOP models in STEP AP214 * +#* Copyright (c) 2015 * +#* Maurice https://launchpad.net/~easyw * +#* All trademarks within this guide belong to their legitimate owners. * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., * +#* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * +#* * +#**************************************************************************** + + +import cq_common # modules parameters +from cq_common import * + +import sys +import math + + +class cq_coaxial_molex(): + + def __init__(self): + x = 0 + + + def get_model_name(self, modelID): + for n in self.all_params: + if n == modelID: + return self.all_params[modelID].modelName + return 'xxUNKNOWNxxx' + + + def get_dest_3D_dir(self, modelID): + for n in self.all_params: + if n == modelID: + return self.all_params[modelID].dest_dir_prefix + return 'Capacitor_SMD.3dshapes' + + def model_exist(self, modelID): + for n in self.all_params: + if n == modelID: + return True + + return False + + + def get_list_all(self): + list = [] + for n in self.all_params: + list.append(n) + + return list + + + def make_3D_model(self, modelID): + + destination_dir = self.get_dest_3D_dir(modelID) + params = self.all_params[modelID] + + + if modelID == 'SMA_Molex_73251_2200': + case_top = self.make_top_SMA_Molex_73251_2200(params) + show(case_top) + case = self.make_case_SMA_Molex_73251_2200(params) + show(case) + elif modelID == 'U_FL_Molex_MCRF_73412_0110': + case_top = self.make_top_U_FL_Molex_MCRF_73412_0110(params) + show(case_top) + case = self.make_case_U_FL_Molex_MCRF_73412_0110(params) + show(case) + elif modelID == 'SMA_Molex_73251_1153': + case_top = self.make_top_SMA_Molex_73251_1153(params) + show(case_top) + case = self.make_case_SMA_Molex_73251_1153(params) + show(case) + else: + FreeCAD.Console.PrintMessage('\r\n') + FreeCAD.Console.PrintMessage('ERROR: Model ID ' + str(modelID) + ' does not exist, exiting') + FreeCAD.Console.PrintMessage('\r\n') + sys.exit() + + pins = self.make_pin(params) + show(pins) + + npth_pins = self.make_npth_pins_dummy(params) + show(npth_pins) + + doc = FreeCAD.ActiveDocument + objs=GetListOfObjects(FreeCAD, doc) + + body_top_color_key = params.body_top_color_key + body_color_key = params.body_color_key + pin_color_key = params.pin_color_key + npth_pin_color_key = params.npth_pin_color_key + + body_top_color = shaderColors.named_colors[body_top_color_key].getDiffuseFloat() + body_color = shaderColors.named_colors[body_color_key].getDiffuseFloat() + pin_color = shaderColors.named_colors[pin_color_key].getDiffuseFloat() + npth_pin_color = shaderColors.named_colors[npth_pin_color_key].getDiffuseFloat() + + Color_Objects(Gui,objs[0],body_top_color) + Color_Objects(Gui,objs[1],body_color) + Color_Objects(Gui,objs[2],pin_color) + Color_Objects(Gui,objs[3],npth_pin_color) + + col_body_top=Gui.ActiveDocument.getObject(objs[0].Name).DiffuseColor[0] + col_body=Gui.ActiveDocument.getObject(objs[1].Name).DiffuseColor[0] + col_pin=Gui.ActiveDocument.getObject(objs[2].Name).DiffuseColor[0] + col_npth_pin=Gui.ActiveDocument.getObject(objs[3].Name).DiffuseColor[0] + + material_substitutions={ + col_body_top[:-1]:body_top_color_key, + col_body[:-1]:body_color_key, + col_pin[:-1]:pin_color_key, + col_npth_pin[:-1]:npth_pin_color_key + } + + expVRML.say(material_substitutions) + while len(objs) > 1: + FuseObjs_wColors(FreeCAD, FreeCADGui, doc.Name, objs[0].Name, objs[1].Name) + del objs + objs = GetListOfObjects(FreeCAD, doc) + + return material_substitutions + + + def make_npth_pins_dummy(self, params): + + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + + # Dummy + case = cq.Workplane("XY").workplane(offset=A1 + 0.2).moveTo(0.0, 0.0).circle(0.01, False).extrude(0.01) + + if rotation != None: + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + return (case) + + + def make_top_SMA_Molex_73251_2200(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + AW2 = params.AW2 # Appendix width 2 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + case = cq.Workplane("XZ").workplane(offset=AY1).moveTo(AX1, AZ1).circle(AW1 / 2.0 - 0.5, False).extrude(AL1 - 3.0) + + # cut out pin + case1 = cq.Workplane("XZ").workplane(offset=AY1).moveTo(AX1, AZ1).circle(0.5, False).extrude(AL1 - 3.0) + case = case.cut(case1) + + case = case.translate((BX, BY, A1)) + + if rotation != None: + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + + def make_top_SMA_Molex_73251_1153(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + AW2 = params.AW2 # Appendix width 2 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + case = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(AW1 / 2.0 - 0.5, False).extrude(AL1 - 3.0) + + # cut out pin + case1 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(0.5, False).extrude(AL1 - 3.0) + case = case.cut(case1) + + case = case.translate((BX, BY, A1)) + + if rotation != None: + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + + def make_top_U_FL_Molex_MCRF_73412_0110(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + BT = params.BT # Body cut + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + case = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle((AW1 / 2.0), False).extrude(AL1) + case = case.faces(">Z").fillet(AW1 / 2.2) + + case1 = cq.Workplane("XY").workplane(offset=AZ).moveTo(AX, AY).circle((AW / 2.0), False).extrude(AL) + case2 = cq.Workplane("XY").workplane(offset=AZ).moveTo(AX, AY).circle((AW / 2.0) - 0.1, False).extrude(AL) + case1 = case1.cut(case2) + case = case.union(case1) + + case = case.translate((BX, BY, A1)) + + if rotation != None: + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + + def make_case_SMA_Molex_73251_2200(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + BT = params.BT # Body cut + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + AW2 = params.AW2 # Appendix width 2 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + # + # Main body + # + case = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W, L).extrude(H) + + # cut out under body + if BT > 0.001: + case1 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W / 2.4, 2.0 * L).extrude(0.5) + case = case.cut(case1) + case1 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.2).rect( 2.0 * L, W / 2.4).extrude(0.5) + case = case.cut(case1) + + case1 = cq.Workplane("XZ").workplane(offset=AY).moveTo(AX, AZ).circle(AW / 2.0, False).extrude(AL) + case = case.union(case1) + + # + # Do the tap + # + case1 = cq.Workplane("XZ").workplane(offset=AY1).moveTo(AX1, AZ1).circle(AW1 / 2.0 - 0.2, False).extrude(AL1) + # + # Add the taps + # + tt = AY1 + 0.4 + while tt < (AY1 + AL1 - 0.4): +# while ty < (AY1 + 2.0): + case2 = cq.Workplane("XZ").workplane(offset=0.0).moveTo(0.0, 0.0).circle(AW1 / 2.0, False).extrude(0.2) + case2 = case2.faces(">Y").chamfer(0.08) + case2 = case2.faces(">Y").chamfer(0.08) + case2 = case2.rotate((0,0,0), (0,1,0), 5.0) + case2 = case2.translate((AX1, 0.0 - tt, AZ1)) + case1 = case1.union(case2) + tt = tt + 0.4 + # + # Cut side of tap + # + if AW2 != None: + if AW2 > 0.01: + tl = AW1 - AW2 + case2 = cq.Workplane("XZ").workplane(offset=AY1).moveTo(AX1 + (AW1 / 2.0), AZ1).rect(2.0 * tl, AL1).extrude(AL1) + case1 = case1.cut(case2) + # + # Cut out the center + # + case2 = cq.Workplane("XZ").workplane(offset=AY1).moveTo(AX1, AZ1).circle(AW1 / 2.0 - 1.0, False).extrude(AL1 + 4.0) + case1 = case1.cut(case2) + # + # Add center tap + # + case2 = cq.Workplane("XZ").workplane(offset=AY1).moveTo(AX1, AZ1).circle(0.5, False).extrude(AL1 - 3.0) + case3 = cq.Workplane("XZ").workplane(offset=AY1).moveTo(AX1, AZ1).circle(0.2, False).extrude(AL1 - 3.0) + case2 = case2.cut(case3) + case1 = case1.union(case2) + + + case = case.union(case1) + + case = case.translate((BX, BY, A1)) + + if rotation != None: + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + + def make_case_SMA_Molex_73251_1153(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + BT = params.BT # Body cut + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + AW2 = params.AW2 # Appendix width 2 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + # + # Main body + # + case = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W, L).extrude(H) + + # cut out under body + if BT > 0.001: + case1 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W / 2.4, 2.0 * L).extrude(0.5) + case = case.cut(case1) + case1 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.2).rect( 2.0 * L, W / 2.4).extrude(0.5) + case = case.cut(case1) + + case1 = cq.Workplane("XY").workplane(offset=AZ).moveTo(AX, AY).circle(AW / 2.0, False).extrude(AL) + case = case.union(case1) + + # + # Do the tap + # + case1 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(AW1 / 2.0 - 0.2, False).extrude(AL1) + # + # Add the taps + # + tt = AY1 + 0.4 + while tt < (AY1 + AL1 - 0.4): +# while ty < (AY1 + 2.0): + case2 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).circle(AW1 / 2.0, False).extrude(0.2) + case2 = case2.faces(">Z").chamfer(0.08) + case2 = case2.faces(">Z").chamfer(0.08) + case2 = case2.rotate((0,0,0), (0,1,0), 5.0) + case2 = case2.translate((AX1, AY1, AZ1 + tt)) + case1 = case1.union(case2) + tt = tt + 0.4 + # + # Cut side of tap + # + if AW2 != None: + if AW2 > 0.01: + tl = AW1 - AW2 + case2 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1 + (AW1 / 2.0), AY1).rect(2.0 * tl, AL1).extrude(AL1) + case1 = case1.cut(case2) + # + # Cut out the center + # + case2 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(AW1 / 2.0 - 1.0, False).extrude(AL1 + 4.0) + case1 = case1.cut(case2) + # + # Add center tap + # + case2 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(0.5, False).extrude(AL1 - 3.0) + case3 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(0.2, False).extrude(AL1 - 3.0) + case2 = case2.cut(case3) + case1 = case1.union(case2) + + + case = case.union(case1) + + case = case.translate((BX, BY, A1)) + + if rotation != None: + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + + def make_case_U_FL_Molex_MCRF_73412_0110(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + BT = params.BT # Body cut + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + # + # Main body + # + case = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W, L).extrude(H) + # cut out under body + case1 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W, L).extrude(H) + case1 = case1.rotate((0,0,0), (0,0,1), 45) + case1 = case1.translate((0.0 - ((W / 1.1415) - 0.2), 0.0 - ((W / 1.1415) - 0.2), 0.0)) + case = case.cut(case1) + + case = case.translate((BX, BY, A1)) + + if rotation != None: + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + + def make_pin(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + AW = params.AW # Appendix width + AW1 = params.AW1 # Appendix width 1 + AL = params.AL # Appendix length + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + case = None + for n in pin: + t = n[0] + x = n[1] + y = n[2] + w = n[3] + l = n[4] + ld = n[5] + if t == 'round': + case1 = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).circle(w, False).extrude(0.0 - (ld + 1.0)) + case1 = case1.faces(" l: + case1 = case1.faces("X").fillet(w / 2.2) + else: + case1 = case1.faces("Y").fillet(l / 2.2) + elif t == 'rect2': + r = n[6] + case1 = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).rect(w, l).extrude(0.0 - (ld + 1.0)) + case1 = case1.rotate((0,0,0), (0,0,1), r) + elif t == 'rect3': + case1 = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).rect(w, l).extrude(0.0 - (ld + 1.0)) + if y < (0.0 - 2.0): + case1 = case1.faces("Y").fillet(l / 2.2) + else: + case1 = case1.faces(" 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return (case) + + + ##enabling optional/default values to None + def namedtuple_with_defaults(typename, field_names, default_values=()): + + T = collections.namedtuple(typename, field_names) + T.__new__.__defaults__ = (None,) * len(T._fields) + if isinstance(default_values, collections.Mapping): + prototype = T(**default_values) + else: + prototype = T(*default_values) + T.__new__.__defaults__ = tuple(prototype) + return T + + Params = namedtuple_with_defaults("Params", [ + 'modelName', # modelName + 'A1', # Body PCB seperation + + 'W', # Width + 'L', # Length + 'H', # Height + 'BX', # Body center X + 'BY', # Body center Y + 'BT', # Body cut + + 'AW', # Appendix width + 'AL', # Appendix length + 'AX', # Appendix X + 'AY', # Appendix Y + 'AZ', # Appendix Z + + 'AW1', # Appendix width 1 + 'AL1', # Appendix length 1 + 'AX1', # Appendix X 1 + 'AY1', # Appendix Y 1 + 'AZ1', # Appendix Z 1 + + 'AW2', # Appendix width 2 + 'AL2', # Appendix length 2 + + 'pin', # pin + 'npth_pin_color_key', # NPTH Pin color + 'body_top_color_key', # Top color + 'body_color_key', # Body colour + 'pin_color_key', # Pin color + 'rotation', # Rotation if required + 'rotationy', # Rotation if required + 'translate', # Translate if required, even pins + 'dest_dir_prefix' # Destination directory + ]) + + + + all_params = { + + 'SMA_Molex_73251_2200': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'SMA_Molex_73251-2200_Horizontal', # modelName + W = 07.00, # Body width + L = 06.62, # Body length + H = 10.44, # Body height + BX = 00.00, # Body center X + BY = -00.26, # Body center Y + + AW = 08.00, # Appendix width + AL = 01.50, # Appendix length + AX = 00.00, # Appendix X + AY = 03.31, # Appendix Y + AZ = 06.35, # Appendix Z + + AW1 = 06.50, # Appendix width 1 + AL1 = 11.43, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 04.81, # Appendix Y 1 + AZ1 = 06.35, # Appendix Z 1 + + AW2 = 06.10, # Appendix width 2 + + A1 = 0.01, # Body-board separation + + pin = [['rect', 0.0, 0.0, 1.0, 1.0, 2.79], ['rect', -2.54, -2.54, 1.0, 1.0, 2.79], ['rect', 2.54, -2.54, 1.0, 1.0, 2.79], ['rect', -2.54, 2.54, 1.0, 1.0, 2.79], ['rect', 2.54, 2.54, 1.0, 1.0, 2.79]], + body_top_color_key = 'white body', # Top color + body_color_key = 'metal grey pins', # Body color + pin_color_key = 'metal grey pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + rotation = 180, # Rotation if required + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + + 'U_FL_Molex_MCRF_73412_0110': Params( + # + # http://www.molex.com/pdm_docs/sd/734120110_sd.pdf + # + modelName = 'U.FL_Molex_MCRF_73412-0110_Vertical', # modelName + W = 02.60, # Body width + L = 02.60, # Body length + H = 00.36, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.00, # Body cut + + AW = 02.00, # Appendix width + AL = 00.87, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 00.36, # Appendix Z + + AW1 = 00.50, # Appendix width 1 + AL1 = 00.80, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 00.36, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['smd', 0.0, 1.5, 0.8, 0.8, 0.1], ['smd', 0.0, -1.5, 0.8, 0.8, 0.1], ['smd', -1.475, 0.0, 0.9, 2.0, 0.1], ['smd', 1.475, 0.0, 0.9, 2.0, 0.1]], + body_top_color_key = 'gold pins', # Top color + body_color_key = 'white body', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + + rotation = 0, # Rotation if required + + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + + 'SMA_Molex_73251_1153': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'SMA_Molex_73251-1153_EdgeMount_Horizontal', # modelName + W = 09.52, # Body width + L = 09.52, # Body length + H = 01.65, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.00, # Body cut + + AW = 06.00, # Appendix width + AL = 03.00, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 01.65, # Appendix Z + + AW1 = 06.30, # Appendix width 1 + AL1 = 04.87, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 04.65, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, -0.50, 0.76, 0.76, 4.75], ['rect3', -4.25, -0.75, 0.81, 1.02, 4.75], ['rect3', 4.25, -0.75, 0.81, 1.02, 4.75], ['rect3', -4.25, -3.8, 0.81, 1.9, 4.75], ['rect3', 4.25, -3.8, 0.81, 1.9, 4.75]], + body_top_color_key = 'white body', # Top color + body_color_key = 'gold pins', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + + rotation = 270, # Rotation if required + rotationy = 270, # Rotation if required + translate = [-4.9, 0.0, 1.20], # translation + + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + } diff --git a/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_samtec.py b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_samtec.py new file mode 100644 index 00000000..a9228ff0 --- /dev/null +++ b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_samtec.py @@ -0,0 +1,468 @@ +# -*- coding: utf-8 -*- +#!/usr/bin/python +# +# This is derived from a cadquery script for generating PDIP models in X3D format +# +# from https://bitbucket.org/hyOzd/freecad-macros +# author hyOzd +# This is a +# Dimensions are from Microchips Packaging Specification document: +# DS00000049BY. Body drawing is the same as QFP generator# + +## requirements +## cadquery FreeCAD plugin +## https://github.com/jmwright/cadquery-freecad-module + +## to run the script just do: freecad main_generator.py modelName +## e.g. c:\freecad\bin\freecad main_generator.py DIP8 + +## the script will generate STEP and VRML parametric models +## to be used with kicad StepUp script + +#* These are a FreeCAD & cadquery tools * +#* to export generated models in STEP & VRML format. * +#* * +#* cadquery script for generating QFP/SOIC/SSOP/TSSOP models in STEP AP214 * +#* Copyright (c) 2015 * +#* Maurice https://launchpad.net/~easyw * +#* All trademarks within this guide belong to their legitimate owners. * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., * +#* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * +#* * +#**************************************************************************** + + +import cq_common # modules parameters +from cq_common import * + +import sys +import math + + +class cq_coaxial_samtec(): + + def __init__(self): + x = 0 + + + def get_model_name(self, modelID): + for n in self.all_params: + if n == modelID: + return self.all_params[modelID].modelName + return 'xxUNKNOWNxxx' + + + def get_dest_3D_dir(self, modelID): + for n in self.all_params: + if n == modelID: + return self.all_params[modelID].dest_dir_prefix + return 'Capacitor_SMD.3dshapes' + + def model_exist(self, modelID): + for n in self.all_params: + if n == modelID: + return True + + return False + + + def get_list_all(self): + list = [] + for n in self.all_params: + list.append(n) + + return list + + + def make_3D_model(self, modelID): + + destination_dir = self.get_dest_3D_dir(modelID) + params = self.all_params[modelID] + + + if modelID == 'SMA_Samtec_SMA': + case_top = self.make_top_SMA_Samtec_SMA(params) + show(case_top) + case = self.make_case_SMA_Samtec_SMA(params) + show(case) + else: + FreeCAD.Console.PrintMessage('\r\n') + FreeCAD.Console.PrintMessage('ERROR: Model ID ' + str(modelID) + ' does not exist, exiting') + FreeCAD.Console.PrintMessage('\r\n') + sys.exit() + + pins = self.make_pin(params) + show(pins) + + npth_pins = self.make_npth_pins_dummy(params) + show(npth_pins) + + doc = FreeCAD.ActiveDocument + objs=GetListOfObjects(FreeCAD, doc) + + body_top_color_key = params.body_top_color_key + body_color_key = params.body_color_key + pin_color_key = params.pin_color_key + npth_pin_color_key = params.npth_pin_color_key + + body_top_color = shaderColors.named_colors[body_top_color_key].getDiffuseFloat() + body_color = shaderColors.named_colors[body_color_key].getDiffuseFloat() + pin_color = shaderColors.named_colors[pin_color_key].getDiffuseFloat() + npth_pin_color = shaderColors.named_colors[npth_pin_color_key].getDiffuseFloat() + + Color_Objects(Gui,objs[0],body_top_color) + Color_Objects(Gui,objs[1],body_color) + Color_Objects(Gui,objs[2],pin_color) + Color_Objects(Gui,objs[3],npth_pin_color) + + col_body_top=Gui.ActiveDocument.getObject(objs[0].Name).DiffuseColor[0] + col_body=Gui.ActiveDocument.getObject(objs[1].Name).DiffuseColor[0] + col_pin=Gui.ActiveDocument.getObject(objs[2].Name).DiffuseColor[0] + col_npth_pin=Gui.ActiveDocument.getObject(objs[3].Name).DiffuseColor[0] + + material_substitutions={ + col_body_top[:-1]:body_top_color_key, + col_body[:-1]:body_color_key, + col_pin[:-1]:pin_color_key, + col_npth_pin[:-1]:npth_pin_color_key + } + + expVRML.say(material_substitutions) + while len(objs) > 1: + FuseObjs_wColors(FreeCAD, FreeCADGui, doc.Name, objs[0].Name, objs[1].Name) + del objs + objs = GetListOfObjects(FreeCAD, doc) + + return material_substitutions + + + def make_npth_pins_dummy(self, params): + + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + + # Dummy + case = cq.Workplane("XY").workplane(offset=A1 + 1.0).moveTo(0.0, 0.0).circle(0.01, False).extrude(0.01) + + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + return (case) + + + def make_top_SMA_Samtec_SMA(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + BT = params.BT # Body cut + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + case = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle((AW1 / 2.0) - 1.0, False).extrude(AL1 - 1.0) + # + # Cut out center pin + # + case1 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(0.3, False).extrude(AL1 - 1.0) + case = case.cut(case1) + + case = case.translate((BX, BY, A1)) + + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + + def make_case_SMA_Samtec_SMA(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + BT = params.BT # Body cut + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + # + # Main body + # + case = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W, L).extrude(H) + # cut out under body + if BT > 0.001: + case1 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(W / 2.0, 2.0 * L).extrude(BT) + case = case.cut(case1) + case1 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).rect(2.0 * L, W / 2.0).extrude(BT) + case = case.cut(case1) + + # Base + case1 = cq.Workplane("XY").workplane(offset=AZ).moveTo(0.0, 0.0).circle((AW / 2.0), False).extrude(AL) + case = case.union(case1) + # Top cylinder + case1 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(0.0, 0.0).circle((AW1 / 2.0) - 0.2, False).extrude(AL1) + # Add the taps + tt = AZ1 + 0.4 + while tt < (AZ1 + AL1 - 0.6): +# while ty < (AY1 + 2.0): + case2 = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).circle(AW1 / 2.0, False).extrude(0.2) + case2 = case2.faces(">Z").chamfer(0.08) + case2 = case2.faces(">Z").chamfer(0.08) + case2 = case2.rotate((0,0,0), (0,1,0), 5.0) + case2 = case2.translate((AX1, AY1, tt)) + case1 = case1.union(case2) + tt = tt + 0.4 + + # Cut out hollow + case2 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(0.0, 0.0).circle((AW1 / 2.0) - 0.4, False).extrude(AL1 + 2.0) + case1 = case1.cut(case2) + # Center pin + case2 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(0.3, False).extrude(AL1 - 1.0) + case3 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(0.1, False).extrude(AL1 - 1.0) + case2 = case2.cut(case3) + case1 = case1.union(case2) + + case = case.union(case1) + + case = case.translate((BX, BY, A1)) + + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + if rotationy != None: + if (rotationy != 0): + case = case.rotate((0,0,0), (0,1,0), rotationy) + + if translate != None: + if len(translate) > 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return case + + + def make_pin(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + AW = params.AW # Appendix width + AW1 = params.AW1 # Appendix width 1 + AL = params.AL # Appendix length + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + rotationy = params.rotationy # Rotation if required + translate = params.translate # Rotation if required + + case = None + for n in pin: + t = n[0] + x = n[1] + y = n[2] + w = n[3] + l = n[4] + ld = n[5] + if t == 'round': + case1 = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).circle(w / 2.0, False).extrude(0.0 - (ld + 1.0)) + case1 = case1.faces(" l: + case1 = case1.faces("X").fillet(w / 2.2) + else: + case1 = case1.faces("Y").fillet(l / 2.2) + elif t == 'rect1': + case1 = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).rect(w, l).extrude(0.0 - (ld + 1.0)) + if l > w: + case1 = case1.faces("Y").fillet(l / 2.2) + else: + case1 = case1.faces("Y").fillet(l / 2.2) + else: + case1 = case1.faces(" 2: + case = case.translate((translate[0], translate[1], translate[2])) + + return (case) + + + ##enabling optional/default values to None + def namedtuple_with_defaults(typename, field_names, default_values=()): + + T = collections.namedtuple(typename, field_names) + T.__new__.__defaults__ = (None,) * len(T._fields) + if isinstance(default_values, collections.Mapping): + prototype = T(**default_values) + else: + prototype = T(*default_values) + T.__new__.__defaults__ = tuple(prototype) + return T + + Params = namedtuple_with_defaults("Params", [ + 'modelName', # modelName + 'A1', # Body PCB seperation + + 'W', # Width + 'L', # Length + 'H', # Height + 'BX', # Body center X + 'BY', # Body center Y + 'BT', # Body cut + + 'AW', # Appendix width + 'AL', # Appendix length + 'AX', # Appendix X + 'AY', # Appendix Y + 'AZ', # Appendix Z + + 'AW1', # Appendix width 1 + 'AL1', # Appendix length 1 + 'AX1', # Appendix X 1 + 'AY1', # Appendix Y 1 + 'AZ1', # Appendix Z 1 + + 'AW2', # Appendix width 2 + 'AL2', # Appendix length 2 + + 'pin', # pin + 'npth_pin_color_key', # NPTH Pin color + 'body_top_color_key', # Top color + 'body_color_key', # Body colour + 'pin_color_key', # Pin color + 'rotation', # Rotation if required + 'rotationy', # Rotation if required + 'translate', # Translate if required, even pins + 'dest_dir_prefix' # Destination directory + ]) + + + + all_params = { + + 'SMA_Samtec_SMA': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'SMA_Samtec_SMA-J-P-H-ST-EM1_EdgeMount', # modelName + W = 06.35, # Body width + L = 06.35, # Body length + H = 01.50, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + BT = 00.00, # Body cut + + AW = 05.50, # Appendix width + AL = 02.00, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 01.50, # Appendix Z + + AW1 = 06.30, # Appendix width 1 + AL1 = 06.02, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 03.50, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, -0.05, 1.27, 1.27, 2.0], ['rect3', -2.77, -2.665, 0.81, 1.02, 3.81], ['rect3', 2.77, -2.665, 0.81, 1.02, 2.79], ['rect3', -2.77, -0.135, 0.81, 1.07, 3.81], ['rect3', 2.77, -0.135, 0.81, 1.07, 3.81]], + body_top_color_key = 'white body', # Top color + body_color_key = 'gold pins', # Body color + pin_color_key = 'gold pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + + rotation = 90, # Rotation if required + rotationy = 90, # Rotation if required + translate = [2.0, 0.0, 0.6], # translation + + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + } diff --git a/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_te.py b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_te.py new file mode 100644 index 00000000..829cd314 --- /dev/null +++ b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_coaxial_te.py @@ -0,0 +1,387 @@ +# -*- coding: utf-8 -*- +#!/usr/bin/python +# +# This is derived from a cadquery script for generating PDIP models in X3D format +# +# from https://bitbucket.org/hyOzd/freecad-macros +# author hyOzd +# This is a +# Dimensions are from Microchips Packaging Specification document: +# DS00000049BY. Body drawing is the same as QFP generator# + +## requirements +## cadquery FreeCAD plugin +## https://github.com/jmwright/cadquery-freecad-module + +## to run the script just do: freecad main_generator.py modelName +## e.g. c:\freecad\bin\freecad main_generator.py DIP8 + +## the script will generate STEP and VRML parametric models +## to be used with kicad StepUp script + +#* These are a FreeCAD & cadquery tools * +#* to export generated models in STEP & VRML format. * +#* * +#* cadquery script for generating QFP/SOIC/SSOP/TSSOP models in STEP AP214 * +#* Copyright (c) 2015 * +#* Maurice https://launchpad.net/~easyw * +#* All trademarks within this guide belong to their legitimate owners. * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., * +#* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * +#* * +#**************************************************************************** + + +import cq_common # modules parameters +from cq_common import * + +import sys +import math + + +class cq_coaxial_te(): + + def __init__(self): + x = 0 + + + def get_model_name(self, modelID): + for n in self.all_params: + if n == modelID: + return self.all_params[modelID].modelName + return 'xxUNKNOWNxxx' + + + def get_dest_3D_dir(self, modelID): + for n in self.all_params: + if n == modelID: + return self.all_params[modelID].dest_dir_prefix + return 'Capacitor_SMD.3dshapes' + + def model_exist(self, modelID): + for n in self.all_params: + if n == modelID: + return True + + return False + + + def get_list_all(self): + list = [] + for n in self.all_params: + list.append(n) + + return list + + + def make_3D_model(self, modelID): + + destination_dir = self.get_dest_3D_dir(modelID) + params = self.all_params[modelID] + + + if modelID == 'BNC_TEConnectivity_1478204': + case_top = self.make_top_BNC_TEConnectivity_1478204(params) + show(case_top) + case = self.make_case_BNC_TEConnectivity_1478204(params) + show(case) + else: + FreeCAD.Console.PrintMessage('\r\n') + FreeCAD.Console.PrintMessage('ERROR: Model ID ' + str(modelID) + ' does not exist, exiting') + FreeCAD.Console.PrintMessage('\r\n') + sys.exit() + + pins = self.make_pin(params) + show(pins) + + npth_pins = self.make_npth_pins_dummy(params) + show(npth_pins) + + doc = FreeCAD.ActiveDocument + objs=GetListOfObjects(FreeCAD, doc) + + body_top_color_key = params.body_top_color_key + body_color_key = params.body_color_key + pin_color_key = params.pin_color_key + npth_pin_color_key = params.npth_pin_color_key + + body_top_color = shaderColors.named_colors[body_top_color_key].getDiffuseFloat() + body_color = shaderColors.named_colors[body_color_key].getDiffuseFloat() + pin_color = shaderColors.named_colors[pin_color_key].getDiffuseFloat() + npth_pin_color = shaderColors.named_colors[npth_pin_color_key].getDiffuseFloat() + + Color_Objects(Gui,objs[0],body_top_color) + Color_Objects(Gui,objs[1],body_color) + Color_Objects(Gui,objs[2],pin_color) + Color_Objects(Gui,objs[3],npth_pin_color) + + col_body_top=Gui.ActiveDocument.getObject(objs[0].Name).DiffuseColor[0] + col_body=Gui.ActiveDocument.getObject(objs[1].Name).DiffuseColor[0] + col_pin=Gui.ActiveDocument.getObject(objs[2].Name).DiffuseColor[0] + col_npth_pin=Gui.ActiveDocument.getObject(objs[3].Name).DiffuseColor[0] + + material_substitutions={ + col_body_top[:-1]:body_top_color_key, + col_body[:-1]:body_color_key, + col_pin[:-1]:pin_color_key, + col_npth_pin[:-1]:npth_pin_color_key + } + + expVRML.say(material_substitutions) + while len(objs) > 1: + FuseObjs_wColors(FreeCAD, FreeCADGui, doc.Name, objs[0].Name, objs[1].Name) + del objs + objs = GetListOfObjects(FreeCAD, doc) + + return material_substitutions + + + def make_npth_pins_dummy(self, params): + + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + + # Dummy + case = cq.Workplane("XY").workplane(offset=A1 + 0.2).moveTo(0.0, 0.0).circle(0.01, False).extrude(0.01) + + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + return (case) + + + def make_top_BNC_TEConnectivity_1478204(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + + case = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(AW1 / 2.0, False).extrude(AL1) + case = case.faces(">Z").fillet((AW1 / 2.0) - 0.5) + case1 = cq.Workplane("XY").workplane(offset=AZ1).moveTo(AX1, AY1).circle(AW1 / 4.0 - 0.5, False).extrude(AL1 + 1.0) + case = case.cut(case1) + + case = case.translate((BX, BY, A1)) + + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + return case + + + def make_case_BNC_TEConnectivity_1478204(self, params): + + W = params.W # Width + L = params.L # Length + H = params.H # Height + BX = params.BX # Body center X + BY = params.BY # Body center Y + + AW = params.AW # Appendix width + AL = params.AL # Appendix length + AX = params.AX # Appendix center X + AY = params.AY # Appendix center Y + AZ = params.AZ # Appendix center Z + + AW1 = params.AW1 # Appendix width 1 + AL1 = params.AL1 # Appendix length 1 + AX1 = params.AX1 # Appendix center X 1 + AY1 = params.AY1 # Appendix center Y 1 + AZ1 = params.AZ1 # Appendix center Z 1 + + pin = params.pin # pin + A1 = params.A1 # package height + rotation = params.rotation # Rotation if required + + # + # Main body + # + case = cq.Workplane("XY").workplane(offset=0.0).moveTo(0.0, 0.0).circle((W / 2.0), False).extrude(L) + case = case.faces(" l: + case1 = case1.faces("X").fillet(w / 2.2) + else: + case1 = case1.faces("Y").fillet(l / 2.2) + elif t == 'rect2': + r = n[6] + case1 = cq.Workplane("XY").workplane(offset=1.0).moveTo(0.0, 0.0).rect(w, l).extrude(0.0 - (ld + 1.0)) + case1 = case1.rotate((0,0,0), (0,0,1), r) + + case1 = case1.translate((x, y, 0.0)) + + if case == None: + case = case1 + else: + case = case.union(case1) + + case = case.translate((0.0, 0.0, A1)) + + if (rotation != 0): + case = case.rotate((0,0,0), (0,0,1), rotation) + + return (case) + + + ##enabling optional/default values to None + def namedtuple_with_defaults(typename, field_names, default_values=()): + + T = collections.namedtuple(typename, field_names) + T.__new__.__defaults__ = (None,) * len(T._fields) + if isinstance(default_values, collections.Mapping): + prototype = T(**default_values) + else: + prototype = T(*default_values) + T.__new__.__defaults__ = tuple(prototype) + return T + + Params = namedtuple_with_defaults("Params", [ + 'modelName', # modelName + 'A1', # Body PCB seperation + + 'W', # Width + 'L', # Length + 'H', # Height + 'BX', # Body center X + 'BY', # Body center Y + + 'AW', # Appendix width + 'AL', # Appendix length + 'AX', # Appendix X + 'AY', # Appendix Y + 'AZ', # Appendix Z + + 'AW1', # Appendix width 1 + 'AL1', # Appendix length 1 + 'AX1', # Appendix X 1 + 'AY1', # Appendix Y 1 + 'AZ1', # Appendix Z 1 + + 'AW2', # Appendix width 2 + 'AL2', # Appendix length 2 + + 'pin', # pin + 'npth_pin_color_key', # NPTH Pin color + 'body_top_color_key', # Top color + 'body_color_key', # Body colour + 'pin_color_key', # Pin color + 'rotation', # Rotation if required + 'dest_dir_prefix' # Destination directory + ]) + + + + all_params = { + + 'BNC_TEConnectivity_1478204': Params( + # + # https://www.cui.com/product/resource/sj1-353xng.pdf + # + modelName = 'BNC_TEConnectivity_1478204_Vertical', # modelName + W = 12.00, # Body width + L = 02.00, # Body length + H = 00.00, # Body height + BX = 00.00, # Body center X + BY = 00.00, # Body center Y + + AW = 10.00, # Appendix width + AL = 11.70, # Appendix length + AX = 00.00, # Appendix X + AY = 00.00, # Appendix Y + AZ = 02.00, # Appendix Z + + AW1 = 05.00, # Appendix width 1 + AL1 = 10.00, # Appendix length 1 + AX1 = 00.00, # Appendix X 1 + AY1 = 00.00, # Appendix Y 1 + AZ1 = 02.00, # Appendix Z 1 + + A1 = 0.01, # Body-board separation + + pin = [['round', 0.0, 0.0, 0.9, 0.9, 4.5], ['rect2', -3.175, -3.175, 0.85, 0.85, 4.5, 45.0], ['rect2', 3.175, -3.175, 0.85, 0.85, 4.5, 45.0], ['rect2', -3.175, 3.175, 0.85, 0.85, 4.5, 45.0], ['rect2', 3.175, 3.175, 0.85, 0.85, 4.5, 45.0]], + body_top_color_key = 'white body', # Top color + body_color_key = 'metal grey pins', # Body color + pin_color_key = 'metal grey pins', # Pin color + npth_pin_color_key = 'metal grey pins', # NPTH Pin color + rotation = 180, # Rotation if required + dest_dir_prefix = 'Connector_Coaxial.3dshapes', # destination directory + ), + } diff --git a/cadquery/FCAD_script_generator/Connector_Coaxial/cq_common.py b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_common.py new file mode 100644 index 00000000..cc4c4e22 --- /dev/null +++ b/cadquery/FCAD_script_generator/Connector_Coaxial/cq_common.py @@ -0,0 +1,476 @@ +# -*- coding: utf8 -*- +#!/usr/bin/python +# + +#**************************************************************************** +#* * +#* base classes for generating part models in STEP AP214 * +#* * +#* This is part of FreeCAD & cadquery tools * +#* to export generated models in STEP & VRML format. * +#* Copyright (c) 2017 * +#* Terje Io https://github.com/terjeio * +#* Maurice https://launchpad.net/~easyw * +#* * +#* All trademarks within this guide belong to their legitimate owners. * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., * +#* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * +#* * +#**************************************************************************** + +# 2017-11-30 + +# +# parts of this code is based on work by other contributors +# last copied from cq_base_model.py +# + +import collections +from collections import namedtuple + +from math import sin, tan, radians + +import FreeCAD, Draft, FreeCADGui +import ImportGui +import FreeCADGui as Gui + +import shaderColors +import exportPartToVRML as expVRML + +## base parametes & model +import collections +from collections import namedtuple + +# Import cad_tools +import cq_cad_tools +# Reload tools +reload(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, \ + CutObjs_wColors, checkRequirements + +# Sphinx workaround #1 +try: + QtGui +except NameError: + QtGui = None +# + +try: + # Gui.SendMsgToActiveView("Run") +# from Gui.Command import * + Gui.activateWorkbench("CadQueryWorkbench") + import cadquery + cq = cadquery + from Helpers import show + # CadQuery Gui +except: # catch *all* exceptions + msg = "missing CadQuery 0.3.0 or later Module!\r\n\r\n" + msg += "https://github.com/jmwright/cadquery-freecad-module/wiki\n" + if QtGui is not None: + reply = QtGui.QMessageBox.information(None,"Info ...",msg) + # maui end + +#checking requirements + +try: + close_CQ_Example(FreeCAD, Gui) +except: # catch *all* exceptions + print "CQ 030 doesn't open example file" + +from Helpers import show +import Part as FreeCADPart + +class Polyline: + r"""A class for creating a polyline wire (including arcs) using **relative** moves (turtle graphics style) + + :param plane: the workplane to add the polyline (as a wire) + :type plane: ``workplane`` + :param origin: point + :type origin: ``point`` + + Most of the methods returns a reference to the class instance (self) which allows method chaining + """ + + def __init__(self, plane, origin=(0.0, 0.0)): + self.commands = [] + self.plane = plane + self.origin = origin + self.x = 0 + self.y = 0 + self.addMoveTo(origin[0], origin[1]) + + def getCurrentPosition(self): + r"""get the current position in absolute coordinates + + :rtype: Point + """ + return (self.x, self.y) + + + def addMoveTo(self, x, y): + r"""add a relative move (offset) from the current coordinate + + .. note:: when issued as the first call after instatiating the class then the origin is moved accordingly + + :param x: x distance from current position + :type x: ``float`` + :param y: y distance from current position + :type y: ``float`` + + :rtype: self + """ + self.x += x + self.y += y + + if len(self.commands) == 1: + self.commands = [] + self.origin = (self.x, self.y) + self.commands.append((0, self.x, self.y)) + + return self + + def addPoint(self, x, y): + r"""add a straight line to point + + :param x: x distance from current position + :type x: ``float`` + :param y: y distance from current position + :type y: ``float`` + + :rtype: self + """ + self.x += x + self.y += y + self.commands.append((1, self.x, self.y)) + + return self + + def addPoints(self, pointList): + r"""add a list of new points + + :param pointList: + :type pointList: list of points + + :rtype: self + + Example where first half is defined by points and then mirrored by adding points in reverse order:: + + ow = 0.6 + pw = self.pin_width + c1 = (ow - pw) / 2.0 + pin = Polyline(cq.Workplane("XY"), origin=(0.0, self.body_width / 2.0))\ + .addPoints([ + (ow / 2.0, 0), + (0.0, -self.body_width), + (-c1, -c1), + (0.0, -(self.pin_length - pw)), + (-pw / 4.0, -pw), + (-pw / 4.0, 0.0), + ])\ + .addMirror().make().extrude(self.pin_thickness) + + .. figure:: ../images/pin.png + + Rendering + """ + + for point in pointList: + self.addPoint(point[0], point[1]) + + return self + + def addArc(self, radius, angle=90, type=0): + + o = sin(radians(abs(angle) / 2.0)) + p = 1.0 - 1.0 * o + f = -1.0 if angle < 0.0 else 1.0 + + if type == 0: + ap1 = self.x + radius * (p if f == 1.0 else o) + ap2 = self.y + radius * (o if f == 1.0 else p) * f + else: + ap1 = self.x + radius * (p if f == -1.0 else o) + ap2 = self.y + radius * (o if f == -1.0 else p) * f + self.x += radius + self.y += radius * f + self.commands.append((2, self.x, self.y, ap1, ap2)) + + return self + + def addThreePointArc(self, point1, point2): + r"""create a three point arc + + The starting point is the current position, end point is *point2*, the arc will be drawn through point1 + + :param point1: + :type width: ``float`` + + :param point2: + :type point2: ``point`` + + :rtype: self + + Example:: + + l = 4 + a = 0.2 + w = 2 - a + + body = Polyline(cq.Workplane("XY"))\ + .addPoint(0, w)\ + .addThreePointArc((l / 2, a), (l, 0))\ + .addPoint(0,- w).make().extrude(1) + + .. figure:: ../images/threepointarc.png + + Rendering + + """ + ap1 = self.x + point1[0] + ap2 = self.y + point1[1] + self.x += point2[0] + self.y += point2[1] + self.commands.append((2, self.x, self.y, ap1, ap2)) + + return self + + def addChamferedRectangle(self, length, width, chamfer): + r"""create a chamfered rectangle centered at the current point + + :param length: + :type length: ``float`` + + :param width: + :type width: ``float`` + + :param chamfer: + :type chamfer: ``float`` + + :rtype: self + + See :func:`addRoundedRectangle` for an example + """ + + self.addMoveTo(-length / 2.0, -width / 2.0 + chamfer) + + length = length - chamfer * 2.0 + width = width - chamfer * 2.0 + + self.addPoint(0.0, width) + self.addPoint(chamfer, chamfer) + self.addPoint(length, 0) + self.addPoint(chamfer, -chamfer) + self.addPoint(0.0, -width) + self.addPoint(-chamfer, -chamfer) + self.addPoint(-length, 0.0) + self.addPoint(-chamfer, chamfer) + + return self + + def addRoundedRectangle(self, length, width, radius): + r"""create a rounded rectangle centered at the current point + + :param length: + :type length: ``float`` + + :param width: + :type width: ``float`` + + :param cornerRadius: + :type cornerRadius: ``float`` + + :rtype: self + + Example with a chamfered rectangle cutout:: + + l = 4 + w = 2 + + cutout = Polyline(cq.Workplane("XY"))\ + .addChamferedRectangle(l - 0.3, w - 0.3, 0.3).make().extrude(1) + + body = Polyline(cq.Workplane("XY"))\ + .addRoundedRectangle(l, w, 0.3).make().extrude(1).cut(cutout) + + .. figure:: ../images/roundedrectangle.png + + Rendering + """ + + self.addMoveTo(-length / 2.0, -width / 2.0 + radius) + + length = length - radius * 2.0 + width = width - radius * 2.0 + + self.addPoint(0.0, width) + self.addArc(radius, 90) + self.addPoint(length, 0) + self.addArc(radius, -90) + self.addPoint(0.0, -width) + self.addArc(-radius, 90) + self.addPoint(-length, 0.0) + self.addArc(-radius, -90) + + return self + + def mirror(self, axis="X"): + r"""mirror the current polyline + """ + + result = [] + tx = -1.0 if axis == "X" else 1.0 + ty = -1.0 if axis != "X" else 1.0 + + for point in self.commands: + result.append((point[0], point[1] * tx, point[2] * ty)) + + self.commands = result + + return self + + def addMirror(self, axis="X"): + r"""add a mirror of the current polyline by reversing its direction + """ + + x0 = self.origin[0] if axis == "X" else 0.0 + y0 = self.origin[1] if axis != "X" else 0.0 + tx = -1.0 if axis == "X" else 1.0 + ty = -1.0 if axis != "X" else 1.0 + start = 2 #if axis == "X" else 0 + start = 1 if self.commands[0][start] == self.commands[-1][start] else 0 + + for point in reversed(self.commands[start:-1]): + self.commands.append((1, (point[1] - x0) * tx + x0, (point[2] - y0) * ty + y0)) + + return self + + def _is_equal (self, point1, point2): + return point1[0] == point2[0] and point1[1] == point2[1] + + def make(self): + r""" Closes the polyline and creates a wire in the supplied plane + + :rtype: ``wire`` + """ + plane = self.plane + + for point in self.commands: + if point[0] == 0: + plane = plane.moveTo(point[1], point[2]) + elif point[0] == 1: + plane = plane.lineTo(point[1], point[2]) + elif point[0] == 2: + plane = plane.threePointArc((point[3], point[4]), (point[1], point[2])) + + return plane.wire() if self._is_equal(self.origin, (self.commands[-1])[1:3]) else plane.close().wire() + +class cq_parameters_help(): + + def __init__(self): + self.pin_thickness = 0.15 + self.pin_length = 1.0 + self.pin_width = 0.4 + + def _make_gullwing_pin(self, pin_height, bottom_length, r_upper_i=None, r_lower_i=None): + """ create gull wing pin + + The pin will placed at coordinate 0, 0 and with the base at Z = 0 + + :param pin_height: overall pin height + :type pin_height: ``float`` + + :rtype: ``solid`` + + .. figure:: ../images/gullwingpin.png + + Rendering example + + """ + + # r_upper_i - pin upper corner, inner radius + # r_lower_i - pin lower corner, inner radius + # bottom_length - pin bottom flat part length (excluding corner arc) + + if r_lower_i is None: + r_lower_i = self.pin_thickness / 2.0 if r_upper_i is None else r_upper_i + + if r_upper_i is None: + r_upper_i = self.pin_thickness / 2.0 + + r_upper_o = r_upper_i + self.pin_thickness # pin upper corner, outer radius + r_lower_o = r_lower_i + self.pin_thickness # pin lower corner, outer radius + bottom_length = bottom_length - r_lower_i + top_length = self.pin_length - bottom_length - r_upper_i - r_lower_o + + return Polyline(cq.Workplane("YZ"), origin=(0, pin_height))\ + .addPoint(top_length, 0)\ + .addArc(r_upper_i, -90)\ + .addPoint(0, -(pin_height - r_upper_i - r_lower_o))\ + .addArc(r_lower_o, -90, 1)\ + .addPoint(bottom_length, 0)\ + .addPoint(0, self.pin_thickness)\ + .addPoint(-bottom_length, 0)\ + .addArc(-r_lower_i, -90)\ + .addPoint(0, pin_height - r_upper_i - r_lower_o)\ + .addArc(-r_upper_o, -90, 1)\ + .addPoint(-top_length, 0).make().extrude(self.pin_width).translate((-self.pin_width / 2.0, 0, 0)) + + + def _make_Jhook_pin(self, pin_height, bottom_length, top_length = 0.05, r_upper_i=None, r_lower_i=None): + """ create J-hook pin + + The pin will placed at coordinate 0, 0 and with the base at Z = 0 + + :param pin_height: overall pin height + :type pin_height: ``float`` + + :rtype: ``solid`` + + .. figure:: ../images/jhookpin.png + + Rendering example + + """ + + # r_upper_i - pin upper corner, inner radius + # r_lower_i - pin lower corner, inner radius + # bottom_length - pin bottom flat part length (excluding corner arc) + + if r_lower_i is None: + r_lower_i = self.pin_thickness / 2.0 if r_upper_i is None else r_upper_i + + if r_upper_i is None: + r_upper_i = self.pin_thickness / 2.0 + + r_upper_o = r_upper_i + self.pin_thickness # pin upper corner, outer radius + r_lower_o = r_lower_i + self.pin_thickness # pin lower corner, outer radius + bottom_length = bottom_length - r_lower_i + + + return Polyline(cq.Workplane("YZ"), (-(top_length + r_upper_i), pin_height))\ + .addPoint(top_length, 0)\ + .addArc(r_upper_i, -90)\ + .addPoint(0, -(pin_height - r_upper_i - r_lower_i - self.pin_thickness))\ + .addArc(-r_lower_i, 90)\ + .addPoint(-bottom_length, 0)\ + .addPoint(0, -self.pin_thickness)\ + .addPoint(bottom_length, 0)\ + .addArc(r_lower_o, 90, 1)\ + .addPoint(0, pin_height - r_upper_i - r_lower_i - self.pin_thickness)\ + .addArc(-r_upper_o, -90, 1)\ + .addPoint(-top_length, 0).make().extrude(self.pin_width).translate((-self.pin_width / 2.0, 0, 0)) diff --git a/cadquery/FCAD_script_generator/Connector_Coaxial/main_generator.py b/cadquery/FCAD_script_generator/Connector_Coaxial/main_generator.py new file mode 100644 index 00000000..03a2df52 --- /dev/null +++ b/cadquery/FCAD_script_generator/Connector_Coaxial/main_generator.py @@ -0,0 +1,234 @@ +# -*- coding: utf-8 -*- +#!/usr/bin/python +# +# This is derived from a cadquery script for generating PDIP models in X3D format +# +# from https://bitbucket.org/hyOzd/freecad-macros +# author hyOzd +# This is a +# Dimensions are from Microchips Packaging Specification document: +# DS00000049BY. Body drawing is the same as QFP generator# + +## requirements +## cadquery FreeCAD plugin +## https://github.com/jmwright/cadquery-freecad-module + +## to run the script just do: freecad main_generator.py modelName +## e.g. c:\freecad\bin\freecad main_generator.py DIP8 + +## the script will generate STEP and VRML parametric models +## to be used with kicad StepUp script + +#* These are a FreeCAD & cadquery tools * +#* to export generated models in STEP & VRML format. * +#* * +#* cadquery script for generating QFP/SOIC/SSOP/TSSOP models in STEP AP214 * +#* Copyright (c) 2015 * +#* Maurice https://launchpad.net/~easyw * +#* All trademarks within this guide belong to their legitimate owners. * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., * +#* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * +#* * +#**************************************************************************** + +__title__ = "make Valve 3D models" +__author__ = "Stefan, based on Valve script" +__Comment__ = 'make varistor 3D models exported to STEP and VRML for Kicad StepUP script' + +___ver___ = "1.3.3 14/08/2015" + +# maui import cadquery as cq +# maui from Helpers import show +from collections import namedtuple + +import math +import sys, os +import datetime +from datetime import datetime +sys.path.append("../_tools") +import exportPartToVRML as expVRML +import shaderColors + + +# maui start +import FreeCAD, Draft, FreeCADGui +import ImportGui +import FreeCADGui as Gui +#from Gui.Command import * + + +outdir=os.path.dirname(os.path.realpath(__file__) + os.sep + '..' + os.sep + '_3Dmodels') +scriptdir=os.path.dirname(os.path.realpath(__file__)) +sys.path.append(outdir) +sys.path.append(scriptdir) +if FreeCAD.GuiUp: + from PySide import QtCore, QtGui + +# Licence information of the generated models. +################################################################################################# +STR_licAuthor = "kicad StepUp" +STR_licEmail = "ksu" +STR_licOrgSys = "kicad StepUp" +STR_licPreProc = "OCC" +STR_licOrg = "FreeCAD" + + +################################################################################################# + + + + +import cq_coaxial_amphenol # modules parameters +from cq_coaxial_amphenol import * + +import cq_coaxial_te # modules parameters +from cq_coaxial_te import * + +import cq_coaxial_molex # modules parameters +from cq_coaxial_molex import * + +import cq_coaxial_samtec # modules parameters +from cq_coaxial_samtec import * + + +different_models = [ + cq_coaxial_amphenol(), + cq_coaxial_te(), + cq_coaxial_molex(), + cq_coaxial_samtec(), +] + + + + + +def make_3D_model(models_dir, model_class, modelID): + + LIST_license = ["",] + + CheckedmodelName = modelID.replace('.', '').replace('-', '_').replace('(', '').replace(')', '') + Newdoc = App.newDocument(CheckedmodelName) + App.setActiveDocument(CheckedmodelName) + Gui.ActiveDocument=Gui.getDocument(CheckedmodelName) + destination_dir = model_class.get_dest_3D_dir(modelID) + + material_substitutions = model_class.make_3D_model(modelID) + modelName = model_class.get_model_name(modelID) + + + doc = FreeCAD.ActiveDocument + doc.Label = CheckedmodelName + + objs=GetListOfObjects(FreeCAD, doc) + objs[0].Label = CheckedmodelName + restore_Main_Tools() + + script_dir=os.path.dirname(os.path.realpath(__file__)) + expVRML.say(models_dir) + out_dir=models_dir+os.sep+destination_dir + if not os.path.exists(out_dir): + os.makedirs(out_dir) + + exportSTEP(doc, modelName, out_dir) + if LIST_license[0]=="": + LIST_license=Lic.LIST_int_license + LIST_license.append("") + Lic.addLicenseToStep(out_dir + os.sep, modelName+".step", LIST_license,\ + STR_licAuthor, STR_licEmail, STR_licOrgSys, STR_licOrg, STR_licPreProc) + + # scale and export Vrml model + scale=1/2.54 + #exportVRML(doc,modelName,scale,out_dir) + del objs + objs=GetListOfObjects(FreeCAD, doc) + expVRML.say("######################################################################") + expVRML.say(objs) + expVRML.say("######################################################################") + export_objects, used_color_keys = expVRML.determineColors(Gui, objs, material_substitutions) + export_file_name=out_dir+os.sep+modelName+'.wrl' + colored_meshes = expVRML.getColoredMesh(Gui, export_objects , scale) + #expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys)# , LIST_license + expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license) + #scale=0.3937001 + #exportVRML(doc,modelName,scale,out_dir) + # Save the doc in Native FC format + saveFCdoc(App, Gui, doc, modelName,out_dir) + #display BBox + Gui.activateWorkbench("PartWorkbench") + Gui.SendMsgToActiveView("ViewFit") + Gui.activeDocument().activeView().viewAxometric() + #FreeCADGui.ActiveDocument.activeObject.BoundingBox = True + + +def run(): + ## # get variant names from command line + + return + +#import step_license as L +import add_license as Lic + +# when run from command line +if __name__ == "__main__" or __name__ == "main_generator": + + FreeCAD.Console.PrintMessage('\r\nRunning...\r\n') + + full_path=os.path.realpath(__file__) + expVRML.say(full_path) + scriptdir=os.path.dirname(os.path.realpath(__file__)) + expVRML.say(scriptdir) + sub_path = full_path.split(scriptdir) + expVRML.say(sub_path) + sub_dir_name =full_path.split(os.sep)[-2] + expVRML.say(sub_dir_name) + sub_path = full_path.split(sub_dir_name)[0] + expVRML.say(sub_path) + models_dir=sub_path+"_3Dmodels" + + model_to_build = '' + if len(sys.argv) < 3: + FreeCAD.Console.PrintMessage('No variant name is given, add a valid model name as an argument or the argument "all"\r\n') + sys.exit() + else: + model_to_build=sys.argv[2] + + + found_one = False + if len(model_to_build) > 0: + if model_to_build == 'all' or model_to_build == 'All' or model_to_build == 'ALL': + found_one = True + for n in different_models: + listall = n.get_list_all() + for i in listall: + FreeCAD.Console.PrintMessage('\r\nMaking model :' + i + '\r\n') + make_3D_model(models_dir, n, i) + elif model_to_build == 'list': + found_one = True + FreeCAD.Console.PrintMessage('\r\n') + for n in different_models: + listall = n.get_list_all() + for i in listall: + FreeCAD.Console.PrintMessage(i + '\r\n') + + else: + for n in different_models: + if n.model_exist(model_to_build): + found_one = True + make_3D_model(models_dir, n, model_to_build) + + if not found_one: + print("Parameters for %s doesn't exist, skipping. " % model_to_build)