Skip to content

Commit

Permalink
Merge pull request #147 from kbwbe/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
kbwbe authored Jan 15, 2019
2 parents 698f6df + 2535d43 commit a4b7f48
Show file tree
Hide file tree
Showing 13 changed files with 1,070 additions and 58 deletions.
1 change: 1 addition & 0 deletions A2plus.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>icons/a2p_recursiveUpdate.svg</file>
<file>icons/a2p_Asm.svg</file>
<file>icons/a2p_Obj.svg</file>
<file>icons/a2p_EditConstraint.svg</file>
Expand Down
42 changes: 34 additions & 8 deletions GuiA2p/Resources/ui/a2p_prefs.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>705</width>
<height>731</height>
<height>776</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -101,9 +101,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>140</y>
<y>173</y>
<width>687</width>
<height>234</height>
<height>201</height>
</rect>
</property>
<property name="title">
Expand All @@ -112,10 +112,10 @@
<widget class="QWidget" name="verticalLayoutWidget_3">
<property name="geometry">
<rect>
<x>49</x>
<y>40</y>
<x>30</x>
<y>30</y>
<width>537</width>
<height>171</height>
<height>151</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -194,9 +194,9 @@
<property name="geometry">
<rect>
<x>30</x>
<y>40</y>
<y>27</y>
<width>521</width>
<height>95</height>
<height>131</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down Expand Up @@ -232,6 +232,19 @@
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBox_5">
<property name="text">
<string>enable recursive update of imported parts</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>enableRecursiveUpdate</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/A2plus</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBox">
<property name="text">
Expand All @@ -245,6 +258,19 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
Expand Down
31 changes: 22 additions & 9 deletions InitGui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
#***************************************************************************
#* *
#* Copyright (c) 2018 kbwbe *
Expand Down Expand Up @@ -38,7 +39,7 @@ class a2pWorkbench (Workbench):
def __init__(self):
import a2plib
self.__class__.Icon = a2plib.pathOfModule() + "/icons/a2p_workbench.svg"
self.__class__.MenuText = 'A2plus V0.2.4'
self.__class__.MenuText = 'A2plus V0.2.5'
self.__class__.ToolTip = 'An other assembly workbench for FreeCAD'

def Initialize(self):
Expand All @@ -50,6 +51,7 @@ def Initialize(self):
import a2p_Resources3
import a2plib #QtCore.QResource.registerResource happens in assembly2lib
import a2p_importpart
import a2p_recursiveUpdatePlanner
import a2p_convertPart
import a2p_solversystem
import a2p_MuxAssembly
Expand All @@ -58,14 +60,25 @@ def Initialize(self):
import a2p_constraintcommands
import a2p_bom # bom == bill of materials == partslist

partCommands = [
'a2p_ImportPart',
'a2p_updateImportedParts',
'a2p_movePart',
'a2p_duplicatePart',
'a2p_ConvertPart',
'a2p_editImportedPart',
]
if a2plib.getRecursiveUpdateEnabled():
partCommands = [
'a2p_ImportPart',
'a2p_updateImportedParts',
'a2p_recursiveUpdateImportedPartsCommand',
'a2p_movePart',
'a2p_duplicatePart',
'a2p_ConvertPart',
'a2p_editImportedPart',
]
else:
partCommands = [
'a2p_ImportPart',
'a2p_updateImportedParts',
'a2p_movePart',
'a2p_duplicatePart',
'a2p_ConvertPart',
'a2p_editImportedPart',
]

if a2plib.SHOW_CONSTRAINTS_ON_TOOLBAR:
constraintCommands = [
Expand Down
8 changes: 4 additions & 4 deletions a2p_Resources2.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions a2p_Resources3.py

Large diffs are not rendered by default.

37 changes: 23 additions & 14 deletions a2p_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import string

import a2plib
from a2p_fcdocumentreader import FCdocumentReader
#from a2p_fcdocumentreader import FCdocumentReader
from a2p_simpleXMLreader import FCdocumentReader

from a2p_partlistglobals import (
PARTLIST_COLUMN_NAMES,
Expand Down Expand Up @@ -60,10 +61,9 @@ def createPartList(
)
workingDir,basicFileName = os.path.split(fileNameInProject)
docReader1 = FCdocumentReader()

docReader1.openDocument(fileNameInProject)

for ob in docReader1.getA2pObjects():
#print(u'{}, Subassembly? = {}'.format(ob,ob.isSubassembly()))
if ob.isSubassembly() and recursive:
partListEntries = createPartList(
ob.getA2pSource(),
Expand All @@ -76,7 +76,7 @@ def createPartList(
if not ob.isSubassembly() or not recursive:
# Try to get spreadsheetdata _PARTINFO_ from linked source
linkedSource = ob.getA2pSource()
linkedSource = a2plib.findSourceFileInProject(
linkedSource = a2plib.findSourceFileInProject( #this returns unicode on py2 systems!
linkedSource,
workingDir
)
Expand All @@ -89,21 +89,29 @@ def createPartList(
# There is no entry in dict, need to read out information from importFile...
docReader2 = FCdocumentReader()
docReader2.openDocument(linkedSource)

# Initialize a default parts information...
partInformation = []
for i in range(0,len(PARTLIST_COLUMN_NAMES)):
partInformation.append("*")
# last entry of partinformations is reserved for filename
partInformation[-1] = os.path.split(linkedSource)[1] #without complete path...

# if there is a proper spreadsheat, then read it...
for ob in docReader2.getSpreadsheetObjects():
if ob.name == PARTINFORMATION_SHEET_NAME:

sheetName = PARTINFORMATION_SHEET_NAME
if a2plib.PYVERSION > 2:
sheetName = a2plib.to_bytes(PARTINFORMATION_SHEET_NAME)

if ob.name == sheetName:
cells = ob.getCells()
for addr in cells.keys():
if addr[:1] == 'B': #column B contains the information
if addr[:1] == b'B': #column B contains the data, A only the titles
idx = int(addr[1:])-1
if idx < len(PARTLIST_COLUMN_NAMES): # don't read further!
partInformation[idx] = cells[addr]
# last entry of partinformations is reserved for filename
partInformation[-1] = os.path.split(linkedSource)[1] #without complete path...

# put information to dict and count usage of sourcefiles..
entry = partListEntries.get(linkedSource,None)
if entry == None:
Expand Down Expand Up @@ -190,22 +198,23 @@ def Activated(self):
# Set the background color of the column headers
ss.setBackground('A1:'+chr(idx2-1)+'1', (0.000000,1.000000,0.000000,1.000000))
# Set the columnwith to proper values
ss.setColumnWidth('A',75)
ss.setColumnWidth('A',40)
i=0
for c in range(idx1,idx2):
ss.setColumnWidth(chr(c),250)
ss.setColumnWidth(chr(c),150)
i+=1
# fill entries for partsList...
idx3 = ord('A')
for idx, k in enumerate(partListEntries.keys()):
ss.set('A'+str(idx+2),str(idx+1))
ss.set('B'+str(idx+2),str(partListEntries[k][0]))
values = partListEntries[k][1]
for j,tx in enumerate(values):
if a2plib.PYVERSION == 2:
tx2 = tx.encode('UTF-8')
for j,tx in enumerate(values): # all strings inside values are unicode!
#ss.set needs 2. argument as unicode for py3 and utf-8 string for py2!!!
if a2plib.PYVERSION > 2:
tx2 = tx # preserve unicode
else:
tx2 = tx
tx2 = a2plib.to_bytes(tx) # convert to utf-8
ss.set(chr(idx3+2+j)+str(idx+2),tx2)

# recompute to finish..
Expand Down
2 changes: 1 addition & 1 deletion a2p_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def clear(self):
self.lockRotation = False

def __str__(self):
return "Dependencies between {}-{}, type {}".format(
return u"Dependencies between {}-{}, type {}".format(
self.currentRigid.label,
self.dependedRigid.label,
self.Type
Expand Down
23 changes: 23 additions & 0 deletions a2p_fcdocumentreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def getBool(self):
else:
return False

#------------------------------------------------------------------------------
class A2p_xmldoc_PropertyFloat(A2p_xmldoc_Property):

def getFloat(self):
s = self.treeElement.find('Float')
return float( s.attrib['value'] )

#------------------------------------------------------------------------------
class A2p_xmldoc_PropertyFile(A2p_xmldoc_Property):

Expand Down Expand Up @@ -119,6 +126,13 @@ def loadPropertyDict(self,tree):
e.attrib['type']
)
self.propertyDict[e.attrib['name']] = p
elif e.attrib['type'] == 'App::PropertyFloat':
p = A2p_xmldoc_PropertyFloat(
e,
e.attrib['name'],
e.attrib['type']
)
self.propertyDict[e.attrib['name']] = p
elif e.attrib['type'] == 'App::PropertyFile':
p = A2p_xmldoc_PropertyFile(
e,
Expand Down Expand Up @@ -161,6 +175,15 @@ def isSubassembly(self):
else:
return False
return False

def getTimeLastImport(self):
if self.isA2pObject:
propFound = self.propertyDict.get('timeLastImport',None)
if propFound:
return propFound.getFloat()
else:
return 0
return 0

#------------------------------------------------------------------------------
class FCdocumentReader(object):
Expand Down
Loading

0 comments on commit a4b7f48

Please sign in to comment.