parameters: (filename, docname)
docstring: Import a file into the specified document.
  
      Parameters
      ----------
      filename : str
          The path to the file to import.
  
      docname : str
          The name of an `App::Document` instance into which
          the objects and shapes from `filename` will be imported.
  
          If the document doesn't exist, it is created
          and set as the active document.
  
      To do
      -----
      Use local variables, not global variables.
docstring_summary: Import a file into the specified document.
docstring_tokens: Import a file into the specified document .
function: def insert(filename, docname):
      """Import a file into the specified document.
  
      Parameters
      ----------
      filename : str
          The path to the file to import.
  
      docname : str
          The name of an `App::Document` instance into which
          the objects and shapes from `filename` will be imported.
  
          If the document doesn't exist, it is created
          and set as the active document.
  
      To do
      -----
      Use local variables, not global variables.
      """
      readPreferences()
      try:
          doc = FreeCAD.getDocument(docname)
      except NameError:
          doc = FreeCAD.newDocument(docname)
      FreeCAD.setActiveDocument(docname)
      if dxfUseLegacyImporter:
          getDXFlibs()
          if dxfReader:
              groupname = os.path.splitext(os.path.basename(filename))[0]
              if six.PY2:
                  if isinstance(groupname, six.text_type):
                      # workaround since newDocument
                      # currently can't handle unicode filenames
                      groupname = groupname.encode(sys.getfilesystemencoding())
              importgroup = doc.addObject("App::DocumentObjectGroup", groupname)
              importgroup.Label = decodeName(groupname)
              processdxf(doc, filename)
              for l in layers:
                  importgroup.addObject(l)
          else:
              errorDXFLib(gui)
      else:
          import Import
          Import.readDXF(filename)
          Draft.convertDraftTexts() # convert annotations to Draft texts
          doc.recompute()
function_tokens: def insert ( filename , docname ) : readPreferences ( ) try : doc = FreeCAD . getDocument ( docname ) except NameError : doc = FreeCAD . newDocument ( docname ) FreeCAD . setActiveDocument ( docname ) if dxfUseLegacyImporter : getDXFlibs ( ) if dxfReader : groupname = os . path . splitext ( os . path . basename ( filename ) ) [ 0 ] if six . PY2 : if isinstance ( groupname , six . text_type ) : # workaround since newDocument # currently can't handle unicode filenames groupname = groupname . encode ( sys . getfilesystemencoding ( ) ) importgroup = doc . addObject ( "App::DocumentObjectGroup" , groupname ) importgroup . Label = decodeName ( groupname ) processdxf ( doc , filename ) for l in layers : importgroup . addObject ( l ) else : errorDXFLib ( gui ) else : import Import Import . readDXF ( filename ) Draft . convertDraftTexts ( ) # convert annotations to Draft texts doc . recompute ( )