Select to view content in your preferred language

IRepresentation - Changing Geometry

569
1
12-09-2010 06:10 AM
RiverTaig1
Deactivated User
I'm trying to figure out how to move the "representation" for a point feature (not the feature itself), but can't find a good sample.  The feature class that I have has representation applied to it (which I set up in ArcCatalog). Using ArcMap's Representation Toolbar, I can move the representation for the feature just fine. Now what I want to do is modify the representation geometry in code.

I found IRepresentation.RemoveShapeOverride, and this method DOES work to reset the representation...But how do you provide a new geometry or modify the existing geometry?  Presumably, IRepresentationGraphics.ChangeGeometry would do the trick, but I can't figure out how to use it (what is the ID parameter?).  But perhaps IRepresentationGraphic is not the right approach at all because I don't want to use so-called Free-Representation...I just want to modify it's shape.
0 Kudos
1 Reply
RiverTaig1
Deactivated User
I figured this out: Here's the VBA code to grab a point feature (it happens to have an ObjectID of  34599) and set it's representation geometry.

Private Sub MoveRepresentation()
    Dim pMxDoc As IMxDocument
    Dim pMap As IMap
    Dim pFeatLayer As IFeatureLayer
    Dim pGeoFeatLayer As IGeoFeatureLayer
    Dim pRepRenderer As IRepresentationRenderer
    Dim pRepClass As IRepresentationClass
    Dim pFC As IFeatureClass
    Dim pRepRule As IRepresentationRule
    Dim pGeom As IGeometry
    Dim pPtCol As IPointCollection
    Dim pPt As IPoint
    Dim pFeat As IFeature
    Dim pDisp As IDisplayTransformation
    Dim i As Integer, lID As Long, lIndex As Long
    Dim pRep As IRepresentation
    Dim pMC As IMapContext
    
    Set pMxDoc = ThisDocument
    Set pMap = pMxDoc.FocusMap
    Set pFeatLayer = pMap.Layer(0)
    Set pFC = pFeatLayer.FeatureClass
    Set pGeoFeatLayer = pFeatLayer
    If TypeOf pGeoFeatLayer Is RepresentationRenderer Then
        Set pRepRenderer = pGeoFeatLayer.Renderer
        Set pRepClass = pRepRenderer.RepresentationClass
    End If
    Set pPt = New Point
    pPt.PutCoords 2216006.2, 393858.2 'Use map units
    Set pFeat = pFC.GetFeature(34599) 'Get a specific feature
    Set pMC = New MapContext
    Set pDisp = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation
    pMC.InitFromDisplay pDisp
    Set pRep = pRepClass.GetRepresentation(pFeat, pMC)
    Set pRep.Shape = pPt
    pRep.UpdateFeature
    pFeat.Store
    '** Refresh the TOC '** Draw the map
    pMxDoc.ActiveView.Refresh
    
End Sub
0 Kudos