chiark / gitweb /
Add uppercase STL and HEX to file dialog filters for linux/MacOS
[cura.git] / Cura / cura_sf / fabmetheus_utilities / geometry / geometry_utilities / evaluate_elements / creation.py
1 """
2 Boolean geometry utilities.
3
4 """
5
6 from __future__ import absolute_import
7 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
8 import __init__
9
10
11 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
12 from fabmetheus_utilities import archive
13 from fabmetheus_utilities import gcodec
14
15
16 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
17 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
18 __date__ = '$Date: 2008/02/05 $'
19 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
20
21
22 def _getAccessibleAttribute(attributeName, elementNode):
23         'Get the accessible attribute.'
24         functionName = attributeName[len('get') :].lower()
25         if functionName not in evaluate.globalCreationDictionary:
26                 print('Warning, functionName not in globalCreationDictionary in _getAccessibleAttribute in creation for:')
27                 print(functionName)
28                 print(elementNode)
29                 return None
30         pluginModule = archive.getModuleWithPath(evaluate.globalCreationDictionary[functionName])
31         if pluginModule == None:
32                 print('Warning, _getAccessibleAttribute in creation can not get a pluginModule for:')
33                 print(functionName)
34                 print(elementNode)
35                 return None
36         return Creation(elementNode, pluginModule).getCreation
37
38
39 class Creation:
40         'Class to handle a creation.'
41         def __init__(self, elementNode, pluginModule):
42                 'Initialize.'
43                 self.elementNode = elementNode
44                 self.pluginModule = pluginModule
45
46         def __repr__(self):
47                 "Get the string representation of this creation."
48                 return self.elementNode
49
50         def getCreation(self, *arguments):
51                 "Get creation."
52                 dictionary = {'_fromCreationEvaluator': 'true'}
53                 firstArgument = None
54                 if len(arguments) > 0:
55                         firstArgument = arguments[0]
56                 if firstArgument.__class__ == dict:
57                         dictionary.update(firstArgument)
58                         return self.pluginModule.getGeometryOutput(None, self.elementNode.getCopyShallow(dictionary))
59                 copyShallow = self.elementNode.getCopyShallow(dictionary)
60                 return self.pluginModule.getGeometryOutputByArguments(arguments, copyShallow)