Skip to content

Commit

Permalink
Part: AttachmentEditor: fix take_selection argument not working
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepSOIC authored and yorikvanhavre committed Jun 16, 2016
1 parent 1c135d6 commit 89ebf5f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py
Expand Up @@ -111,10 +111,11 @@ def GetSelectionAsLinkSubList():
result = []
for selobj in sel:
for subname in selobj.SubElementNames:
result.append((selobj, subname))
result.append((selobj.Object, subname))
if len(selobj.SubElementNames) == 0:
result.append((selobj, ''))
result.append((selobj.Object, ''))
return result


def PlacementsFuzzyCompare(plm1, plm2):
pos_eq = (plm1.Base - plm2.Base).Length < 1e-7 # 1e-7 is OCC's Precision::Confusion
Expand Down Expand Up @@ -263,6 +264,9 @@ def __init__(self, obj_to_attach,
if sel[i][0] is obj_to_attach:
sel.pop(i)
self.attacher.References = sel
# need to update textboxes
self.fillAllRefLines()

if len(self.attacher.References) == 0:
self.i_active_ref = 0
self.auto_next = True
Expand Down Expand Up @@ -430,14 +434,22 @@ def readParameters(self):

self.form.checkBoxFlip.setChecked(self.attacher.Reverse)

self.fillAllRefLines()
finally:
self.block = old_selfblock

def fillAllRefLines(self):
old_block = self.block
try:
self.block = True
strings = StrListFromRefs(self.attacher.References)
if len(strings) < len(self.refLines):
strings.extend(['']*(len(self.refLines) - len(strings)))
for i in range(len(self.refLines)):
self.refLines[i].setText(strings[i])
finally:
self.block = old_selfblock
self.block = old_block

def parseAllRefLines(self):
self.attacher.References = RefsFromStrList([le.text() for le in self.refLines], self.obj.Document)

Expand Down

0 comments on commit 89ebf5f

Please sign in to comment.