
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to get the Measure command from the MeasureEvent to run, but it is not working or I'm doing something that the api is not meant to do.
I have a Form with a button, when the form opens (loads) it start a interaction. Then i press the button to start the Measure command, but nothing happens the status bar says "Select a feature or dimension" so i know the command is running but I cannot select anything.
Here is a code snip:
Public Class Form1 Private m_ThisApplication As Application Private m_InteractionEvents As InteractionEvents Private m_MeasureEvets As MeasureEvents Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load m_InteractionEvents = m_ThisApplication.CommandManager.CreateInteractionEvents m_MeasureEvets = m_InteractionEvents.MeasureEvents m_InteractionEvents.Start() AddHandler m_MeasureEvets.OnMeasure, AddressOf m_MeasureEvets_OnMeasure End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click m_MeasureEvets.Enabled = True m_MeasureEvets.Measure(MeasureTypeEnum.kDistanceMeasure) End Sub Private Sub m_MeasureEvets_OnMeasure(MeasureType As MeasureTypeEnum, MeasuredValue As Double, Context As NameValueMap) ' Do something with MeasuredValue m_MeasureEvets.Enabled = False End Sub End Class
Now if I move the "m_MeasureEvents.Enabled = True" like this:
Public Class Form1 Private m_ThisApplication As Application Private m_InteractionEvents As InteractionEvents Private m_MeasureEvets As MeasureEvents Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load m_InteractionEvents = m_ThisApplication.CommandManager.CreateInteractionEvents m_MeasureEvets = m_InteractionEvents.MeasureEvent
m_MeasureEvents.Enabled = True
m_InteractionEvents.Start()
AddHandler m_MeasureEvets.OnMeasure, AddressOf m_MeasureEvets_OnMeasure End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
m_MeasureEvents.Enabled = True
m_MeasureEvets.Measure(MeasureTypeEnum.kDistanceMeasure) End Sub Private Sub m_MeasureEvets_OnMeasure(MeasureType As MeasureTypeEnum, MeasuredValue As Double, Context As NameValueMap) ' Do something with MeasuredValue m_MeasureEvets.Enabled = False End Sub End Class
The Measure command works now, if I set MeasureEvents.Enabled = True before I start the Interaction, but when i try to run the Measure command again I only get the status bar text and cannot select anything.
I have seen some posts about MeasureEvent and SelectEvent not working together that are posts from 2010.
So is the problem that you cannot start the Measure command in a active interaction or am i doing something wrong?
I have tried the solution from this post and that works, but i want to have a active interaction so I can capture other events, for example Select Events
Solved! Go to Solution.