chiark / gitweb /
Add back the ultimaker platform, and made the platform mesh simpler.
[cura.git] / Cura / slice / cura_sf / fabmetheus_utilities / geometry / statements / _print.py
1 """
2 Print statement.
3
4 There is also the print attribute in geometry_utilities/evaluate_fundamentals/print.py
5
6 The model is xml_models/geometry_utilities/evaluate_fundamentals/print.xml
7
8 """
9
10 from __future__ import absolute_import
11
12 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
13
14
15 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
16 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
17 __date__ = '$Date: 2008/02/05 $'
18 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
19
20
21 def getLocalDictionary( attributesKey, elementNode):
22         "Get the local dictionary."
23         xmlProcessor = elementNode.getXMLProcessor()
24         if len( xmlProcessor.functions ) < 1:
25                 return None
26         return xmlProcessor.functions[-1].localDictionary
27
28 def printAttributesKey( attributesKey, elementNode):
29         "Print the attributesKey."
30         if attributesKey.lower() == '_localdictionary':
31                 localDictionary = getLocalDictionary( attributesKey, elementNode)
32                 if localDictionary != None:
33                         localDictionaryKeys = localDictionary.keys()
34                         attributeValue = elementNode.attributes[attributesKey]
35                         if attributeValue != '':
36                                 attributeValue = ' - ' + attributeValue
37                         print('Local Dictionary Variables' + attributeValue )
38                         localDictionaryKeys.sort()
39                         for localDictionaryKey in localDictionaryKeys:
40                                 print('%s: %s' % ( localDictionaryKey, localDictionary[ localDictionaryKey ] ) )
41                         return
42         value = elementNode.attributes[attributesKey]
43         evaluatedValue = None
44         if value == '':
45                 evaluatedValue = evaluate.getEvaluatedExpressionValue(elementNode, attributesKey)
46         else:
47                 evaluatedValue = evaluate.getEvaluatedExpressionValue(elementNode, value)
48         print('%s: %s' % ( attributesKey, evaluatedValue ) )
49
50 def processElementNode(elementNode):
51         "Process the xml element."
52         if len(elementNode.getTextContent()) > 1:
53                 print(elementNode.getTextContent())
54                 return
55         attributesKeys = elementNode.attributes.keys()
56         if len( attributesKeys ) < 1:
57                 print('')
58                 return
59         attributesKeys.sort()
60         for attributesKey in attributesKeys:
61                 printAttributesKey( attributesKey, elementNode)