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

hittest functionality

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
409 Views, 6 Replies

hittest functionality

Hello all,

I was wondering if .NET in AutoCAD provides a function with a "hittest"
behaviour (like for example in Silverlight and Flash).

My case:
I have to check if 2000 symbols are placed on an endpoint of one of 4000
polylines, with a search margin of 0.5. I am now using two
ObjectIdCollections with all the ids, and have to check 2000x4000= 8 milion
times if a symbol is matching a polyline. This way the function is becoming
rather slow.

If I could use a "hittest" function (returning all objects within a margin
around a Point3d), the function would become about 4000 times faster.

Anyone an idea?
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

Check out the Select... methods of the Editor class.
SelectCrossingWindow(...) will select all entities that the window crosses
or totally encloses. Note if you pass in the same point twice you can create
a selection of all entities that cross that point.

"HeNK" wrote in message
news:6233126@discussion.autodesk.com...
Hello all,

I was wondering if .NET in AutoCAD provides a function with a "hittest"
behaviour (like for example in Silverlight and Flash).

My case:
I have to check if 2000 symbols are placed on an endpoint of one of 4000
polylines, with a search margin of 0.5. I am now using two
ObjectIdCollections with all the ids, and have to check 2000x4000= 8 milion
times if a symbol is matching a polyline. This way the function is becoming
rather slow.

If I could use a "hittest" function (returning all objects within a margin
around a Point3d), the function would become about 4000 times faster.

Anyone an idea?
Message 3 of 7
Anonymous
in reply to: Anonymous

Yes, you're right, I did try the SelectCrossingWindow() now.

But I ran into two limitations of this function, due to using the
EditorInput I guess:
- If the crossingwindow is outside the screen, the function returns the
Status "Error".
- The count of ObjectIds found is dependent of the zoom factor.

(This functionality does not differ from behaviour in for example
Silverlight, which also uses the screen pixels for calculations)

I did hope a function would exist on database level (more reliable), but it
is understandable there isn't one.

Thanks,
Henk
Message 4 of 7
Anonymous
in reply to: Anonymous

You could zoom to the area in question and then do your selection.
This will select objects that pass throught 0,0,0 even if they are not
zoomed on the screen.
{code}
[CommandMethod("Hittest")]
public static void Hit()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

//add reference to COM AutoCAD Type Library
((AcadApplication) Application.AcadApplication).ZoomWindow
(new double[] { -1, -1, -1 }, new double[] { 1, 1, 1 });

PromptSelectionResult psr =
ed.SelectCrossingWindow(new Point3d(0, 0, 0), new Point3d(0,0,0));

((AcadApplication)Application.AcadApplication).ZoomPrevious();
}
{code}

"HeNK" wrote in message
news:6233136@discussion.autodesk.com...
Yes, you're right, I did try the SelectCrossingWindow() now.

But I ran into two limitations of this function, due to using the
EditorInput I guess:
- If the crossingwindow is outside the screen, the function returns the
Status "Error".
- The count of ObjectIds found is dependent of the zoom factor.

(This functionality does not differ from behaviour in for example
Silverlight, which also uses the screen pixels for calculations)

I did hope a function would exist on database level (more reliable), but it
is understandable there isn't one.

Thanks,
Henk
Message 5 of 7
Anonymous
in reply to: Anonymous

I should have noted to add a 'using' directive for the COM call.
using Autodesk.AutoCAD.Interop;

"Paul Richardson" wrote in message
news:6233226@discussion.autodesk.com...
You could zoom to the area in question and then do your selection.
This will select objects that pass throught 0,0,0 even if they are not
zoomed on the screen.
{code}
[CommandMethod("Hittest")]
public static void Hit()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

//add reference to COM AutoCAD Type Library
((AcadApplication) Application.AcadApplication).ZoomWindow
(new double[] { -1, -1, -1 }, new double[] { 1, 1, 1 });

PromptSelectionResult psr =
ed.SelectCrossingWindow(new Point3d(0, 0, 0), new Point3d(0,0,0));

((AcadApplication)Application.AcadApplication).ZoomPrevious();
}
{code}

"HeNK" wrote in message
news:6233136@discussion.autodesk.com...
Yes, you're right, I did try the SelectCrossingWindow() now.

But I ran into two limitations of this function, due to using the
EditorInput I guess:
- If the crossingwindow is outside the screen, the function returns the
Status "Error".
- The count of ObjectIds found is dependent of the zoom factor.

(This functionality does not differ from behaviour in for example
Silverlight, which also uses the screen pixels for calculations)

I did hope a function would exist on database level (more reliable), but it
is understandable there isn't one.

Thanks,
Henk
Message 6 of 7
Anonymous
in reply to: Anonymous

Tnx, I will give it a try.

Henk


"Paul Richardson" schreef in bericht
news:6233275@discussion.autodesk.com...
I should have noted to add a 'using' directive for the COM call.
using Autodesk.AutoCAD.Interop;

"Paul Richardson" wrote in message
news:6233226@discussion.autodesk.com...
You could zoom to the area in question and then do your selection.
This will select objects that pass throught 0,0,0 even if they are not
zoomed on the screen.
{code}
[CommandMethod("Hittest")]
public static void Hit()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

//add reference to COM AutoCAD Type Library
((AcadApplication) Application.AcadApplication).ZoomWindow
(new double[] { -1, -1, -1 }, new double[] { 1, 1, 1 });

PromptSelectionResult psr =
ed.SelectCrossingWindow(new Point3d(0, 0, 0), new Point3d(0,0,0));

((AcadApplication)Application.AcadApplication).ZoomPrevious();
}
{code}

"HeNK" wrote in message
news:6233136@discussion.autodesk.com...
Yes, you're right, I did try the SelectCrossingWindow() now.

But I ran into two limitations of this function, due to using the
EditorInput I guess:
- If the crossingwindow is outside the screen, the function returns the
Status "Error".
- The count of ObjectIds found is dependent of the zoom factor.

(This functionality does not differ from behaviour in for example
Silverlight, which also uses the screen pixels for calculations)

I did hope a function would exist on database level (more reliable), but it
is understandable there isn't one.

Thanks,
Henk
Message 7 of 7
Anonymous
in reply to: Anonymous

np - I should have set the z value of the test zoom points to 0 instead - it
was early ~)

"HeNK" wrote in message
news:6233452@discussion.autodesk.com...
Tnx, I will give it a try.

Henk


"Paul Richardson" schreef in bericht
news:6233275@discussion.autodesk.com...
I should have noted to add a 'using' directive for the COM call.
using Autodesk.AutoCAD.Interop;

"Paul Richardson" wrote in message
news:6233226@discussion.autodesk.com...
You could zoom to the area in question and then do your selection.
This will select objects that pass throught 0,0,0 even if they are not
zoomed on the screen.
{code}
[CommandMethod("Hittest")]
public static void Hit()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

//add reference to COM AutoCAD Type Library
((AcadApplication) Application.AcadApplication).ZoomWindow
(new double[] { -1, -1, -1 }, new double[] { 1, 1, 1 });

PromptSelectionResult psr =
ed.SelectCrossingWindow(new Point3d(0, 0, 0), new Point3d(0,0,0));

((AcadApplication)Application.AcadApplication).ZoomPrevious();
}
{code}

"HeNK" wrote in message
news:6233136@discussion.autodesk.com...
Yes, you're right, I did try the SelectCrossingWindow() now.

But I ran into two limitations of this function, due to using the
EditorInput I guess:
- If the crossingwindow is outside the screen, the function returns the
Status "Error".
- The count of ObjectIds found is dependent of the zoom factor.

(This functionality does not differ from behaviour in for example
Silverlight, which also uses the screen pixels for calculations)

I did hope a function would exist on database level (more reliable), but it
is understandable there isn't one.

Thanks,
Henk

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