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...?