Skip to content

Commit

Permalink
renaming LCS
Browse files Browse the repository at this point in the history
* 2019.06.15 (version 0.5.3) : <br/>
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
  • Loading branch information
Zolko-123 committed Jun 19, 2019
1 parent dea9c62 commit 06470bb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 30 deletions.
8 changes: 4 additions & 4 deletions Mod_Asm4/InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion Mod_Asm4/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Assembly 4 Workbench for FreeCAD-LinkStage3
v0.5.2 2019.05.07
v0.5.3 2019.06.15

69 changes: 44 additions & 25 deletions Mod_Asm4/placeLinkCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class placeLink( QtGui.QDialog ):
def __init__(self):
super(placeLink,self).__init__()
self.selectedLink = []
self.attLCStable = []


def GetResources(self):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -209,15 +219,17 @@ 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 +'***' )

# 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 +'***' )
Expand Down Expand Up @@ -293,33 +305,38 @@ 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
else:
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


Expand All @@ -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


Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ Therefore, in order to re-use a coordinate system of a part in an assembly, a co
<br/>
#### Release notes:<br/>

* 2019.06.15 (version 0.5.3) : <br/>
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) : <br/>
added insertDatumCmd

Expand Down

0 comments on commit 06470bb

Please sign in to comment.