Skip to content

Commit

Permalink
force saving before partlist creation
Browse files Browse the repository at this point in the history
  • Loading branch information
kbwbe committed Nov 7, 2018
1 parent b65357f commit 089aa16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
28 changes: 21 additions & 7 deletions a2p_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
from PySide import QtGui, QtCore
import Spreadsheet
import os
import string

import a2plib
from a2p_fcdocumentreader import FCdocumentReader
from a2p_partlistglobals import PARTLIST_COLUMN_NAMES

from a2p_partlistglobals import (
PARTLIST_COLUMN_NAMES,
BOM_SHEET_NAME,
BOM_SHEET_LABEL,
PARTINFORMATION_SHEET_NAME
PARTINFORMATION_SHEET_NAME,
BOM_MAX_LENGTH
)


Expand Down Expand Up @@ -115,6 +117,16 @@ def createPartList(

#------------------------------------------------------------------------------
class a2p_CreatePartlist():

def clearPartList(self):
alphabet_list = list(string.ascii_uppercase)
doc = FreeCAD.activeDocument()
ss = doc.getObject(BOM_SHEET_NAME)
for i in range(0,12): #12 Rows enought for a partlist
for k in range(0,BOM_MAX_LENGTH):
cellAdress = alphabet_list[i]+str(k+1)
print cellAdress
ss.set(cellAdress,'')

def Activated(self):
doc = FreeCAD.activeDocument()
Expand Down Expand Up @@ -154,14 +166,16 @@ def Activated(self):
recursive=subAssyRecursion
)

# delete old BOM if one exists...
ss = None
try:
doc.removeObject(BOM_SHEET_NAME)
ss = doc.getObject(BOM_SHEET_NAME)
except:
pass
# create a spreadsheet with a special reserved name...
ss = doc.addObject('Spreadsheet::Sheet',BOM_SHEET_NAME)
ss.Label = BOM_SHEET_LABEL
if ss == None:
ss = doc.addObject('Spreadsheet::Sheet',BOM_SHEET_NAME)
ss.Label = BOM_SHEET_LABEL
else:
self.clearPartList()

# Write Column headers to spreadsheet
ss.set('A1',u'POS')
Expand Down
1 change: 1 addition & 0 deletions a2p_partlistglobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

BOM_SHEET_NAME = '_PARTSLIST_' #BOM = BillOfMaterials...
BOM_SHEET_LABEL = '#PARTSLIST#'
BOM_MAX_LENGTH = 150


PARTLIST_COLUMN_NAMES = [
Expand Down

0 comments on commit 089aa16

Please sign in to comment.