parameters: (self)
docstring: adds a new component
docstring_summary: adds a new component
docstring_tokens: adds a new component
function: def create(self):
  
          'adds a new component'
  
          # testing if fields are ok
          ok = True
          ar = []
          for i in range(5):
              if i == 1: # type (1)
                  n = getattr(self,"field"+str(i+1)).currentIndex()
                  if n in range(len(WindowPartTypes)):
                      t = WindowPartTypes[n]
                  else:
                      # if type was not specified or is invalid, we set a default
                      t = WindowPartTypes[0]
              else: # name (0)
                  t = str(getattr(self,"field"+str(i+1)).property("text"))
                  if t in WindowPartTypes:
                      t = t + "_" # avoiding part names similar to types
              if t == "":
                  if not(i in [1,5]):
                      ok = False
              else:
                  if i > 2: # thickness (3), offset (4)
                      try:
                          q = FreeCAD.Units.Quantity(t)
                          t = str(q.Value)
                          if i == 3:
                              if self.addp4.isChecked():
                                  t += "+V"
                          if i == 4:
                              if self.addp5.isChecked():
                                  t += "+V"
                      except (ValueError,TypeError):
                          ok = False
                  elif i == 2:
                      # check additional opening parameters
                      hinge = self.field6.property("text")
                      n = self.field7.currentIndex()
                      if (hinge.startswith("Edge")) and (n > 0):
                          # remove accelerator added by Qt
                          hinge = hinge.replace("&","")
                          t += "," + hinge + ",Mode" + str(n)
              ar.append(t)
  
          if ok:
              if self.obj:
                  parts = self.obj.WindowParts
                  if ar[0] in parts:
                      b = parts.index(ar[0])
                      for i in range(5):
                          parts[b+i] = ar[i]
                  else:
                      parts.extend(ar)
                  self.obj.WindowParts = parts
                  self.update()
          else:
              FreeCAD.Console.PrintWarning(translate("Arch", "Unable to create component")+"\n")
  
          self.newtitle.setVisible(False)
          self.new1.setVisible(False)
          self.new2.setVisible(False)
          self.new3.setVisible(False)
          self.new4.setVisible(False)
          self.new5.setVisible(False)
          self.new6.setVisible(False)
          self.new7.setVisible(False)
          self.field1.setVisible(False)
          self.field2.setVisible(False)
          self.field3.setVisible(False)
          self.field4.setVisible(False)
          self.field5.setVisible(False)
          self.field6.setVisible(False)
          self.field7.setVisible(False)
          self.addp4.setVisible(False)
          self.addp5.setVisible(False)
          self.createButton.setVisible(False)
          self.addButton.setEnabled(True)
function_tokens: def create ( self ) : # testing if fields are ok ok = True ar = [ ] for i in range ( 5 ) : if i == 1 : # type (1) n = getattr ( self , "field" + str ( i + 1 ) ) . currentIndex ( ) if n in range ( len ( WindowPartTypes ) ) : t = WindowPartTypes [ n ] else : # if type was not specified or is invalid, we set a default t = WindowPartTypes [ 0 ] else : # name (0) t = str ( getattr ( self , "field" + str ( i + 1 ) ) . property ( "text" ) ) if t in WindowPartTypes : t = t + "_" # avoiding part names similar to types if t == "" : if not ( i in [ 1 , 5 ] ) : ok = False else : if i > 2 : # thickness (3), offset (4) try : q = FreeCAD . Units . Quantity ( t ) t = str ( q . Value ) if i == 3 : if self . addp4 . isChecked ( ) : t += "+V" if i == 4 : if self . addp5 . isChecked ( ) : t += "+V" except ( ValueError , TypeError ) : ok = False elif i == 2 : # check additional opening parameters hinge = self . field6 . property ( "text" ) n = self . field7 . currentIndex ( ) if ( hinge . startswith ( "Edge" ) ) and ( n > 0 ) : # remove accelerator added by Qt hinge = hinge . replace ( "&" , "" ) t += "," + hinge + ",Mode" + str ( n ) ar . append ( t ) if ok : if self . obj : parts = self . obj . WindowParts if ar [ 0 ] in parts : b = parts . index ( ar [ 0 ] ) for i in range ( 5 ) : parts [ b + i ] = ar [ i ] else : parts . extend ( ar ) self . obj . WindowParts = parts self . update ( ) else : FreeCAD . Console . PrintWarning ( translate ( "Arch" , "Unable to create component" ) + "\n" ) self . newtitle . setVisible ( False ) self . new1 . setVisible ( False ) self . new2 . setVisible ( False ) self . new3 . setVisible ( False ) self . new4 . setVisible ( False ) self . new5 . setVisible ( False ) self . new6 . setVisible ( False ) self . new7 . setVisible ( False ) self . field1 . setVisible ( False ) self . field2 . setVisible ( False ) self . field3 . setVisible ( False ) self . field4 . setVisible ( False ) self . field5 . setVisible ( False ) self . field6 . setVisible ( False ) self . field7 . setVisible ( False ) self . addp4 . setVisible ( False ) self . addp5 . setVisible ( False ) self . createButton . setVisible ( False ) self . addButton . setEnabled ( True )