PROBLEM

ArcView displays an ArcCAD coverage at the incorrect location

Last Published: April 25, 2020

Description

ArcView displays ArcCAD coverages at the incorrect location.

Cause

An XY shift has been applied to the ArcCAD coverage. ArcView does not recognize the XY shift, causing the data to be displayed incorrectly.

Solution or Workaround

Use the script below to search the ArcCAD coverage directory to determine the proper XY shift and apply that shift to the coverage.

  1. Start ArcView.
  2. Load the ArcCAD coverage into a new view.
  3. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  4. Copy the script below into the new script window.

    Code:
    ' Name: View.ApplyShift
    ' Title: apply the shift from a shifted ArcCAD coverage.
    ' Topics: GeoData
    ' Description: Shifts features in the current active Theme in the
    ' X and Y distance retrived from the coverage. A new theme is created
    ' as a result of the shift. Only the selected features will be moved.
    ' If there are no selected features then all features in the theme will
    ' be moved. The units of the xy shift are the same units as the unprojected
    ' source geometry.
    '
    ' Requires: A View with one active Theme.

    theView = av.GetActiveDoc
    srcnames = SourceDialog.Show("")
    for each n in srcnames
    theTheme = Theme.Make(n)
    theView.AddTheme(theTheme)
    theTheme.setactive(TRUE)
    theTheme = theView.GetActiveThemes.Get(0)
    theCover = theTheme.GetSrcName.GetFileName.GetFullName
    thestring = theCover.asstring+"\xyshift.dbf"
    f = File.Exists(thestring.asfilename)
    if (f = true) then
    shiftyes = msgbox.YesNo("This ArcCAD coverage "+theTheme.asstring.quote+" has an xyshift."+nl+"Do you what this applied to the view?","",true)
    if (shiftyes = TRUE) then
    v = Vtab.make(theString.asfilename,FALSE,FALSE)
    xField = v.findField("xshift")
    if (xField.asstring = "Nil") then
    msgbox.info("There is no Xshift value."+nl+"Please check the xyshift.dbf file in the coverage."+nl+"Be sure that this is an apropriate file.","error")
    exit
    end
    xshift = v.ReturnValue(xField,0)
    xtype = xshift.getclass.getclassname
    if (not(xtype = "number")) then
    msgbox.info("There is no Yshift value."+nl+"Please check the xyshift.dbf file in the coverage."+nl+"Be sure that this is an apropriate file.","error")
    exit
    end
    yField = v.findField("yshift")
    if (yfield.asstring = "NIL") then
    msgbox.info("There is no Yshift value."+nl+"Please check the xyshift.dbf file in the coverage."+nl+"Be sure that this is an apropriate file.","error")
    exit
    end
    yshift = v.ReturnValue(yField,0)
    ytype = yshift.getclass.getclassname
    if (not(ytype = "number")) then
    msgbox.info("There is no Yshift value."+nl+"Please check the xyshift.dbf file in the coverage."+nl+"Be sure that this is an apropriate file.","error")
    exit
    end
    defaultName = FN.Make("$HOME").MakeTmp("theme","shp")
    shpFileName = FileDialog.Put( defaultName,"*.shp","Output Shape File" )
    if (shpFileName = Nil) then
    exit
    end
    shpFileName.SetExtension("shp")
    if (xShift = Nil) then
    msgbox.info("There is no Xshift value."+nl+"Please check the xyshift.dbf file in the coverage."+nl+"Be sure that there this is an apropriate file.","error")
    exit
    end
    if (yShift = Nil) then
    msgbox.info("There is no Yshift value."+nl+"Please check the xyshift.dbf file in the coverage."+nl+"Be sure that there this is an apropriate file.","error")
    exit
    end
    shapeType = theTheme.GetFtab.FindField("Shape").GetType
    if (shapeType = #FIELD_SHAPELINE) then
    outFTab = FTab.MakeNew( shpFileName, Polyline )
    elseif (shapeType = #FIELD_SHAPEMULTIPOINT) then
    outFTab = FTab.MakeNew( shpFileName, Multipoint )
    elseif (shapeType = #FIELD_SHAPEPOINT) then
    outFTab = FTab.MakeNew( shpFileName, Point )
    elseif (shapeType = #FIELD_SHAPEPOLY) then
    outFTab = FTab.MakeNew( shpFileName, Polygon )
    end
    inShapeField = theTheme.GetFtab.FindField("Shape")
    outShapeField = outFTab.FindField("Shape")
    inFTab = theTheme.GetFTab
    inFieldList = inFTab.GetFields
    outFieldList = inFieldList.DeepClone
    outFieldList.Remove(0) ' omit the shape field...
    outFTab.AddFields( outFieldList )
    if (inFTab.GetSelection.Count = 0) then
    theRecordsToShift = inFTab
    numRecs = inFTab.GetNumRecords
    else
    theRecordsToShift = inFTab.GetSelection
    numRecs = theRecordsToShift.Count
    end
    for each rec in theRecordsToShift
    theShape = theTheme.GetFtab.ReturnValue( inShapeField, rec )
    newShape = theShape.Move(xShift, yShift)
    newRec = outFtab.AddRecord
    outFTab.SetValue( outShapeField, newRec, newShape )
    fieldPtr = 0
    for each fOut in outFieldList
    fieldPtr = fieldPtr + 1
    fIn = inFieldList.Get( fieldPtr )
    outFTab.SetValue( fOut, newRec, inFTab.ReturnValue( fIn, rec ) )
    end
    end

    outFtab.Flush
    if (MsgBox.YesNo("Add shapefile as theme to a view?","XY Shift", true).Not) then
    exit
    end
    viewList = {}
    for each d in av.GetProject.GetDocs
    if (d.Is(View)) then
    viewList.Add( d )
    end
    end

    viewList.Add("<New View>")
    addToView = MsgBox.ListAsString( viewList,"Add Theme to:", "XY Shift" )
    if (addToView <> nil) then
    if (addToView = "<New View>") then
    addToView = View.Make
    addToView.GetWin.Open
    end
    shiftedTheme = FTheme.Make( outFTab )
    addToView.AddTheme( shiftedTheme )
    addToView.GetWin.Activate
    end
    end
    end
    end

  5. Attach the script to a new button on the View GUI.

    A. Compile the script.
    B. Switch to the Project window.
    C. Select Customize from the Project menu.
    D. On the Customize dialog box, click the Type dropdown arrow and click View.
    E. Select Buttons under Category.
    F. Click the New button.
    G. Double-click the Click property in the Customize dialog box.
    H. Type the name of the script in the Script Manager and click Select.
    I. Close the Customize dialog box.

    For more information, see "Customize dialog box" in ArcView Help.

  6. Click the new button.

Article ID:000005141

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic