Skip to content

Commit

Permalink
improved configurationEngine UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Zolko-123 committed Jul 7, 2021
1 parent 55561b4 commit 656d2b0
Show file tree
Hide file tree
Showing 7 changed files with 1,108 additions and 612 deletions.
49 changes: 5 additions & 44 deletions Asm4_libs.py
Expand Up @@ -229,14 +229,17 @@ def getLinkAndDatum():
if isLinkToPart(obj):
# add it to our tree table if it's a link to an App::Part ...
childrenTable.append( obj )

# the selected datum
selObj = Gui.Selection.getSelection()[0]
# a datum is selected
# if indeed a datum is selected
if selObj.TypeId in datumTypes:
# return at least the selected datum object
retval = (None,selObj)
# this returns the selection hierarchy in the form 'linkName.datumName.'
selTree = Gui.Selection.getSelectionEx("", 0)[0].SubElementNames[0]
(parents, toto, dot) = selTree.partition('.'+selObj.Name)
link = App.ActiveDocument.getObject( parents )
# if indeed the datum is the child of a link
if dot =='.' and link in childrenTable:
retval = (link,selObj)
else:
Expand All @@ -249,48 +252,6 @@ def getLinkAndDatum():
return retval


# get from two selected datums the corresponding links
def getLinkAndDatum2():
retval = (None, None, None, None)
# only for Asm4
if checkModel() and len(Gui.Selection.getSelection()) == 2:
parentAssembly = App.ActiveDocument.Model
# find all the links to Part or Body objects
childrenTable = []
for objStr in parentAssembly.getSubObjects():
# the string ends with a . that must be removed
obj = App.ActiveDocument.getObject( objStr[0:-1] )
if isLinkToPart(obj):
# add it to our tree table if it's a link to an App::Part ...
childrenTable.append( obj )

selObjA = Gui.Selection.getSelection()[0]
selObjB = Gui.Selection.getSelection()[1]
# two datum objects are selected
if ((selObjA.TypeId in datumTypes) and (selObjB.TypeId in datumTypes)):
# this returns the selection hierarchy in the form 'linkName.datumName.'
selTreeA = Gui.Selection.getSelectionEx("", 0)[0].SubElementNames[0]
selTreeB = Gui.Selection.getSelectionEx("", 0)[0].SubElementNames[1]
(parentsA, totoA, dotA) = selTreeA.partition('.'+selObjA.Name)
(parentsB, totoB, dotB) = selTreeB.partition('.'+selObjB.Name)
linkA = App.ActiveDocument.getObject( parentsA )
linkB = App.ActiveDocument.getObject( parentsB )
if (dotA =='.' and linkA in childrenTable) and (dotB =='.' and linkB in childrenTable):
retval = (linkA, selObjA, linkB, selObjB)

else:
# see whether the datum objects are in a group, some people like to do that
(parentsA2, dotA, groupNameA) = parentsA.partition('.')
(parentsB2, dotB, groupNameB) = parentsB.partition('.')
linkA2 = App.ActiveDocument.getObject( parentsA2 )
linkB2 = App.ActiveDocument.getObject( parentsB2 )
groupA = App.ActiveDocument.getObject( groupNameA )
groupB = App.ActiveDocument.getObject( groupNameB )
if ((linkA2 in childrenTable and groupA.TypeId=='App::DocumentObjectGroup') and (linkB2 in childrenTable and groupB.TypeId=='App::DocumentObjectGroup')):
retval = (linkA2,selObjA,linkB2,selObjB)

return retval

# get all datums in a part
def getPartLCS( part ):
partLCS = [ ]
Expand Down
32 changes: 19 additions & 13 deletions InitGui.py
Expand Up @@ -181,24 +181,24 @@ def assemblyMenuItems(self):
"Asm4_newPart",
"Asm4_newBody",
"Asm4_newGroup",
"Asm4_insertLink",
self.FastenersCmd,
"Separator",
"Asm4_newSketch",
"Asm4_newLCS",
"Asm4_newPlane",
"Asm4_newAxis",
"Asm4_newPoint",
"Asm4_newHole",
"Asm4_importDatum",
'Asm4_createDatum',
self.FastenersCmd,
#"Asm4_newLCS",
#"Asm4_newPlane",
#"Asm4_newAxis",
#"Asm4_newPoint",
#"Asm4_newHole",
"Separator",
"Asm4_insertLink",
"Asm4_placeLink",
"Asm4_releaseAttachment",
"Asm4_mirrorPart",
"Asm4_circularArray",
"Asm4_placeFastener",
"Asm4_cloneFastenersToAxes",
"Asm4_importDatum",
"Asm4_placeDatum",
"Asm4_releaseAttachment",
"Separator",
"Asm4_infoPart",
"Asm4_makeBOM",
Expand All @@ -207,6 +207,10 @@ def assemblyMenuItems(self):
'Asm4_hideLcs',
"Asm4_addVariable",
"Asm4_delVariable",
#"Asm4_applyConfiguration",
"Asm4_openConfigurations",
#'Asm4_saveConfiguration',
#'Asm4_newConfiguration',
"Asm4_Animate",
"Asm4_updateAssembly"]
return commandList
Expand Down Expand Up @@ -234,6 +238,7 @@ def assemblyToolbarItems(self):
"Asm4_makeBOM",
"Asm4_Measure",
"Asm4_variablesCmd",
"Asm4_openConfigurations",
"Asm4_Animate",
"Asm4_updateAssembly"]
return commandList
Expand Down Expand Up @@ -274,8 +279,7 @@ def ContextMenu(self, recipient):
'Asm4_placeFastener' ,
'Asm4_cloneFastenersToAxes' ,
'Separator' ,
'Asm4_saveConfiguration',
'Asm4_restoreConfiguration']
'Asm4_applyConfiguration']
# commands to appear in the 'Create' sub-menu in the contextual menu (right-click)
createSubMenu =["Asm4_newSketch",
"Asm4_newBody",
Expand All @@ -286,7 +290,9 @@ def ContextMenu(self, recipient):
"Asm4_newHole",
"Asm4_insertScrew",
"Asm4_insertNut",
"Asm4_insertWasher"]
"Asm4_insertWasher",
'Separator',
'Asm4_newConfiguration']

self.appendContextMenu("", "Separator")
self.appendContextMenu("", contextMenu) # add commands to the context menu
Expand Down
213 changes: 213 additions & 0 deletions Resources/icons/Asm4_Configurations.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 656d2b0

Please sign in to comment.