Skip to content

Commit

Permalink
support FC1.0.0 for jst module. more to come
Browse files Browse the repository at this point in the history
  • Loading branch information
benjinne committed Jan 2, 2025
1 parent 3618936 commit 89e33bb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
*.[pP][yY][cC]
*.DS_Store
*.bak
*.FCBak
2 changes: 1 addition & 1 deletion cadquery/FCAD_script_generator/_tools/cq_cad_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def runGeometryCheck(App, Gui, step_path, log,
log.write('\t- Union check: [ FAIL ]\n')
geometry_error_container.append(NotUnionedError(modelName))
#stop
if FC_majorV == 0 and FC_minorV >= 17:
if (FC_majorV == 0 and FC_minorV >= 17) or FC_majorV > 0:
if docu.Objects == 0:
FreeCAD.Console.PrintError('Step import seems to fail. No objects to check\n')
for o in docu.Objects:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class LICENCE_Info():
from cq_helpers import *

import cadquery as cq
from Helpers import show
import FreeCAD
from conn_jst_eh_params import *

Expand Down Expand Up @@ -302,5 +301,5 @@ def generate_part(params):
params=series_params.variant_params['side_entry']['param_generator'](3)

(body, pins) = generate_part(params)
show(pins)
show(body)
show_object(pins)
show_object(body)
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class LICENCE_Info():
from cq_helpers import *

import cadquery as cq
from Helpers import show
from collections import namedtuple
import FreeCAD
from conn_jst_gh_params import *
Expand Down Expand Up @@ -301,5 +300,5 @@ def generate_part(params):

(body, pins) = generate_part(params)
body = body.translate((0,0,body_off_center_z))
show(pins)
show(body)
show_object(pins)
show_object(body)
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class LICENCE_Info():


import cadquery as cq
from Helpers import show
from collections import namedtuple
import FreeCAD
from conn_jst_ph_params import *
Expand Down Expand Up @@ -347,5 +346,5 @@ def generate_part(params):
params=series_params.variant_params['side_entry']['param_generator'](3)

(body, pins) = generate_part(params)
show(pins)
show(body)
show_object(pins)
show_object(body)
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class LICENCE_Info():
from cq_helpers import *

import cadquery as cq
from Helpers import show
from collections import namedtuple
import FreeCAD
from conn_jst_xh_params import *
Expand Down Expand Up @@ -308,6 +307,7 @@ def generate_part(params):
center_x=body_corner_x+body_lenght/2
pins = pins.rotate((center_x,0,0),(0,0,1),180)
body = body.rotate((center_x,0,0),(0,0,1),180)
# show_object(body)
return (body, pins)


Expand All @@ -317,5 +317,5 @@ def generate_part(params):
params=series_params.variant_params['side_entry']['param_generator'](3)

(body, pins) = generate_part(params)
show(pins)
show(body)
show_object(pins)
show_object(body)
31 changes: 11 additions & 20 deletions cadquery/FCAD_script_generator/jst/main_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@
check_Model = True
check_log_file = 'check-log.md'

from CQGui.display import show_object

if FreeCAD.GuiUp:
from PySide import QtCore, QtGui

try:
# Gui.SendMsgToActiveView("Run")
# from Gui.Command import *
Gui.activateWorkbench("CadQueryWorkbench")
import cadquery as cq
from Helpers import show
# CadQuery Gui
except Exception as e: # catch *all* exceptions
print(e)
msg = "missing CadQuery 0.3.0 or later Module!\r\n\r\n"
Expand All @@ -104,19 +102,16 @@
from cqToolsExceptions import *
import cq_cad_tools
# Reload tools
reload(cq_cad_tools)
cq_cad_tools.reload_lib(cq_cad_tools)
# Explicitly load all needed functions
from cq_cad_tools import multiFuseObjs_wColors, GetListOfObjects, restore_Main_Tools, \
exportSTEP, close_CQ_Example, saveFCdoc, z_RotateObject,\
runGeometryCheck

# Gui.SendMsgToActiveView("Run")
#Gui.activateWorkbench("CadQueryWorkbench")
#import FreeCADGui as Gui

try:
close_CQ_Example(App, Gui)
except:
except Exception as e:
print(f"An exception occurred: {e}")
FreeCAD.Console.PrintMessage("can't close example.")

#import FreeCAD, Draft, FreeCADGui
Expand Down Expand Up @@ -170,19 +165,14 @@ def export_one_part(module, variant, pincount, configuration, log):


for i in range(len(cq_obj_data)):
cq_obj_data[i].val().label = ModelName + obj_suffixes[i]
color_i = colors[i] + (0,)
show(cq_obj_data[i], color_i)

show_object(cq_obj_data[i], options={"color": color_i, "alpha": 0.0})

doc = FreeCAD.ActiveDocument
doc.Label = ModelName
objs=GetListOfObjects(FreeCAD, doc)


for i in range(len(objs)):
objs[i].Label = ModelName + obj_suffixes[i]


restore_Main_Tools()

out_dir='{:s}{:s}.3dshapes'.format(global_3dpath, lib_name)
Expand Down Expand Up @@ -235,8 +225,9 @@ def export_one_part(module, variant, pincount, configuration, log):
def exportSeries(module, configuration, log, model_filter_regobj):
series_definition = module.series_params
for variant in series_definition.variant_params:
#print(variant)
print("series: " + variant)
pinrange = series_definition.variant_params[variant]['pinrange']
print("pinrange: " + str(pinrange))
for pins in pinrange:
try:
if model_filter_regobj.match(str(pins)):
Expand Down Expand Up @@ -313,7 +304,7 @@ def argSwitchArg(self, name):
stop_on_first_error = False

def print_usage(self):
print("Generater script for phoenix contact 3d models.")
print("Generater script for jst 3d models.")
print('usage: FreeCAD main_generator.py [optional arguments and switches]')
print('optional arguments:')
print('\tconfig=[config file]: default:config_phoenix_KLCv3.0.yaml')
Expand All @@ -338,7 +329,7 @@ def __str__(self):

with open(args.config, 'r') as config_stream:
try:
configuration = yaml.load(config_stream)
configuration = yaml.load(config_stream, Loader=yaml.FullLoader)
except yaml.YAMLError as exc:
print(exc)

Expand Down

0 comments on commit 89e33bb

Please sign in to comment.