.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to pick an insertion point with the mouse?

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
1840 Views, 8 Replies

How to pick an insertion point with the mouse?

How do I get an onscreen point after/ during a VB.net dialog box is launched (as example like with Hatch add pick points.

 

I would like to create button for this in a vb.net dialog box?

8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

to get the point, you use editor's method GetPoint

 

 

Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim ed As Editor = db.Editor

Dim newPoint as Point3d = ed.GetPoint("Pick a point: ").Value

 

 

Message 3 of 9
norman.yuan
in reply to: Anonymous

You need to hide the dialog box so that user can pick in Acad editor, and then show the dialog box back. AutoCAD API provides a class for you: EditorUserInteraction. Assume you have a button on the form btnPick:

 

private void btnPick_Click(....)

{

    Editor ed=Application.DocumentManaer.MdiDocument.Editor;

    using ed.StartUserInteraction(this) //Calling StartUserInteraction(form) will hide the form automatically

    {

        PromptPointResult res=ed.GetPoint("\nPick a point:");

        if (res.Status==PromptStatus.OK)

        {

            //Populate text boxes with picked Point3d value

            txtBoxPointX.Text=res.Value.X.ToString();

            txtBoxPointY.Text=res.Value.Y.ToString();

            txtBoxPointZ.Text=res.Value.Z.ToString();

        }

    }

 

   //When the using block ends, the form shows back

}

Norman Yuan

Drive CAD With Code

EESignature

Message 4 of 9
Anonymous
in reply to: Anonymous

Hi,

 

I tested it but get the error message that a few items are not defined eg:

 

 

type "point3d" is not defined

 

Im assuming that i need to refrence Autocad first however all i see is a bunch of Acblablabla type librarys which one do i need?

 

Message 5 of 9
Anonymous
in reply to: Anonymous

acdbmgd.dll

acmgd.dll

Message 6 of 9
Anonymous
in reply to: Anonymous

Hi

 

I was trying out your code snippet but i get the following error message which I cant figure out.

 

Error 7 'Editor' is not a member of 'Autodesk.AutoCAD.DatabaseServices.Database'. C:\Users\Bart van Tuyl\Desktop\VB.net insert block example\Insert block\Insert block\Class1.vb 36 28 Insert block

 

do you know how to fix this?

Message 7 of 9
Anonymous
in reply to: Anonymous

This might be related to the big split, when core components were moved to separate dll. I don't have access to any AutoCAD API solution to check it now, but try to search in object browser for Editor and see in which namespace it can be found

Message 8 of 9
Anonymous
in reply to: Anonymous

In principal this code should work under vb.net 2010? If so i also have v2010 installed
Message 9 of 9
Anonymous
in reply to: Anonymous

It's related to AutoCAD version, but yes, it should work with AutoCAD 2010

 

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


Autodesk Design & Make Report

”Boost