Skip to content

Commit

Permalink
bugfix: partslist got struggled with step files
Browse files Browse the repository at this point in the history
  • Loading branch information
kbwbe committed Feb 15, 2019
1 parent 356d10c commit f806369
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__title__ = 'A2plus assembly Workbench - InitGui file'
__author__ = 'kbwbe'

A2P_VERSION = 'V0.3.7'
A2P_VERSION = 'V0.3.8'

import sys
PyVersion = sys.version_info[0]
Expand Down
1 change: 1 addition & 0 deletions a2p_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def createPartList(
parentAssemblyDir
)
workingDir,basicFileName = os.path.split(fileNameInProject)

docReader1 = FCdocumentReader()
docReader1.openDocument(fileNameInProject)

Expand Down
15 changes: 15 additions & 0 deletions a2p_simpleXMLreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@ class for extracting the XML-Documentdata from a fcstd-file given by
def __init__(self):
self.xmlLines = []
self.objects = []
self.successfulOpened = False

def clear(self):
self.xmlLines = []
self.objects = []
self.successfulOpened = False

def openDocument(self,_fileName):
fileName = _fileName
Expand All @@ -215,14 +217,24 @@ def openDocument(self,_fileName):
fileName = a2plib.to_str(fileName)

self.clear()

# check whether file exists or not...
if not os.path.exists( fileName ):
print (u"fcDocumentReader: file {} does not exist!".format(fileName))
successfulOpened = False
return

# check for fcstd file
if not fileName.lower().endswith(a2plib.to_str('.fcstd')):
print (u"fcDocumentReader: file {} is no FCStd file!".format(fileName))
successfulOpened = False
return

# decompress the file
f = zipfile.ZipFile(fileName,'r')
xml = f.read('Document.xml')
f.close()
self.successfulOpened = True
#
#self.xmlLines = xml.split("\r\n") #Windows
self.xmlLines = xml.split(b'\r\n') #Windows
Expand Down Expand Up @@ -253,6 +265,7 @@ def openDocument(self,_fileName):
self.objects = tmp

def getA2pObjects(self):
if not self.successfulOpened: return []
out = []
for ob in self.objects:
if ob.propertyDict.get(b'a2p_Version',None) != None:
Expand All @@ -261,13 +274,15 @@ def getA2pObjects(self):
return out

def getSpreadsheetObjects(self):
if not self.successfulOpened: return []
out = []
for ob in self.objects:
if ob.propertyDict.get(b'cells',None) != None:
out.append(ob)
return out

def getObjectByName(self,name):
if not self.successfulOpened: return None
for ob in self.objects:
if ob.name == name:
return ob
Expand Down

0 comments on commit f806369

Please sign in to comment.