cgraham

Label with LXP file

Discussion created by cgraham on Apr 30, 2010
Latest reply on May 4, 2010 by cgraham
Good Afternoon,
I have a sub to symbolize a working layer from a saved layer file.  (see below)  I was hoping to be able to do some labeling in the same way.  Or in a worst case scenerio grab the needed values from the feature, build a string and pass it to some sort of label object that way. 

Any leads greatly appreciated.

Take care,
Craig

Here's the symbology sub:
Public Sub subSymbolizeByLayerFile(sLayer As String, sLayerFilePath As String)
    Dim pDoc As IMxDocument, pMap As IMap, pFLayer As IFeatureLayer, pGxLayer As IGxLayer, pGxFile As IGxFile
    Dim pSymLayer As ILayer, pLyr As IGeoFeatureLayer, pGeoSymLyr As IGeoFeatureLayer, pLayer As ILayer
    Dim pLayer1 As ILayer, pLayers As IEnumLayer
    Dim i As Integer
    Dim pFSO As FileSystemObject
    Set pDoc = g_App.Document
    Set pMap = pDoc.FocusMap
    Set pLayers = pMap.Layers
    Set pLayer1 = pLayers.Next
    Do While Not pLayer1 Is Nothing
        If pLayer1.Name = sLayer Then
            Set pLayer = pLayer1
            Exit Do
        End If
        Set pLayer1 = pLayers.Next
    Loop
    If pLayer Is Nothing Then Exit Sub
    Set pFSO = New FileSystemObject
    If pFSO.FileExists(sLayerFilePath) = False Then Exit Sub
    Set pFLayer = pLayer
    Set pGxLayer = New GxLayer
    Set pGxFile = pGxLayer
    pGxFile.Path = sLayerFilePath
    Set pSymLayer = pGxLayer.Layer
    Set pLyr = pFLayer
    Set pGeoSymLyr = pSymLayer
    Set pLyr.Renderer = pGeoSymLyr.Renderer
    pDoc.ActiveView.Refresh
    pDoc.UpdateContents
End Sub


Here is the contents of the label expression file:
Function FindLabel ( [POLYID], [POLYTYPE], [FORMOD], [DEVSTAGE], [OSPCOMP], [USPCOMP], [VERT], [PRI_ECO], [SEC_ECO] )
  Dim Str
  Str = [POLYID] & " - " & [POLYTYPE]  
  If [POLYTYPE] = "FOR" Then
    Str = Str & vbNewLine & "FORMOD = " & [FORMOD]  & vbNewLine & "DEVSTAGE = " & [DEVSTAGE]  & vbNewLine & "OSC = " & [OSPCOMP] 
  End If
  FindLabel = Str

Outcomes