1

My code:

    import arcpy, csv
    from arcpy import env

    dgnfile = str(arcpy.GetParameterAsText(0))
    outFeatureClass = str(arcpy.GetParameterAsText(1))  #the fc in my fgdb template to be  populated by data read from the dgn
    i = 0
    while outFeatureClass[i:i+4] <> ".gdb": i+=1
      inFeatureClass = outFeatureClass[:i+4]
      CADdataset = "GD_Temp"
      refscale = "1000"
      arcpy.CADToGeodatabase_conversion(dgnfile,inFeatureClass,CADdataset,refscale)

This is my code which crashes out. I am able to read geometry out of a CAD dataset which has been created in ArcCatalog manually, and populate an existing FC in my FGDB. But the dgn-to-CADdataset part crashed. When I placed my first question I ASSUMED the CADToGeodatabase routine would work. Is it a simple Python code error? ESRI are their usual helpful self. By the way, I've omitted the code which subsequently reads the output from CADToGeodatabase().


Following is what I am feeding into CADToGeodatabase routine, as quoted from PythonWin debug session (...=intevening folders):

argument 1: 'C:\GeneralWorkData\...\9202.dgn'
argument 2: 'C:\GeneralWorkData\...\GD_9202_ED5031N_FGDB_Pop.gdb'
argument 3: 'GD_Temp'
argument 4: '1000'

It is supposed to create a new feature dataset in the .gdb, which is what I am trying to achieve here.

The Sample Code you mentioned is the method I am using for my work, but it crashes ArcMap/ArcCatalog/PythonWin Debug, with no (helpful) error message. These are the right argument formats according to Resource Centre Help for ArcGIS 10.0!

Don't want to look at "Interoperability"(?) right now, as I have code which works to read out of the CADToGeodatabase results so it would mean starting all over again. In other words, I can import dgn data by hand in Catalog then read that data in Python and put it where I like, so the second half of the Python project is done, now I need the first. I posted originally prematurely, didn't know this would crash, apologies again. Is there any chance someone could try this routine with real dgn data, cos I am thinking we are looking at an ESRI bug...?

0

1 Answer 1

1

Check the syntax you are supplying to CADtoGeodatabase because it expects:

CADtoGeodatabase_conversion (input_cad_datasets, out_gdb_path, out_dataset_name, reference_scale, {spatial_reference})

You seem to be giving it a Feature Class name where it expects a path to a Geodatabase.

There is a Code Sample you could follow in the CAD to Geodatabase (Conversion) documentation.

However, it may be that this tool which creates a Feature Dataset is not what you need because I think you are trying to populate an existing (and empty) Feature Class.

Perhaps try re-phrasing your question along the lines of "How to populate existing (and empty) Feature Class from Microstation *.dgn?". I don't know the answer to that (but would try Data Interoperabilty, if I had it) - but someone else might.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.