Fixed bugs with retrieving files in check_density.py and generate_fill.py, syntax fixes for check_antenna.py, added error checking for .rcfile to all scripts
diff --git a/sky130/custom/scripts/generate_fill.py b/sky130/custom/scripts/generate_fill.py
index 943920c..08209b3 100755
--- a/sky130/custom/scripts/generate_fill.py
+++ b/sky130/custom/scripts/generate_fill.py
@@ -93,10 +93,10 @@
 
     user_project_path = arguments[0]
 
-    magpath = os.path.split(user_project_path)[0]
+    magpath = os.getcwd()+'/'+os.path.split(user_project_path)[0]
     if magpath == '':
         magpath = os.getcwd()
-
+    
     if os.path.splitext(user_project_path)[1] != '.mag':
         if os.path.splitext(user_project_path)[1] == '':
             user_project_path += '.mag'
@@ -117,18 +117,29 @@
     if '-dist' in optionlist:
         distmode = True
 
-    rcfile = magpath + '/.magicrc'
-    if not os.path.isfile(rcfile):
-        rcfile = None
-
+    # Searching for rcfile
+    
+    rcfile_paths=[magpath+'/.magicrc','/$PDK_PATH/libs.tech/magic/sky130A.magicrc','/usr/share/pdk/sky130A/libs.tech/magic/sky130A.magicrc']
+    
+    rcfile=''
+    
+    for rc_path in rcfile_paths:
+        if os.path.isfile(rc_path):
+            rcfile=rc_path
+            break
+    
+    if rcfile=='':
+        print('Error: .magicrc file not found.')
+        sys.exit(1)
+    
     project = os.path.splitext(os.path.split(user_project_path)[1])[0]
 
     topdir = os.path.split(magpath)[0]
     gdsdir = topdir + '/gds'
     hasgdsdir = True if os.path.isdir(gdsdir) else False
-
+    
     ofile = open(magpath + '/generate_fill.tcl', 'w') 
-
+	
     print('#!/usr/bin/env wish', file=ofile)
     print('drc off', file=ofile)
     print('tech unlock *', file=ofile)
@@ -292,7 +303,7 @@
     print('puts stdout "Ended: $endtime"', file=ofile)
     print('quit -noprompt', file=ofile)
     ofile.close()
-
+    
     myenv = os.environ.copy()
     myenv['MAGTYPE'] = 'mag'
 
@@ -301,6 +312,7 @@
         # print('This script will generate file ' + project + '_fill_pattern.gds')
         print('This script will generate files ' + project + '_fill_pattern_x_y.gds')
         print('Now generating fill patterns.  This may take. . . quite. . . a while.', flush=True)
+        
         mproc = subprocess.run(['magic', '-dnull', '-noconsole',
 		'-rcfile', rcfile, magpath + '/generate_fill.tcl'],
 		stdin = subprocess.DEVNULL,
@@ -309,6 +321,7 @@
 		cwd = magpath,
 		env = myenv,
 		universal_newlines = True)
+        
         if mproc.stdout:
             for line in mproc.stdout.splitlines():
                 print(line)
@@ -318,7 +331,8 @@
                 print(line)
             if mproc.returncode != 0:
                 print('ERROR:  Magic exited with status ' + str(mproc.returncode))
-
+	
+	
         if distmode:
             # If using distributed mode, then run magic on each of the generated
             # layout files