Beispiel #1
0
 def cmd_str(self, tab_level=0):
     v_str = utility.val_to_str(self.v)
     if self.a:  # If there's an angle use axis/angle
         a_str = utility.val_to_str(self.a)
         return 'rotate(a=%s,v=%s)' % (a_str, v_str)
     # If not a then interpret v as a vector of angles
     return 'rotate(a=%s)' % (v_str)
Beispiel #2
0
 def cmd_str(self, tab_level=0):
     facets = self.facets()  # Retreve object facet information
     tab_str0 = ' ' * utility.TAB_WIDTH * tab_level
     tab_str1 = ' ' * utility.TAB_WIDTH * (tab_level + 1)
     rtn_str = 'polygon(\n'
     rtn_str = '%s%spoints = [\n' % (
         rtn_str,
         tab_str1,
     )
     for p in self.points:
         p_str = utility.val_to_str(p, tab_level=tab_level + 2)
         rtn_str = '%s%s,\n' % (rtn_str, p_str)
     rtn_str = '%s%s],\n' % (
         rtn_str,
         tab_str1,
     )
     rtn_str = '%s%spaths = [\n' % (
         rtn_str,
         tab_str1,
     )
     for p in self.paths:
         p_str = utility.val_to_str(p, tab_level=tab_level + 2)
         rtn_str = '%s%s,\n' % (rtn_str, p_str)
     rtn_str = '%s%s]\n' % (
         rtn_str,
         tab_str1,
     )
     rtn_str += facets
     rtn_str = '%s%s);\n' % (rtn_str, tab_str0)
     return rtn_str
Beispiel #3
0
 def cmd_str(self,tab_level=0):
     v_str = utility.val_to_str(self.v)
     if self.a: # If there's an angle use axis/angle
         a_str = utility.val_to_str(self.a)
         return 'rotate(a=%s,v=%s)'%(a_str,v_str)
     # If not a then interpret v as a vector of angles
     return 'rotate(a=%s)'%(v_str)
Beispiel #4
0
 def cmd_str(self,tab_level=0):
     h_str = utility.val_to_str(self.h)
     twist_str = utility.val_to_str(self.twist)
     center_str = self.center_str()
     if self.slices == None:
         str_tup = (h_str,twist_str,center_str,self.convexity)
         rtn_str = 'linear_extrude(height=%s,twist=%s,center=%s,convexity=%d)'%str_tup
     else:
         str_tup = (h_str,twist_str,center_str,self.convexity,self.slices)
         rtn_str = 'linear_extrude(height=%s,twist=%s,center=%s,convexity=%d,slices=%d)'%str_tup
     return rtn_str
Beispiel #5
0
 def cmd_str(self, tab_level=0):
     h_str = utility.val_to_str(self.h)
     twist_str = utility.val_to_str(self.twist)
     center_str = self.center_str()
     if self.slices == None:
         str_tup = (h_str, twist_str, center_str, self.convexity)
         rtn_str = 'linear_extrude(height=%s,twist=%s,center=%s,convexity=%d)' % str_tup
     else:
         str_tup = (h_str, twist_str, center_str, self.convexity,
                    self.slices)
         rtn_str = 'linear_extrude(height=%s,twist=%s,center=%s,convexity=%d,slices=%d)' % str_tup
     return rtn_str
Beispiel #6
0
 def cmd_str(self, tab_level=0):
     facets = self.facets()  # Retreve object facet information
     center_str = self.center_str()
     h_str = utility.val_to_str(self.h)
     r1_str = utility.val_to_str(self.r1)
     if self.r2:
         r2_str = utility.val_to_str(self.r2)
         return 'cylinder(h={0},r1={1},r2={2},center={3});'.format(
             h_str, r1_str, r2_str, center_str, facets)
     # When Cylinder is constant radius the argument is just called 'r'
     return 'cylinder(h={0},r={1},center={2}{3});'.format(
         h_str, r1_str, center_str, facets)
Beispiel #7
0
 def cmd_str(self, tab_level=0):
     tab_str = ' ' * utility.TAB_WIDTH * tab_level
     rtn_str = ''
     for k, v in self.items():
         rtn_str += '{0}{1} = {2};\n'.format(tab_str, k,
                                             utility.val_to_str(v))
     return rtn_str + '\n'
Beispiel #8
0
 def cmd_str(self,tab_level=0):
     facets = self.facets() # Retreve object facet information
     r_str = utility.val_to_str(self.r)
     center_str = self.center_str()
     return 'sphere(r={0}, center={1}{2});'.format(r_str,
                                                   center_str,
                                                   facets)
Beispiel #9
0
 def cmd_str(self,tab_level=0):
     facets = self.facets() # Retreve object facet information
     size_str = utility.val_to_str(self.size)
     center_str = self.center_str()
     return 'cube(size={0}, center={1}{2});'.format(size_str,
                                                    center_str,
                                                    facets)
Beispiel #10
0
 def cmd_str(self,tab_level=0):
     facets = self.facets() # Retreve object facet information
     center_str = self.center_str()
     h_str = utility.val_to_str(self.h)
     r1_str = utility.val_to_str(self.r1)
     if self.r2:
         r2_str = utility.val_to_str(self.r2)
         return 'cylinder(h={0},r1={1},r2={2},center={3});'.format(h_str,
                                                                   r1_str,
                                                                   r2_str,
                                                                   center_str,
                                                                   facets)
     # When Cylinder is constant radius the argument is just called 'r'
     return 'cylinder(h={0},r={1},center={2}{3});'.format(h_str,
                                                          r1_str,
                                                          center_str,
                                                          facets)
Beispiel #11
0
 def cmd_str(self,tab_level=0):
     facets = self.facets() # Retreve object facet information
     tab_str0 = ' '*utility.TAB_WIDTH*tab_level
     tab_str1 = ' '*utility.TAB_WIDTH*(tab_level+1)
     rtn_str = 'polygon(\n'
     rtn_str = '%s%spoints = [\n'%(rtn_str,tab_str1,)
     for p in self.points:
         p_str = utility.val_to_str(p,tab_level=tab_level+2)
         rtn_str = '%s%s,\n'%(rtn_str,p_str)
     rtn_str = '%s%s],\n'%(rtn_str,tab_str1,)
     rtn_str = '%s%spaths = [\n'%(rtn_str,tab_str1,)
     for p in self.paths:
         p_str = utility.val_to_str(p,tab_level=tab_level+2)
         rtn_str = '%s%s,\n'%(rtn_str,p_str)
     rtn_str = '%s%s]\n'%(rtn_str,tab_str1,)
     rtn_str += facets
     rtn_str = '%s%s);\n'%(rtn_str,tab_str0)
     return rtn_str
Beispiel #12
0
 def __call__(self, mod='', *args):
     """Returns a string calling this module with provided arguments."""
     if mod and not mod in list('*!#%'): # mod can eat he first arg
         args = (mod,) + args
         mod = ''
     if len(args) > len(self.args):
         raise TypeError("{0}() takes exactly {1} argument(s) ({2} given)".format(self.name, len(self.args), len(args)))
     return "{0}{1}({2});".format(mod, self.name,
             ', '.join(utility.val_to_str(arg) for arg in args))
Beispiel #13
0
 def __call__(self, mod='', *args):
     """Returns a string calling this module with provided arguments."""
     if mod and not mod in list('*!#%'):  # mod can eat he first arg
         args = (mod, ) + args
         mod = ''
     if len(args) > len(self.args):
         raise TypeError(
             "{0}() takes exactly {1} argument(s) ({2} given)".format(
                 self.name, len(self.args), len(args)))
     return "{0}{1}({2});".format(
         mod, self.name, ', '.join(utility.val_to_str(arg) for arg in args))
Beispiel #14
0
 def __str__(self, tab_level=0):
     tab_str = ' ' * TAB_WIDTH * tab_level
     mod_str = self.mod
     comment = ''
     if self.comment:
         comment = tab_str + '// ' + self.comment + '\n'
     rtn_str = '{0}{1}{2}'.format(tab_str, mod_str,
                                  self.cmd_str(tab_level=tab_level))
     if self.translate:
         translate = tab_str + "translate(" + val_to_str(self.translate)
         rtn_str = translate + ") {\n" + ' ' * TAB_WIDTH + rtn_str + "\n}"
     return comment + rtn_str
Beispiel #15
0
 def cmd_str(self, tab_level=0):
     facets = self.facets()  # Retreve object facet information
     size_str = utility.val_to_str(self.size)
     center_str = self.center_str()
     return 'cube(size={0}, center={1}{2});'.format(size_str, center_str,
                                                    facets)
Beispiel #16
0
 def cmd_str(self,tab_level=0):
     rgba_str = utility.val_to_str(self.rgba)
     return 'color(%s)'%(rgba_str,)
Beispiel #17
0
 def cmd_str(self,tab_level=0):
     v_str = utility.val_to_str(self.v)
     return 'mirror(v=%s)'%(v_str,)
Beispiel #18
0
 def cmd_str(self, tab_level=0):
     v_str = utility.val_to_str(self.v)
     return 'translate(v=%s)' % (v_str, )
Beispiel #19
0
 def cmd_str(self, tab_level=0):
     facets = self.facets()  # Retreve object facet information
     r_str = utility.val_to_str(self.r)
     center_str = self.center_str()
     return 'sphere(r={0}, center={1}{2});'.format(r_str, center_str,
                                                   facets)
Beispiel #20
0
 def cmd_str(self, tab_level=0):
     v_str = utility.val_to_str(self.v)
     return 'scale(v=%s)' % (v_str)
Beispiel #21
0
 def cmd_str(self, tab_level=0):
     rgba_str = utility.val_to_str(self.rgba)
     return 'color(%s)' % (rgba_str, )
Beispiel #22
0
 def cmd_str(self, tab_level=0):
     facets = self.facets()  # Retreve object facet information
     r_str = utility.val_to_str(self.r)
     rtn_str = 'circle(r={0}{1});'.format(r_str, facets)
     return rtn_str
Beispiel #23
0
 def cmd_str(self, tab_level=0):
     tab_str = ' '*utility.TAB_WIDTH*tab_level
     rtn_str = ''
     for k,v in self.items():
         rtn_str += '{0}{1} = {2};\n'.format(tab_str, k, utility.val_to_str(v))
     return rtn_str + '\n'
Beispiel #24
0
 def cmd_str(self,tab_level=0):
     v_str = utility.val_to_str(self.v)
     return 'scale(v=%s)'%(v_str)
Beispiel #25
0
 def cmd_str(self,tab_level=0):
     facets = self.facets() # Retreve object facet information
     r_str = utility.val_to_str(self.r)
     rtn_str = 'circle(r={0}{1});'.format(r_str, facets)
     return rtn_str
Beispiel #26
0
 def cmd_str(self,tab_level=0):
     v_str = utility.val_to_str(self.v)
     return 'translate(v=%s)'%(v_str,)
Beispiel #27
0
 def cmd_str(self, tab_level=0):
     v_str = utility.val_to_str(self.v)
     return 'mirror(v=%s)' % (v_str, )