POST
|
Oooh Arkadiusz! Thank you very very much for this great input. I made the modification and my script is running perfectly well. So for anyone who might be interested! this is what my script is built to do. Scans through the specified drive for all autoCAD files with .dwg extension, list them out; creates a geodatabase with the name '2010.gdb, then converts all the .dwg files into feature dataset with feature classes and store in the geodatabase created. The correct script is shown below import os, os.path, arcpy
from arcpy import env
env.workspace = "J:/2010"
# Set workspace and variables
gdb = r"C:\data\2010.gdb"
arcpy.env.workspace = gdb
# Create a FileGDB for the fds
arcpy.CreateFileGDB_management("C:/data", "2010.gdb")
reference_scale = "1500"
for root, dirs, files in os.walk("J:/2010/"):
for file in files:
if file.endswith('.dwg'):
print "current file is: " + file
outDS = arcpy.ValidateTableName(os.path.splitext("d" + os.path.basename(file))[0])
arcpy.CADToGeodatabase_conversion(root + '\\' + file, gdb, outDS, reference_scale) Hi, I think changing last line to: arcpy.CADToGeodatabase_conversion(root + '\\' + file, gdb, outDS, reference_scale) Should help, now you look all files in 'J:\\2010\\' (or J:/2010/ if you prefer) BR, Arek
... View more
09-21-2012
01:03 PM
|
2
|
0
|
454
|
POST
|
Please can someone help me out with is error? I have created a script to list all my CAD files in the directory and subdirectories and then convert them to Geodatabase with feature classes. When I run the script, it creates an empty geodatabase and list just the first file and gives the error" "ERROR 000732: Input CAD Datasets: Dataset 100135S01.dwg does not exist or is not supported, Failed to execute (CADToGeodatabase).. What could be the issue here?. Please help! Thanks Here is my script import os, os.path, arcpy from arcpy import env env.workspace = "J:/2010" # Set workspace and variables gdb = r"C:\data\2010.gdb" arcpy.env.workspace = gdb # Create a FileGDB for the fds arcpy.CreateFileGDB_management("C:/data", "2010.gdb") reference_scale = "1500" for root, dirs, files in os.walk("J:/2010/"): for file in files: if file.endswith('.dwg'): print "current file is: " + file outDS = arcpy.ValidateTableName(os.path.splitext("d" + os.path.basename(file))[0]) arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale)
... View more
09-18-2012
07:54 AM
|
0
|
2
|
1949
|
POST
|
If we are talking about resizing text on a CAD annotation layer, it can be done. But the changes to the font are not always obeyed. Sometimes the font will change, other times it will not. The image of the dialog below shows where the font controls are. Could this be related? http://support.esri.com/en/bugs/nimbus/TklNMDEwOTI0 This issue has been around in ArcMap as long as I can remember. [ATTACH=CONFIG]17209[/ATTACH] Hi, I just tried this too and i found it is possible to resize the CAD anotations on ArcMAp. But in this case what I did was to convert the card files to feature classes in a Geodatabase and then use editor function to view and resize the anotation to any size and color of my choice. How you do it is this way: open the layer in arcmap, activate the 'Editor' toolset and, click on the annotation feature class and select attributes tab on the editor window, you will see the the current font and choices you can make in terms of changing color, and font size. Ensure that your cursor is on the attribute you want to change .
... View more
09-07-2012
12:27 PM
|
0
|
0
|
1099
|
POST
|
some that function isn't being recognized - make sure that the spacing and everything is just right.. i have noticed that with PythonWin that you can be a space off at the >>> prompt .. either one closer to it or one farther away and it will act like it accepts that code, but then it doesn't compile like it is supposed to and then won't run. try re-entering that information (maybe do it in a text editor window then copy/past it into your interactive window) then right after that test it by typing parse_cadname(... once you put in the left parentheses it should prompt you for the arguments (dwg) - if it doesn't do that.. you'll have to try it again.. otherwise it should be good to go. You might be wise to try and put this all into a text window and run it from there just because its easier to manage than from the command prompt, and if something goes wrong, you don't have to retype everything again. This has now been achieved; I am able to create a geodatabase with the same name as the folder and convert the CAD files into Feature dataset loaded with feature dataclasses using the script below. It worked perfectly well. Thanks Thompson and Curtvprice for all your inputs.
# Import system modules
import arcpy
import glob
import os
# Set workspace and variables
gdb = r"C:\data\DGW2007.gdb"
arcpy.env.workspace = gdb
# Create a FileGDB for the fds
arcpy.CreateFileGDB_management("C:/data", "DGW2007.gdb")
reference_scale = "1500"
for file in glob.glob(r"N:\2007_dwg\*.dwg"):
outDS = arcpy.ValidateTableName(os.path.splitext("d" + os.path.basename(file))[0])
arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale) I still have one more task to complete in this topic and that is to write a script that will iterate through my CAD drive (which stores my CAD data according to the year the were acquired) and convert each CAD directory folder to a geodatabase and populate it with the related feature classes as obtained when implementing it as individual folders as seen above.
... View more
08-21-2012
08:59 AM
|
0
|
0
|
2486
|
POST
|
This line in your code is wrong: arcpy.CreateFileGDB_management("C:/data", "d{0}.gdb" Should be arcpy.CreateFileGDB_management("C:/data", "d{0}.gdb".format(year) and also should be inside the loop. Python 2.7 docs: string methods Hi Curtis, It appears the script is not recorgnising the years as just foldernames within a director. When I run the script it simply picks up the year just before the last, e.g if i specifiy range(1990,2009) it will just create a gdb folder for 2008 and thats all, even when i just put one year (1998) in the parameter for the format it will just create the an empty gdb in the name 1998 without datasets in it It does not create and populate the gdb with feature datasets and it does not iterate through the folders in the directory. Please can you check my script to know where im not getting it right. Thanks #Import system modules
import arcpy
import glob
import os
# Set workspace and variables
for year in range(1990,2009): # 1990-2009
inFolder = r"c:\data\cadfiles\{0}_dwg".format(year) # 1990_dwg
gdbName = "d{0}.gdb".format (1990,2009) # d1990.gdb
arcpy.env.workspace = gdbName
# Create a FileGDB for the fds
arcpy.CreateFileGDB_management("C:/data", "d{0}.gdb".format(year))
reference_scale = "1500"
for file in glob.glob(r"N:\{0}_dwg"):
outDS = arcpy.ValidateTableName(os.path.splitext("d" + os.path.basename(file))[0])
arcpy.CADToGeodatabase_conversion(file, gdbName, outDS, reference_scale)
... View more
08-21-2012
07:15 AM
|
0
|
0
|
325
|
POST
|
I'm not familiar with what you mean by "range" unless you mean the range of a single zone, say -72 to -78 longitude. The meridian is of course the center of the zone, say, -74. UTM is nicely described in its wikipedia article, as follows: So -- you know the zone's central meridian, you can calculate the zone like this:
zone = int((( merid + 180 ) % 360 ) / 6 ) + 1
For a value of merid = -75 this yields a zone value of 18. Here's python interactive code to test it:
>>> for merid in range(-177,183,6):
... print merid, merid-3,merid+3,int(((merid + 180) % 360) / 6) + 1
...
-177 -180 -174 1
-171 -174 -168 2
-165 -168 -162 3
Here's another explanation, that uses different (but I'm assuming equivalent) integer math. http://www.resurgentsoftware.com/GeoMag/utm_coordinates.htm Hi Curtprv, I ran the script above but it gave me a wrong answer for the supplied meridian. For instance in my code below, I tried to see what the equation will return as the zone for meridian 2 but it gave me Zone 31 instead of Zone 13. If calculated manually, the zone is determined by two parameters - the DLS range and the Meridian value which i found to be missing in your equation. Please can you take a look once more at the equation. merid = 2
zone = int((( merid+180) % 360) / 6) + 1
print zone
... View more
08-20-2012
06:15 AM
|
0
|
0
|
761
|
POST
|
Hi Curtiv, I have been working on this script since yesterday and uptil this morning I have not been able to get it to populate the geodatabase with datasets. I also observed that it is not picking information from the format() as supposed. I am actually having some difficulties on how best to set the format parameters because the parameters are supposed to be folders (subdirectories) within a directory and and each of them has a suffix at the end. Each time i insert the foldernme as it is within the format() parameter, the script does not recorgnise it and so it gives me a syntax error. Please see how my folders are arranged. I have gone through a lot python format() function but couldnt find any that is similar to mine. [ATTACH=CONFIG]17033[/ATTACH] Here is my script and the errors Im getting # Import system modules
import arcpy
import glob
import os
# Set workspace and variables
gdbName = "d{0}.gdb".format(1990)
for year in range(1990,2005): # 1990-2004
inFolder = r"{0}.gdb".format(1990)# 1991_dwg
arcpy.env.workspace = gdbName
# Create a FileGDB for the fds
arcpy.CreateFileGDB_management("C:/data", "d{0}.gdb")
reference_scale = "1500"
for year in range(1990,2005): # 1990-2004
inFolder = r"N:\{0}_dwg".format(1990) # 1990_dwg
gdbName = "d{0}.gdb".format(year) # d1990.gdb
for file in glob.glob(r"N:\{0}_dwg"):
outDS = arcpy.ValidateTableName("d" + os.path.splitext(os.path.basename(file))[0]) This one just creates the geodatabase name d{0}.gdb (it does not substitute the 0 with the names specified in the format(), i dont understand why) Check the value of outDS you're getting with a print statement -- but also make sure your output GDB is entirely empty. arcpy.env.overwriteOutput = True is a good idea too! Perhaps this syntax will work better for you: outDS = arcpy.ValidateTableName("d" + os.path.splitext(os.path.basename(file))[0]) Yes - Look up the syntax on .format() in the python help. You need to substitute that year into the gdb name using .format: gdbName = "d{0}.gdb".format(year)
arcpy.CreateFileGDB_management("C:/data",gdbName)
... View more
08-17-2012
05:44 AM
|
0
|
0
|
325
|
POST
|
I tried inserting the line for using a "d" to prefix the output feature dataset name in my script, the script did run, created some datasets and errored out at one of the dwg files, i am not able to figure out why it is not able to create the annotation for that file and why it is erroring out at that point. Here is my script for it # Import system modules
import arcpy
import glob
import os
# Set workspace and variables
gdb = r"C:\data\DGW2005.gdb"
arcpy.env.workspace = gdb
# Create a FileGDB for the fds
arcpy.CreateFileGDB_management("C:/data", "DGW2005.gdb")
reference_scale = "1500"
for file in glob.glob(r"N:\2005_dwg\*.dwg"):
outDS = arcpy.ValidateTableName(os.path.splitext("d" + os.path.basename(file))[0])
arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale) and here is the error displayed Traceback (most recent call last): File "C:\data\Scripts\cadconversRight", line 13, in <module> arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\conversion.py", line 1084, in CADToGeodatabase raise e ExecuteError: ERROR 000278: 1 error(s) have been detected for layer 050101C01. Errors are described in file GLC:\Users\IEGBUL~1\AppData\Local\Temp\GL050101C011.log.log in your temp directory. ERROR 000016: 1 annotation(s) rejected Failed to execute (CADToGeodatabase). and here is the extent it was able to execute [ATTACH=CONFIG]16990[/ATTACH] I also tried the looping script but it came up with an error, It appears the loop is not functioning well, i guess i am missing something because it is not even creating the GDBs. Here is my script # Import system modules
import arcpy
import glob
import os
# Set workspace and variables
gdbName = "d{0}.gdb".format(year) # d1990.gdb
for year in range(1990,2005): # 1990-2004
inFolder = r"N:\{0}_dwg".format(year) # 1990_dwg
arcpy.env.workspace = gdbName
# Create a FileGDB for the fds
arcpy.CreateFileGDB_management("C:/data", "d{0}.gdb")
reference_scale = "1500"
for year in range(1990,2005): # 1990-2004
inFolder = r"N:\{0}_dwg".format(year) # 1990_dwg
gdbName = "d{0}.gdb".format(year) # d1990.gdb
for file in glob.glob(r"N:\{0}_dwg"):
outDS = arcpy.ValidateTableName(os.path.splitext("d" + os.path.basename(file))[0])
arcpy.CADToGeodatabase_conversion(file, gdbName, outDS, reference_scale) and here is the error i got Traceback (most recent call last): File "C:/Users/iegbulefu/Documents/myscripts/cadconvers5", line 6, in <module> gdbName = "d{0}.gdb".format(year) # d1990.gdb NameError: name 'year' is not defined curtvprice;224453 wrote: The validation is stripping that leading number because gdb object names should not start with a number. Here's a tweak that will preserve those full names be prefixing a "d" to the output feature dataset name: outDS = arcpy.ValidateTableName(os.path.splitext("d" + os.path.basename(file))[0]) Creating a geodatabase for each folder should be pretty straightforward. Wrap a for loop around what you have:
for year in range(1990,2005): # 1990-2004
inFolder = r"c:\data\cadfiles\{0}_dwg".format(year) # 1990_dwg
gdbName = "d{0}.gdb".format(year) # d1990.gdb
arcpy.env.workspace = gdb
...
... View more
08-15-2012
02:23 PM
|
0
|
0
|
1383
|
POST
|
Your terminology is a little confusing - both those terms seem like they relate to Public Land Survey System (Township-Range-section) for describing legal locations, but refer to different attributes of that nomenclature. It would help if you could clarify these terms - for instance, a PLSS township/range/section is described according to a specific Baseline and Meridian - do you mean Baseline here instead of Range or do you really mean the Range (denoted usually as a value E or W of a the Meridian.. ). Also, Meridian in this context is not the same as the Central Meridian as a UTM zone, so a clearer example of these terms is important. PLSS Meridian and baselines are descriptive rather than expressed as degrees of longitude - for instance the PLSS for Arizona references the 'Gila and Salt River Base Line and Meridian'. Perhaps an example of the data you have would be useful as well. Hi Thompson, Sorry if youre somewhat confused about my data, but i dont think your understanding of it is far from being correct. The data describes a legal location and it is similar to the public land survey system that is used in the United States, but in Canada we use what is known as Dominion Land Survey system (Western Canada). So the DLS identifies location by their Township-Range-Secion and Meridian. Thus my data are basically survey data and the description is given in DLS format. Currently our job areas fall within the West Meridian 1 written as (W1M) and West meridian 7(W7M). This is not the same thing as Central Meridian. The central Meridian is the longest line of longitude that runs from North to South forming the axis of symmetry
... View more
08-15-2012
08:18 AM
|
0
|
0
|
761
|
POST
|
Hi Curtvprice, I tried the script but it is giving me a parsing error. I do not quite understand the parameters you are using here, I mean which of the numbers are range and meridian. Here are some sample data i have (All Range values are 1,2,3,4,5,.........30) Meridian = W2M ; Range = 1 to 30 Meridian = W3M ; Range = 1 to 30 Meridian = W4M ; Range = 1 to 30 Meridian = W5M ; Range = 1 to 30 I would like to use a python script to deduce the UTM zones for these meridian and range values. Thanks for your help I'm not familiar with what you mean by "range" unless you mean the range of a single zone, say -72 to -78 longitude. The meridian is of course the center of the zone, say, -74. UTM is nicely described in its wikipedia article, as follows: So -- you know the zone's central meridian, you can calculate the zone like this:
zone = int((( merid + 180 ) % 360 ) / 6 ) + 1
For a value of merid = -75 this yields a zone value of 18. Here's python interactive code to test it:
>>> for merid in range(-177,183,6):
... print merid, merid-3,merid+3,int(((merid + 180) % 360) / 6) + 1
...
-177 -180 -174 1
-171 -174 -168 2
-165 -168 -162 3
Here's another explanation, that uses different (but I'm assuming equivalent) integer math. http://www.resurgentsoftware.com/GeoMag/utm_coordinates.htm
... View more
08-15-2012
07:29 AM
|
0
|
0
|
761
|
POST
|
I posted the question there and i am yet to get the right anwser. Thanks for your observation I'm not familiar with type of data Irene is looking at but just noticed that the same question is posted (with no accepted answer) at Stack Exchange GIS so that is somewhere else to look for ideas on how to do this. - Graeme
... View more
08-15-2012
06:41 AM
|
0
|
0
|
761
|
POST
|
Hi Curt! I think youre right. I deleted all that i had previously in the geodatabase and ran the script again and it worked perfectly well. I also tried to insert a line to create the geodatabase within the script and it also worked very well; but my problem now is that I need to customize the feature datasets such that all the feature datasets will have the same fullname as the CADfiles becos we have a naming convention for all our files for ease of recorgnition. Secondly, I have over 30 different folders created according to the years the data were acquired, so Im wondering if it is possible to use just one script that can create 30 different geodatabases (probably by iteration) and for each database, the feature datasets will be arranged according to the data sets in the specific CAD folder for that year. Here is what my script looks like # Import system modules
import arcpy
import glob
import os
# Set workspace and variables
gdb = r"C:\data\DGW2007.gdb"
arcpy.env.workspace = gdb
# Create a FileGDB for the fds
arcpy.CreateFileGDB_management("C:/data", "DGW2007.gdb")
reference_scale = "1500"
for file in glob.glob(r"C:\CADdata\*.dwg"):
outDS = arcpy.ValidateTableName(os.path.splitext(os.path.basename(file))[0])
arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale) and here is the output on ArcCatalog [ATTACH=CONFIG]16901[/ATTACH] and here is what my inputACDfiles look like [ATTACH=CONFIG]16904[/ATTACH] and here is what my CADfolders look like (I have data acquired from 1990 to 2012) [ATTACH=CONFIG]16905[/ATTACH] It's hard to tell without more details, but my guess is that the feature class names are not unique. All object names within a gdb (tables, feature classes, feature datasets [even those inside of a feature dataset], relationship classes, everything) must be globally unique within the gdb workspace. If your .dwg files have feature classes that are named the same, for example: 94b12v01.dwg\Anno and 94b13c01.dwg\Anno) the only solution is to convert each .dwg to unique gdbs or use Feature Class to Feature Class to copy feature classes one at a time with unique names. (This may require an inner loop and more logic, perhaps the use of the arcpy ListFeatureClasses method.) Also, make sure any feature datasets are deleted from the output gdb after failed attempts. As for setting up the names with a character prefix, you could prefix an "f" to each feature datasetname like this: outDS = "f" + outDS
... View more
08-13-2012
12:11 PM
|
0
|
0
|
1383
|
POST
|
Hi curtvprice I tried runing this script, it is able to run but with an error stating that it is unable to create the anotation feature class. In answer to your comments. All my input CAD data are uniquely identified and since i desire to have the feature dataset assume the same name as the CAD data files, I believe that "Feature class names must be unique for the entire geodatabase or the tool will fail" This issue would be averted. for the second issue of having a prefix my feature dataset names with a letter - object names that start with a number can cause ArcGIS operations (especially queries) to fail; is it possible to do this within the script and have it automatically implemented as the feature dataset is being created from the CAD files, My reason is that I have over 60 CAD files that i need to convert to feature dataset. Here is my code and the error i got when i ran it. Thanks for helping! import arcpy
import glob
import os
gdb = r"C:\data\cadfile.gdb"
arcpy.env.workspace = gdb
reference_scale = "1500"
for file in glob.glob(r"C:\CADdata\*.dwg"):
outDS = arcpy.ValidateTableName(os.path.splitext(os.path.basename(file))[0])
arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale) Traceback (most recent call last): File "C:/data/Scripts/cadconvers", line 9, in <module> arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\conversion.py", line 1084, in CADToGeodatabase raise e ExecuteError: ERROR 999999: Error executing function. ERROR 000021: Failed to create the output annotation feature class Failed to execute (CADToGeodatabase). Here's an approach that is more robust: import arcpy
import glob
import os
gdb = r"C:\data\cadfile2.gdb"
arcpy.env.workspace = gdb
reference_scale = "1500"
for file in glob.glob(r"C:\CADdata\*.dwg"):
# the following line pulls out the "base name" (file.dwg), strips the .dwg extension,
# and then ensures the name is a valid dataset name for the current workspace
outDS = arcpy.ValidateTableName(os.path.splitext(os.path.basename(file))[0])
arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale) Also - look out for this gotcha in the tool reference: Feature class names must be unique for the entire geodatabase or the tool will fail. One more thing, you may want to prefix your feature dataset names with a letter - object names that start with a number can cause ArcGIS operations (especially queries) to fail.
... View more
08-13-2012
10:10 AM
|
0
|
0
|
1383
|
POST
|
Thanks for the script. I tried the script, It was able to create the gdb and supposedly dataset but i am not able to see them on ArcCatalog. Here is what my script looks like import arcpy, glob
gdb = r"C:\data\cadfile2.gdb"
reference_scale = "1500"
for file in glob.glob(r"C:\CADdata\*.dwg"):
arcpy.CADToGeodatabase_conversion(file, gdb, file.split("\\")[-1][0:-4], reference_scale) Here is the result <Result 'C:\\data\\cadfile2.gdb\\91-400'> <Result 'C:\\data\\cadfile2.gdb\\91036c01'> <Result 'C:\\data\\cadfile2.gdb\\94a02c01'> <Result 'C:\\data\\cadfile2.gdb\\94a03w01'> <Result 'C:\\data\\cadfile2.gdb\\94a05w01'> <Result 'C:\\data\\cadfile2.gdb\\94a14w01'> <Result 'C:\\data\\cadfile2.gdb\\94a15w01'> <Result 'C:\\data\\cadfile2.gdb\\94a25w01'> <Result 'C:\\data\\cadfile2.gdb\\94a26w01'> <Result 'C:\\data\\cadfile2.gdb\\94a26w02'> <Result 'C:\\data\\cadfile2.gdb\\94a54w01'> <Result 'C:\\data\\cadfile2.gdb\\94a70w01'> <Result 'C:\\data\\cadfile2.gdb\\94a81w01'> <Result 'C:\\data\\cadfile2.gdb\\94a82c01'> <Result 'C:\\data\\cadfile2.gdb\\94a88C01'> <Result 'C:\\data\\cadfile2.gdb\\94a88W01'> <Result 'C:\\data\\cadfile2.gdb\\94b12v01'> <Result 'C:\\data\\cadfile2.gdb\\94b13c01'> I want to believe that the 94*** are the feature datasets that should be seen within the geodatabase named "cadfiles2" Hi Irene, You can accomplish this using the 'glob' module. Ex: import arcpy, glob
GDB = r"C:\temp\Python\CAD\CAD_DATA.gdb"
reference_scale = "500"
# Find all DWG files
for file in glob.glob(r"C:\temp\python\CAD\*.dwg"):
# Convert all DWG files to GDB feature classes
arcpy.CADToGeodatabase_conversion(file, GDB, file.split("\\")[-1][0:-4], reference_scale) The 'file.split("\\")[-1][0:-4]' will split the path of the CAD file for each backslash (\), use the last value found by specifying [-1] (which would be the CAD file name), and then strip the '.DWG' from the file name by specifying [0:-4].
... View more
08-13-2012
09:06 AM
|
0
|
0
|
1383
|
POST
|
Hi Everyone, I am looking for a phython or php script that will accept the Range and Meridian values of a location and use it to identify the UTM zone. I have a table that comprises of Easting, Northing, Range and Meridian but im missing the UTM zones of these points. I am able to manually identify the UTM zone knowing the range and Meridian of the location. I wish to automate this by using a python script that will scan in these parameters as variables and extract the UTM zones based on the parameters. Can someone please help me out! It will really be exciting to achieve this as i need it move ahead with my job, its so clumsy having to go through thousands of point data to this manually. Thanks for your most valued input!
... View more
08-09-2012
09:39 AM
|
0
|
9
|
1062
|
Title | Kudos | Posted |
---|---|---|
2 | 09-21-2012 01:03 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|