Add Representation

1892
1
09-13-2011 06:58 AM
SteffenKeller
New Contributor
Hi Users,

I need help with adding a representation programmatically (ArcGIS 9.3, VB.NET 2005):
First I set a UniqueValueRenderer to set the Symbology.
Then I add programmatically the representation in ArcMap using the Geoprocessing Tool "AddRepresentation_cartography", the resulting Layer in the TOC shows the correct symbology as representation.
Now I use the tool "DropRepresentation" (from the Toolbox, not programmatically) and select the Layer with the Representation: The tool shows me error 000226: "Layer does not contain representations".
If I remove the Layer from TOC (not programmatically) then the Layer is still showing in the DropRepresentation-Tool. If I add the Layer again, then DropRepresentation-Tool shows 2 Layers with the same name.
Why is the Layer not properly deleted ?

Here is the code:

Dim pFLayer As IFeatureLayer
pFLayer = pApplication.Document.SelectedLayer     'pApplication is already set
Dim GP As IGeoProcessor
GP = New GeoProcessor
GP.OverwriteOutput = True
GP.AddOutputsToMap = False
GP.SetEnvironmentValue("ReferenceScale", 25000)
Dim parameters As IVariantArray
parameters = New VarArray
parameters.Add(pFLayer)
parameters.Add("TestRep")
parameters.Add("RuleID")
parameters.Add("Override")
parameters.Add("STORE_CHANGE_AS_OVERRIDE")
parameters.Add("")
parameters.Add("ASSIGN")

GP.Execute("AddRepresentation_cartography", parameters, Nothing)

Release(GP)

'------------------------------------------
Public Sub Release(ByVal comObj As Object)
        If Not IsNothing(comObj) Then
            Dim refsLeft As Integer = 0
            Do
                refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(comObj)
            Loop While (refsLeft > 0)
        End If
End Sub
0 Kudos
1 Reply
SteffenKeller
New Contributor
Hello again,

it seems to be a bug in Pre10-Versions. Since ArcGIS 10.0 the problem doesn't exists.
0 Kudos