Schematic lable Selection Problem using VBA

322
3
11-11-2011 03:22 AM
sreekarmasani
New Contributor
Hi,
I am using Arc GIS 9.3.1 with Schematics Extension.

I am using following code to get the selected elements in the current view.

    Dim pElements As INgElements
    Set pElements = pScProject.SelectedElements

I need to get the selected labels. If the element is there then I cound able to select the elements and then process the attached labels.

can you please suugest me how get the selected lables Only.

Thanks in advance,
sreekar masani.
Tags (2)
0 Kudos
3 Replies
RickAnderson
Occasional Contributor III
Not completely sure what you are trying to do.  If you have the selected elements, you can then just access the properties of each element and then check if the property is a textual property.  Once you know it is textual, you know you have a label and can do what you want with it.  Here is some sample code for rotating a label.  In this case the name of the textual property can be passed into the function, but if not, it gets all the properties for the element.  Once it gets the textual property, it rotates the label.

Private Sub SchematicRotateLabel(ByVal element As INgElement, ByVal blnUseGeographicRotation As Boolean, ByVal intRotation As Integer, ByVal strPropertyName As String)
        Dim propMain As INgProperty
        Dim prop1 As INgProperty
        Dim props As INgProperties

        Try
            If Len(strPropertyName) = 0 Then
                'just find all textual property
                props = element.ElementType.Properties
            Else
                'get a specific property
                prop1 = element.ElementType.GetProperty(strPropertyName)
                props = New NgProperties
                props.Add(prop1)
            End If

            For Each propMain In props
                If propMain.Type = esriNgPropertyType.esriNgTextualPropertyType Then
                    If blnUseGeographicRotation = True Then
                        element.SetLabelEffect(propMain, esriNgLabelEffect.esriNgLabelTextAngle, GetArithmeticRotationValue(intRotation))
                    Else
                        element.SetLabelEffect(propMain, esriNgLabelEffect.esriNgLabelTextAngle, intRotation)
                    End If
                End If
            Next
            element.Diagram.Redraw(esriNgRedrawMode.esriNgRedrawChange)
        Catch ex As Exception
            MsgBox("Unable to rotate text")
        End Try
    End Sub
0 Kudos
sreekarmasani
New Contributor
Thanks Rick,

I could able modify the label, when an element is selected.

The problem with me is, When select few lables, I do not see any elements get selected.

Actually Diagram type are created by our customer. I do not know what are the properties he have set to that diagram type. I just wnated move multiple labels at a time using VBA code. If elements also got selected, I am able do that. But when there is no related schematic element got selected (Label is in selection), I couls not able find the selelcted lable. Is there a way to fine the selected lables only without the element selection.

Thanks for your support.
0 Kudos
RickAnderson
Occasional Contributor III
The selection is one in the same.  Selecting a label also selects the element.  Selecting an element also selects the label(s).  So if you get all the selected elements, you will have access to all the labels that are selected as shown in the previous code.
0 Kudos