<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Inventor commandmanager.Pick method problem in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-commandmanager-pick-method-problem/m-p/4301153#M130188</link>
    <description>&lt;P&gt;I have some problem using the inventor commandmanager.pick method. Below is the code. (Attached my VBA userform). When the userform run, I will pick the QTY from the userform, then I have used pick method to pick the dimension). the 'Pick" method does not work well. Sometimes I could able to pick the dimension, but many times no. Also attached the class function also, if anything wrong in below code, please advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option Explicit&lt;BR /&gt;Public txtQTY As String&lt;BR /&gt;Public Sub Add_PrefixQTY_To_Dim()&lt;BR /&gt;Dim oSelect As New clsSelect&lt;BR /&gt;On Error GoTo finish:&lt;BR /&gt;' Declare a variable and create a new instance of the select class.&lt;/P&gt;&lt;P&gt;frmAddPrefix.Show&lt;BR /&gt;txtQTY = frmAddPrefix.txtQTY&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Do&lt;BR /&gt;Dim oDrawDoc As DrawingDocument&lt;BR /&gt;Dim oRefDoc As Document&lt;BR /&gt;Set oDrawDoc = thisapplication.ActiveDocument&lt;BR /&gt;' Call the Pick method of the clsSelect object and set the filter to pick any dimension.&lt;BR /&gt;Dim oDrawDim As DrawingDimension&lt;BR /&gt;'Filter out anything that is not a dimension&lt;BR /&gt;Set oDrawDim = oSelect.PickDim(kDrawingDimensionFilter)&lt;BR /&gt;Dim oStr As String&lt;BR /&gt;'Check to see if the text is already there&lt;BR /&gt;If InStr(oDrawDim.Text.FormattedText, "X") = 0 Then&lt;BR /&gt;' If "TYP" has not been added already, add it&lt;BR /&gt;oStr = txtQTY + " " + oDrawDim.Text.FormattedText&lt;BR /&gt;oDrawDim.Text.FormattedText = oStr&lt;BR /&gt;' If "TYP" has been added already, skip this dimension and continue selecting&lt;BR /&gt;ElseIf InStr(oDrawDim.Text.FormattedText, "X") &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;Dim i As Integer&lt;BR /&gt;Dim Pos As Integer&lt;BR /&gt;Dim FindChar As String&lt;BR /&gt;Dim SearchString As String&lt;BR /&gt;SearchString = oDrawDim.Text.FormattedText&lt;BR /&gt;FindChar = "X"&lt;BR /&gt;&lt;BR /&gt;For i = 1 To Len(SearchString)&lt;BR /&gt;If Mid(SearchString, i, 1) = FindChar Then&lt;BR /&gt;Pos = i&lt;BR /&gt;End If&lt;BR /&gt;Next i&lt;/P&gt;&lt;P&gt;Dim FindXPos As String&lt;BR /&gt;FindXPos = Replace(oDrawDim.Text.FormattedText, Mid(oDrawDim.Text.FormattedText, 1, Pos), txtQTY)&lt;BR /&gt;oStr = FindXPos&lt;BR /&gt;oDrawDim.Text.FormattedText = oStr&lt;BR /&gt;End If&lt;BR /&gt;Loop&lt;BR /&gt;finish:&lt;BR /&gt;Unload frmAddPrefix&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;' Declare the event objects&lt;BR /&gt;Private WithEvents oInteraction As InteractionEvents&lt;BR /&gt;Private WithEvents oMouseEvents As MouseEvents&lt;BR /&gt;Private WithEvents oSelect As SelectEvents&lt;/P&gt;&lt;P&gt;' Declare a flag that's used to determine when selection stops.&lt;BR /&gt;Private bstillSelecting As Boolean&lt;/P&gt;&lt;P&gt;Public Function PickDim(filter As SelectionFilterEnum) As Object&lt;BR /&gt;' Initialize flag.&lt;BR /&gt;bstillSelecting = True&lt;BR /&gt;&lt;BR /&gt;' Create an InteractionEvents object.&lt;BR /&gt;Set oInteraction = thisapplication.CommandManager.CreateInteractionEvents&lt;BR /&gt;&lt;BR /&gt;' Define that we want select events rather than mouse events.&lt;BR /&gt;oInteraction.SelectionActive = True&lt;BR /&gt;Set oMouseEvents = oInteraction.MouseEvents&lt;BR /&gt;' Set a reference to the select events.&lt;BR /&gt;Set oSelect = oInteraction.SelectEvents&lt;BR /&gt;&lt;BR /&gt;' Set the filter using the value passed in.&lt;BR /&gt;oSelect.AddSelectionFilter (kDrawingDimensionFilter)&lt;BR /&gt;&lt;BR /&gt;' The InteractionEvents object.&lt;BR /&gt;oInteraction.start&lt;BR /&gt;&lt;BR /&gt;' Loop until a selection is made.&lt;BR /&gt;Do While bstillSelecting&lt;BR /&gt;thisapplication.UserInterfaceManager.DoEvents&lt;BR /&gt;'System.Windows.Forms.Application.DoEvents&lt;BR /&gt;Loop&lt;BR /&gt;&lt;BR /&gt;' Get the selected item. If more than one thing was selected,&lt;BR /&gt;' just get the first item and ignore the rest.&lt;BR /&gt;Dim oSelectedEnts As ObjectsEnumerator&lt;BR /&gt;Set oSelectedEnts = oSelect.SelectedEntities&lt;BR /&gt;If oSelectedEnts.Count &amp;gt; 0 Then&lt;BR /&gt;Set PickDim = oSelectedEnts.Item(1)&lt;BR /&gt;Else&lt;BR /&gt;Set PickDim = Nothing&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' Stop the InteractionEvents object.&lt;BR /&gt;oInteraction.Stop&lt;BR /&gt;&lt;BR /&gt;' Clean up.&lt;BR /&gt;Set oSelect = Nothing&lt;BR /&gt;Set oInteraction = Nothing&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;Public Function Pick(filter As SelectionFilterEnum) As Object&lt;BR /&gt;' Initialize flag.&lt;BR /&gt;bstillSelecting = True&lt;BR /&gt;&lt;BR /&gt;' Create an InteractionEvents object.&lt;BR /&gt;Set oInteraction = thisapplication.CommandManager.CreateInteractionEvents&lt;BR /&gt;&lt;BR /&gt;' Define that we want select events rather than mouse events.&lt;BR /&gt;oInteraction.SelectionActive = True&lt;BR /&gt;&lt;BR /&gt;' Set a reference to the select events.&lt;BR /&gt;Set oSelect = oInteraction.SelectEvents&lt;BR /&gt;&lt;BR /&gt;' Set the filter using the value passed in.&lt;BR /&gt;oSelect.AddSelectionFilter filter&lt;BR /&gt;&lt;BR /&gt;' The InteractionEvents object.&lt;BR /&gt;oInteraction.start&lt;BR /&gt;&lt;BR /&gt;' Loop until a selection is made.&lt;BR /&gt;Do While bstillSelecting&lt;BR /&gt;thisapplication.UserInterfaceManager.DoEvents&lt;BR /&gt;'System.Windows.Forms.Application.DoEvents&lt;BR /&gt;Loop&lt;BR /&gt;&lt;BR /&gt;' Get the selected item. If more than one thing was selected,&lt;BR /&gt;' just get the first item and ignore the rest.&lt;BR /&gt;Dim oSelectedEnts As ObjectsEnumerator&lt;BR /&gt;Set oSelectedEnts = oSelect.SelectedEntities&lt;BR /&gt;If oSelectedEnts.Count &amp;gt; 0 Then&lt;BR /&gt;Set Pick = oSelectedEnts.Item(1)&lt;BR /&gt;Else&lt;BR /&gt;Set Pick = Nothing&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' Stop the InteractionEvents object.&lt;BR /&gt;oInteraction.Stop&lt;BR /&gt;&lt;BR /&gt;' Clean up.&lt;BR /&gt;Set oSelect = Nothing&lt;BR /&gt;Set oInteraction = Nothing&lt;BR /&gt;End Function&lt;BR /&gt;Private Sub oInteraction_OnTerminate()&lt;BR /&gt;' Set the flag to indicate we're done.&lt;BR /&gt;bstillSelecting = False&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;Private Sub oSelect_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, _&lt;BR /&gt;ByVal SelectionDevice As SelectionDeviceEnum, _&lt;BR /&gt;ByVal ModelPosition As Point, _&lt;BR /&gt;ByVal ViewPosition As Point2d, _&lt;BR /&gt;ByVal View As View)&lt;BR /&gt;' Set the flag to indicate we're done.&lt;BR /&gt;bstillSelecting = False&lt;BR /&gt;End Sub&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2013 08:19:19 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-06-18T08:19:19Z</dc:date>
    <item>
      <title>Inventor commandmanager.Pick method problem</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-commandmanager-pick-method-problem/m-p/4301153#M130188</link>
      <description>&lt;P&gt;I have some problem using the inventor commandmanager.pick method. Below is the code. (Attached my VBA userform). When the userform run, I will pick the QTY from the userform, then I have used pick method to pick the dimension). the 'Pick" method does not work well. Sometimes I could able to pick the dimension, but many times no. Also attached the class function also, if anything wrong in below code, please advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option Explicit&lt;BR /&gt;Public txtQTY As String&lt;BR /&gt;Public Sub Add_PrefixQTY_To_Dim()&lt;BR /&gt;Dim oSelect As New clsSelect&lt;BR /&gt;On Error GoTo finish:&lt;BR /&gt;' Declare a variable and create a new instance of the select class.&lt;/P&gt;&lt;P&gt;frmAddPrefix.Show&lt;BR /&gt;txtQTY = frmAddPrefix.txtQTY&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Do&lt;BR /&gt;Dim oDrawDoc As DrawingDocument&lt;BR /&gt;Dim oRefDoc As Document&lt;BR /&gt;Set oDrawDoc = thisapplication.ActiveDocument&lt;BR /&gt;' Call the Pick method of the clsSelect object and set the filter to pick any dimension.&lt;BR /&gt;Dim oDrawDim As DrawingDimension&lt;BR /&gt;'Filter out anything that is not a dimension&lt;BR /&gt;Set oDrawDim = oSelect.PickDim(kDrawingDimensionFilter)&lt;BR /&gt;Dim oStr As String&lt;BR /&gt;'Check to see if the text is already there&lt;BR /&gt;If InStr(oDrawDim.Text.FormattedText, "X") = 0 Then&lt;BR /&gt;' If "TYP" has not been added already, add it&lt;BR /&gt;oStr = txtQTY + " " + oDrawDim.Text.FormattedText&lt;BR /&gt;oDrawDim.Text.FormattedText = oStr&lt;BR /&gt;' If "TYP" has been added already, skip this dimension and continue selecting&lt;BR /&gt;ElseIf InStr(oDrawDim.Text.FormattedText, "X") &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;Dim i As Integer&lt;BR /&gt;Dim Pos As Integer&lt;BR /&gt;Dim FindChar As String&lt;BR /&gt;Dim SearchString As String&lt;BR /&gt;SearchString = oDrawDim.Text.FormattedText&lt;BR /&gt;FindChar = "X"&lt;BR /&gt;&lt;BR /&gt;For i = 1 To Len(SearchString)&lt;BR /&gt;If Mid(SearchString, i, 1) = FindChar Then&lt;BR /&gt;Pos = i&lt;BR /&gt;End If&lt;BR /&gt;Next i&lt;/P&gt;&lt;P&gt;Dim FindXPos As String&lt;BR /&gt;FindXPos = Replace(oDrawDim.Text.FormattedText, Mid(oDrawDim.Text.FormattedText, 1, Pos), txtQTY)&lt;BR /&gt;oStr = FindXPos&lt;BR /&gt;oDrawDim.Text.FormattedText = oStr&lt;BR /&gt;End If&lt;BR /&gt;Loop&lt;BR /&gt;finish:&lt;BR /&gt;Unload frmAddPrefix&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;' Declare the event objects&lt;BR /&gt;Private WithEvents oInteraction As InteractionEvents&lt;BR /&gt;Private WithEvents oMouseEvents As MouseEvents&lt;BR /&gt;Private WithEvents oSelect As SelectEvents&lt;/P&gt;&lt;P&gt;' Declare a flag that's used to determine when selection stops.&lt;BR /&gt;Private bstillSelecting As Boolean&lt;/P&gt;&lt;P&gt;Public Function PickDim(filter As SelectionFilterEnum) As Object&lt;BR /&gt;' Initialize flag.&lt;BR /&gt;bstillSelecting = True&lt;BR /&gt;&lt;BR /&gt;' Create an InteractionEvents object.&lt;BR /&gt;Set oInteraction = thisapplication.CommandManager.CreateInteractionEvents&lt;BR /&gt;&lt;BR /&gt;' Define that we want select events rather than mouse events.&lt;BR /&gt;oInteraction.SelectionActive = True&lt;BR /&gt;Set oMouseEvents = oInteraction.MouseEvents&lt;BR /&gt;' Set a reference to the select events.&lt;BR /&gt;Set oSelect = oInteraction.SelectEvents&lt;BR /&gt;&lt;BR /&gt;' Set the filter using the value passed in.&lt;BR /&gt;oSelect.AddSelectionFilter (kDrawingDimensionFilter)&lt;BR /&gt;&lt;BR /&gt;' The InteractionEvents object.&lt;BR /&gt;oInteraction.start&lt;BR /&gt;&lt;BR /&gt;' Loop until a selection is made.&lt;BR /&gt;Do While bstillSelecting&lt;BR /&gt;thisapplication.UserInterfaceManager.DoEvents&lt;BR /&gt;'System.Windows.Forms.Application.DoEvents&lt;BR /&gt;Loop&lt;BR /&gt;&lt;BR /&gt;' Get the selected item. If more than one thing was selected,&lt;BR /&gt;' just get the first item and ignore the rest.&lt;BR /&gt;Dim oSelectedEnts As ObjectsEnumerator&lt;BR /&gt;Set oSelectedEnts = oSelect.SelectedEntities&lt;BR /&gt;If oSelectedEnts.Count &amp;gt; 0 Then&lt;BR /&gt;Set PickDim = oSelectedEnts.Item(1)&lt;BR /&gt;Else&lt;BR /&gt;Set PickDim = Nothing&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' Stop the InteractionEvents object.&lt;BR /&gt;oInteraction.Stop&lt;BR /&gt;&lt;BR /&gt;' Clean up.&lt;BR /&gt;Set oSelect = Nothing&lt;BR /&gt;Set oInteraction = Nothing&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;Public Function Pick(filter As SelectionFilterEnum) As Object&lt;BR /&gt;' Initialize flag.&lt;BR /&gt;bstillSelecting = True&lt;BR /&gt;&lt;BR /&gt;' Create an InteractionEvents object.&lt;BR /&gt;Set oInteraction = thisapplication.CommandManager.CreateInteractionEvents&lt;BR /&gt;&lt;BR /&gt;' Define that we want select events rather than mouse events.&lt;BR /&gt;oInteraction.SelectionActive = True&lt;BR /&gt;&lt;BR /&gt;' Set a reference to the select events.&lt;BR /&gt;Set oSelect = oInteraction.SelectEvents&lt;BR /&gt;&lt;BR /&gt;' Set the filter using the value passed in.&lt;BR /&gt;oSelect.AddSelectionFilter filter&lt;BR /&gt;&lt;BR /&gt;' The InteractionEvents object.&lt;BR /&gt;oInteraction.start&lt;BR /&gt;&lt;BR /&gt;' Loop until a selection is made.&lt;BR /&gt;Do While bstillSelecting&lt;BR /&gt;thisapplication.UserInterfaceManager.DoEvents&lt;BR /&gt;'System.Windows.Forms.Application.DoEvents&lt;BR /&gt;Loop&lt;BR /&gt;&lt;BR /&gt;' Get the selected item. If more than one thing was selected,&lt;BR /&gt;' just get the first item and ignore the rest.&lt;BR /&gt;Dim oSelectedEnts As ObjectsEnumerator&lt;BR /&gt;Set oSelectedEnts = oSelect.SelectedEntities&lt;BR /&gt;If oSelectedEnts.Count &amp;gt; 0 Then&lt;BR /&gt;Set Pick = oSelectedEnts.Item(1)&lt;BR /&gt;Else&lt;BR /&gt;Set Pick = Nothing&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;' Stop the InteractionEvents object.&lt;BR /&gt;oInteraction.Stop&lt;BR /&gt;&lt;BR /&gt;' Clean up.&lt;BR /&gt;Set oSelect = Nothing&lt;BR /&gt;Set oInteraction = Nothing&lt;BR /&gt;End Function&lt;BR /&gt;Private Sub oInteraction_OnTerminate()&lt;BR /&gt;' Set the flag to indicate we're done.&lt;BR /&gt;bstillSelecting = False&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;Private Sub oSelect_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, _&lt;BR /&gt;ByVal SelectionDevice As SelectionDeviceEnum, _&lt;BR /&gt;ByVal ModelPosition As Point, _&lt;BR /&gt;ByVal ViewPosition As Point2d, _&lt;BR /&gt;ByVal View As View)&lt;BR /&gt;' Set the flag to indicate we're done.&lt;BR /&gt;bstillSelecting = False&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2013 08:19:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-commandmanager-pick-method-problem/m-p/4301153#M130188</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-06-18T08:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor commandmanager.Pick method problem</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-commandmanager-pick-method-problem/m-p/4301826#M130189</link>
      <description>&lt;P&gt;You mention the CommandManager.Pick, but this is not used on the sample code you provided on the post....can you clarify?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could not find any previous report on this. There are some samples at our help file, such as &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;Public Sub GetSingleSelection()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get a feature selection from the user&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim oObject As Object&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set oObject = ThisApplication.CommandManager.Pick(kPartFeatureFilter, "Pick a feature")&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox "Picked: " &amp;amp; oObject.Name&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2013 16:50:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-commandmanager-pick-method-problem/m-p/4301826#M130189</guid>
      <dc:creator>augusto.goncalves</dc:creator>
      <dc:date>2013-06-18T16:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor commandmanager.Pick method problem</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-commandmanager-pick-method-problem/m-p/4301936#M130190</link>
      <description>&lt;P&gt;Sorry. it was not commandmanager issue, it is thisapplication.userinterfacemanager.doevents issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2013 18:19:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-commandmanager-pick-method-problem/m-p/4301936#M130190</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-06-18T18:19:52Z</dc:date>
    </item>
  </channel>
</rss>

