Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

pick 2 points consecutively

7 REPLIES 7
Reply
Message 1 of 8
a7v1n
1920 Views, 7 Replies

pick 2 points consecutively

Hi,

 

i am using Visual Studio 2010 and I want to pick 2 points consecutively using Selection.Pickpoint.

The problem occurs after picking the first point, an error is thrown saying "The user aborted the pick operation." If I put MsgBox in between picking the first and second point, there are  no errors. Why is this so? Thanks!

 

 

Code:


            pt1 = uiDocument2.Selection.PickPoint(Autodesk.Revit.UI.Selection.ObjectSnapTypes.None, "Pick leader end...")
            pt2 = uiDocument2.Selection.PickPoint(Autodesk.Revit.UI.Selection.ObjectSnapTypes.None, "Pick leader elbow...")

 

If I do the next code, theres no error:


            pt1 = uiDocument2.Selection.PickPoint(Autodesk.Revit.UI.Selection.ObjectSnapTypes.None, "Pick leader end...")

            MsgBox("test")
            pt2 = uiDocument2.Selection.PickPoint(Autodesk.Revit.UI.Selection.ObjectSnapTypes.None, "Pick leader elbow...")

7 REPLIES 7
Message 2 of 8
Joe.Ye
in reply to: a7v1n

I used the two lines your provided, it work well on my side. Probably you pressed ESC key, or you right click the view. You can use the try and catch to handle user's wrong interaction.

 

My First Revit plug-in handled the wrong user interaction for PickPoint , PickObject.

http://jprdintprev-wac.autodesk.com/adsk/servlet/index?siteID=123112&id=16849745&preview=1 

 

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 3 of 8
a7v1n
in reply to: Joe.Ye

Thanks for the reply joe. Probably the difference between our codes is that I used a modeless dialog box. I show the dialog box and after clicking the image button, I closed the dialog box using dispose and immediately after that, I execute 2 pickpoints consecutively. I am able to pick 1 point but not the second point. Do you have this same problem? Thanks!

Message 4 of 8
Joe.Ye
in reply to: a7v1n

Hi a7v1n,

 

i tried your steps, and find it is possible to pick twice consecutively.

 

here is my code.

 

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

using  Autodesk.Revit .DB;
using Autodesk.Revit.UI;
using Autodesk.Revit .ApplicationServices;
using Autodesk.Revit.Attributes ;

using Template2010CS;


  [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
  [RegenerationAttribute(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
public class RevitCommand : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
    {

      UIApplication app = commandData.Application;
      Document doc = app.ActiveUIDocument.Document;
      Transaction trans = new Transaction(doc, "ExComm");
      trans.Start();

      Form1 myform = new Form1();
      myform.Show();

      XYZ pt1 = app.ActiveUIDocument.Selection.PickPoint("please pick first pt");
      XYZ pt2 = app.ActiveUIDocument.Selection.PickPoint("please pick second pt");

      trans.Commit();
   
        return Result.Succeeded ;
    }
}

 

In the modless dialog , there is a button. click button to dispose the dialog.

Here is the code.

  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      this.Dispose();
    }
  }

 

Run the command, click the button, i can consecutively pick twice.

 

your code maybe different with me. If this doesn't help, please let me see you code.

Good luck.



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 5 of 8
jalbert300
in reply to: Joe.Ye

I have this same problem using a modeless dialog. I have a section of code that is called when a button is pressed. Within that section of code I am trying to select 2 elements, but upon trying to select the second element I get the "User Aborted..." error.

 

The code in the last post does not seem to respond to a button click.

 

Have you figured this out original poster?

 

 

Message 6 of 8
jalbert300
in reply to: jalbert300

I should mention that I do not want to dispose of the dialog. Rather I want to leave the dialog open and display information about the 2 elements selected.

Message 7 of 8
a7v1n
in reply to: jalbert300

Yes I finally figured it out. You have to code your selection inside the class where you call the Form and not inside the Form. I did it that way and I didnt get errors while picking 2 points consecutively using a modal dialog.

Message 8 of 8
KE-engineering
in reply to: a7v1n

I have the same problem. Been working on it for a few weeks now but I can't seem to fix it.

I'm using a modeless form. After pressing a button on this form the "pick two points" function is needed.

My form must be visible at all times (shows info from poicked points).

 

I tried to use the PickPoint inside my form code. That only works when I use a Msgbox between the picks.

Tried putting it in the main class but then the pick function is activated after showing my main form.

I then can pick two points without the Msgbox in between. 

 

Problem is it has to be activated when I press a button on the main form.

 

Hope u guys can help me out...

(I'm using vb.net)

 

regards,

Dennis

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community