From 06470bb5a06c69d0e15061729fd05ee75ba96f1e Mon Sep 17 00:00:00 2001 From: Zolko Date: Wed, 19 Jun 2019 09:39:19 +0200 Subject: [PATCH] renaming LCS * 2019.06.15 (version 0.5.3) :
Now the LCS can be renamed, and they show up in the LCS list in the command placeLink as such. It's only visual, the ExpressionEngine still uses the LCS.Name though --- Mod_Asm4/InitGui.py | 8 ++--- Mod_Asm4/VERSION | 2 +- Mod_Asm4/placeLinkCmd.py | 69 +++++++++++++++++++++++++--------------- README.md | 4 +++ 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/Mod_Asm4/InitGui.py b/Mod_Asm4/InitGui.py index 29e73acf..1b0396f7 100644 --- a/Mod_Asm4/InitGui.py +++ b/Mod_Asm4/InitGui.py @@ -81,11 +81,11 @@ def Initialize(self): #self.appendMenu(["&Edit","DynamicData"],self.list) # appends a submenu to an existing menu - """ + """ ╔═══════════════════════════════════════════════╗ ║ Standard necessary functions ║ ╚═══════════════════════════════════════════════╝ - """ + """ def Activated(self): "This function is executed when the workbench is activated" return @@ -105,8 +105,8 @@ def ContextMenu(self, recipient): def GetClassName(self): # this function is mandatory if this is a full python workbench return "Gui::PythonWorkbench" - - + + wb = Assembly4_WorkBench() Gui.addWorkbench(wb) diff --git a/Mod_Asm4/VERSION b/Mod_Asm4/VERSION index bd0b1de9..fc0b811a 100644 --- a/Mod_Asm4/VERSION +++ b/Mod_Asm4/VERSION @@ -1,3 +1,3 @@ Assembly 4 Workbench for FreeCAD-LinkStage3 -v0.5.2 2019.05.07 +v0.5.3 2019.06.15 diff --git a/Mod_Asm4/placeLinkCmd.py b/Mod_Asm4/placeLinkCmd.py index e8fd9c3f..7c9f2bf2 100644 --- a/Mod_Asm4/placeLinkCmd.py +++ b/Mod_Asm4/placeLinkCmd.py @@ -25,6 +25,7 @@ class placeLink( QtGui.QDialog ): def __init__(self): super(placeLink,self).__init__() self.selectedLink = [] + self.attLCStable = [] def GetResources(self): @@ -71,6 +72,9 @@ def Activated(self): self.old_AO = [] self.old_EE = [] self.constrFeature = [] + self.attLCStable = [] + self.partLCStable = [] + # name of the constraints object for the link self.constrName = constraintPrefix + self.selectedLink.Name @@ -102,11 +106,15 @@ def Activated(self): ( self.old_Expression, self.old_attPart, self.old_attLCS, self.old_constrLink, self.old_linkLCS ) = splitExpressionPart( self.old_EE, self.old_attachment ) # get all the LCS in the selected linked part - partLCS = self.getPartLCS( self.selectedLink.LinkedObject ) + self.partLCStable = self.getPartLCS( self.selectedLink.LinkedObject ) # build the list - for lcs in partLCS: + for lcs in self.partLCStable: newItem = QtGui.QListWidgetItem() - newItem.setText( lcs.Name ) + if lcs.Name == lcs.Label: + newItem.setText( lcs.Name ) + else: + newItem.setText( lcs.Label + ' (' +lcs.Name+ ')' ) + #newItem.setIcon( lcs.ViewObject.Icon ) #self.lcsIcon = lcs.ViewObject.Icon self.partLCSlist.addItem(newItem) @@ -115,7 +123,8 @@ def Activated(self): self.oldLCS = self.partLCSlist.findItems( self.old_linkLCS, QtCore.Qt.CaseSensitive ) if self.oldLCS: # ... and select it - self.partLCSlist.setCurrentItem( self.oldLCS[0], QtGui.QItemSelectionModel.Select ) + # self.partLCSlist.setCurrentItem( self.oldLCS[0], QtGui.QItemSelectionModel.Select ) + self.partLCSlist.setCurrentItem( self.oldLCS[0] ) # fill the parent selection combo-box # Search for all App::Links in the documents @@ -140,7 +149,8 @@ def Activated(self): self.oldLCS = self.attLCSlist.findItems( self.old_attLCS, QtCore.Qt.CaseSensitive ) if self.oldLCS: # ... and select it - self.attLCSlist.setCurrentItem( self.oldLCS[0], QtGui.QItemSelectionModel.Select ) + # self.attLCSlist.setCurrentItem( self.oldLCS[0], QtGui.QItemSelectionModel.Select ) + self.attLCSlist.setCurrentItem( self.oldLCS[0] ) # the widget is shown and not executed to allow it to stay on top self.show() @@ -209,7 +219,8 @@ def onApply( self ): # the attachment LCS's name in the parent # check that something is selected in the QlistWidget if self.attLCSlist.selectedItems(): - a_LCS = self.attLCSlist.selectedItems()[0].text() + #a_LCS = self.attLCSlist.selectedItems()[0].text() + a_LCS = self.attLCStable[ self.attLCSlist.currentRow() ].Name else: a_LCS = None #self.expression.setText( '***'+ a_LCS +'***' ) @@ -217,7 +228,8 @@ def onApply( self ): # the LCS's name in the linked part to be used for its attachment # check that something is selected in the QlistWidget if self.partLCSlist.selectedItems(): - l_LCS = self.partLCSlist.selectedItems()[0].text() + #l_LCS = self.partLCSlist.selectedItems()[0].text() + l_LCS = self.partLCStable[ self.partLCSlist.currentRow() ].Name else: l_LCS = None #self.expression.setText( '***'+ l_LCS +'***' ) @@ -293,16 +305,17 @@ def getPartLCS( self, part ): def onParentList(self): # clear the LCS list self.attLCSlist.clear() + self.attLCStable = [] # clear the selection in the GUI window Gui.Selection.clearSelection() # the current text in the combo-box is the link's name... parentName = self.parentList.currentText() - partLCS = [] + # partLCS = [] # ... or it's 'Parent Assembly' then the parent is the 'Model' root App::Part if parentName =='Parent Assembly': parentPart = self.activeDoc.getObject( 'Model' ) # we get the LCS directly in the root App::Part 'Model' - partLCS = self.getPartLCS( parentPart ) + self.attLCStable = self.getPartLCS( parentPart ) self.parentDoc.setText( parentPart.Document.Name ) # a sister object is an App::Link # the .LinkedObject is an App::Part @@ -310,16 +323,20 @@ def onParentList(self): parentPart = self.activeDoc.getObject( parentName ) if parentPart: # we get the LCS from the linked part - partLCS = self.getPartLCS( parentPart.LinkedObject ) + self.attLCStable = self.getPartLCS( parentPart.LinkedObject ) self.parentDoc.setText( parentPart.LinkedObject.Document.Name ) # highlight the selected part: Gui.Selection.addSelection( parentPart.Document.Name, 'Model', parentPart.Name+'.' ) # build the list - for lcs in partLCS: + for lcs in self.attLCStable: newItem = QtGui.QListWidgetItem() - newItem.setText( lcs.Name ) + if lcs.Name == lcs.Label: + newItem.setText( lcs.Name ) + else: + newItem.setText( lcs.Label + ' (' +lcs.Name+ ')' ) newItem.setIcon( lcs.ViewObject.Icon ) self.attLCSlist.addItem( newItem ) + #self.attLCStable.append(lcs) return @@ -334,20 +351,22 @@ def onLCSclicked( self ): # clear the selection in the GUI window Gui.Selection.clearSelection() # LCS of the linked part - p_LCS = self.partLCSlist.selectedItems()[0].text() - Gui.Selection.addSelection( self.activeDoc.Name, 'Model', self.selectedLink.Name+'.'+p_LCS+'.') + if self.partLCSlist.selectedItems(): + #p_LCS = self.partLCSlist.selectedItems()[0].text() + p_LCS = self.partLCStable[ self.partLCSlist.currentRow() ].Name + Gui.Selection.addSelection( self.activeDoc.Name, 'Model', self.selectedLink.Name+'.'+p_LCS+'.') # LCS in the parent - a_LCS = self.attLCSlist.selectedItems()[0].text() - # get the part where the selected LCS is - a_Part = self.parentList.currentText() - # parent assembly and sister part need a different treatment - if a_Part == 'Parent Assembly': - linkDot = '' - else: - linkDot = a_Part+'.' - # Gui.Selection.addSelection('asm_Test','Model','Lego_3001.LCS_h2x1.') - # Gui.Selection.addSelection('asm_Test','Model','LCS_0.') - Gui.Selection.addSelection( self.activeDoc.Name, 'Model', linkDot+a_LCS+'.') + if self.attLCSlist.selectedItems(): + #a_LCS = self.attLCSlist.selectedItems()[0].text() + a_LCS = self.attLCStable[ self.attLCSlist.currentRow() ].Name + # get the part where the selected LCS is + a_Part = self.parentList.currentText() + # parent assembly and sister part need a different treatment + if a_Part == 'Parent Assembly': + linkDot = '' + else: + linkDot = a_Part+'.' + Gui.Selection.addSelection( self.activeDoc.Name, 'Model', linkDot+a_LCS+'.') return diff --git a/README.md b/README.md index b97b0584..c47d27ee 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,10 @@ Therefore, in order to re-use a coordinate system of a part in an assembly, a co
#### Release notes:
+* 2019.06.15 (version 0.5.3) :
+Now the LCS can be renamed, and they show up in the LCS list in the command placeLink as such. +It's only visual, the ExpressionEngine still uses the LCS.Name though + * 2019.05.07 (version 0.5.2) :
added insertDatumCmd