Revit API

Reply
Distinguished Contributor
a7v1n
Posts: 216
Registered: ‎10-02-2008
Message 1 of 7 (785 Views)

pick 2 points consecutively

785 Views, 6 Replies
07-04-2011 12:12 PM

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...")

ADN Support Specialist
Joe.Ye
Posts: 325
Registered: ‎03-05-2010
Message 2 of 7 (770 Views)

Re: pick 2 points consecutively

07-06-2011 11:10 PM 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
Distinguished Contributor
a7v1n
Posts: 216
Registered: ‎10-02-2008
Message 3 of 7 (755 Views)

Re: pick 2 points consecutively

07-07-2011 08:03 AM 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!

ADN Support Specialist
Joe.Ye
Posts: 325
Registered: ‎03-05-2010
Message 4 of 7 (663 Views)

Re: pick 2 points consecutively

08-01-2011 08:20 PM 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
Valued Contributor
jta_albert
Posts: 75
Registered: ‎01-10-2006
Message 5 of 7 (590 Views)

Re: pick 2 points consecutively

09-16-2011 12:05 PM 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?

 

 

Valued Contributor
jta_albert
Posts: 75
Registered: ‎01-10-2006
Message 6 of 7 (588 Views)

Re: pick 2 points consecutively

09-16-2011 12:20 PM in reply to: jta_albert

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.

Distinguished Contributor
a7v1n
Posts: 216
Registered: ‎10-02-2008
Message 7 of 7 (530 Views)

Re: pick 2 points consecutively

10-05-2011 03:24 PM in reply to: jta_albert

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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Revit

Twitter

Facebook

Blogs

Youtube