How to recognize on which entity is clicked?
Moderators: SDS, support, admin
How to recognize on which entity is clicked?
Hello
In an application, I display on the screen a plan in dxf format. Then, I intercept mouse events.
On a mouse click, I transform the coordinates (in pixel) into coordinates CADimage (into mm) with the method "CADViewX.CADCoords ()".
From CADimage coordinates, I would find the entity on which the user clicked.
But I do not know what method or property use. Could you help me?
Thank you in advance.
In an application, I display on the screen a plan in dxf format. Then, I intercept mouse events.
On a mouse click, I transform the coordinates (in pixel) into coordinates CADimage (into mm) with the method "CADViewX.CADCoords ()".
From CADimage coordinates, I would find the entity on which the user clicked.
But I do not know what method or property use. Could you help me?
Thank you in advance.
Re: How to recognize on which entity is clicked?
Hello.
A DXF drawing measured in drawing units, not in mm or other physical units. Of course you can have information about correspondence between drawing units and some physical units. But the DXF file doesn't contain such data.
Mouse (screen 2D) coordinates can be transformed to CADImage (drawing 3D) coordinates. However there is no a method that defines if returned 3D coordinates belongs to some entity. You can try to realize own method for such task.
CADViewX Pro includes visual editing functionality that doesn't provided with CADViewX Lite. A part of editing functionality is selection by mouse. You can click on entity to select then access it using editor properties. Please take a look at the following topic:
http://www.cadsofttools.com/forum/viewt ... =16&t=2905
Alexander.
A DXF drawing measured in drawing units, not in mm or other physical units. Of course you can have information about correspondence between drawing units and some physical units. But the DXF file doesn't contain such data.
Mouse (screen 2D) coordinates can be transformed to CADImage (drawing 3D) coordinates. However there is no a method that defines if returned 3D coordinates belongs to some entity. You can try to realize own method for such task.
CADViewX Pro includes visual editing functionality that doesn't provided with CADViewX Lite. A part of editing functionality is selection by mouse. You can click on entity to select then access it using editor properties. Please take a look at the following topic:
http://www.cadsofttools.com/forum/viewt ... =16&t=2905
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to recognize on which entity is clicked?
Thank you for these precisions and for the link.
Unfortunately, it is not suitable for the application I'm developing.
In the application I'm developing, the user is limited in its possibilities. He can change a limited number of entities only.
Therefore, I do not give the user the accces the editor CADViewX. I created my own interface. I disabled components CADViewX (Explorer, Favorites, Properties, ToolBar, StatusBar, ...) and I intercept mouse events.
So I can not use:
"selected = CADViewX1.GetCADEditor (). Selected"
since the user can not select an entity.
When the user clicks, i can only compare mouse coordinates (2D screen) to CADImage coordinates (3D drawing).
I will try to develop my own method to detect the entity on which the user clicked. The method that I currently see is to cover all entities and compare mouse coordinates (2D screen) with Entity.Box coordinates (3D drawing). If you see a better track, do not hesitate to report it.
Thank you in advance.
Unfortunately, it is not suitable for the application I'm developing.
In the application I'm developing, the user is limited in its possibilities. He can change a limited number of entities only.
Therefore, I do not give the user the accces the editor CADViewX. I created my own interface. I disabled components CADViewX (Explorer, Favorites, Properties, ToolBar, StatusBar, ...) and I intercept mouse events.
So I can not use:
"selected = CADViewX1.GetCADEditor (). Selected"
since the user can not select an entity.
When the user clicks, i can only compare mouse coordinates (2D screen) to CADImage coordinates (3D drawing).
I will try to develop my own method to detect the entity on which the user clicked. The method that I currently see is to cover all entities and compare mouse coordinates (2D screen) with Entity.Box coordinates (3D drawing). If you see a better track, do not hesitate to report it.
Thank you in advance.
Re: How to recognize on which entity is clicked?
But you can implement the code to Editor event handler. So entity will be deselected after you identify it:
Alexander.
Code: Select all
this.Editor = CADViewX1.GetCADEditor();
this.Editor.EditorEvent += new CADViewLib.ICADEditorEvents_EditorEventEventHandler(Editor_EditorEvent);
...
private void Editor_EditorEvent(CADViewLib.TxCADEditorEventID ID, CADViewLib.CADImage AImage, CADViewLib.Entity AEntities)
{
CADViewLib.Entity selected = (CADViewLib.Entity)Editor.Selected;
if (selected.Count == 1)
MessageBox.Show((Editor.Selected.get_Entities(0)).CADHandle.ToString());
Editor.Clear();
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to recognize on which entity is clicked?
Hello
I tested this method:
But "selected.Count" is always zero.
have you any idea why?
Xavier
I tested this method:
Code: Select all
private void Editor_EditorEvent(CADViewLib.TxCADEditorEventID ID, CADViewLib.CADImage AImage, CADViewLib.Entity AEntities)
{
CADViewLib.Entity selected = (CADViewLib.Entity)Editor.Selected;
if ([b]selected.Count [/b]== 1)
MessageBox.Show((Editor.Selected.get_Entities(0)).CADHandle.ToString());
Editor.Clear();
}
have you any idea why?
Xavier
Re: How to recognize on which entity is clicked?
i always get :
selected.count = 0
selected.EntID = 0
selected.EntName = UP
even if i do a "Editor.selectAll" before
selected.count = 0
selected.EntID = 0
selected.EntName = UP
even if i do a "Editor.selectAll" before
Re: How to recognize on which entity is clicked?
Hello.
CADEditor selects an entity by mouse left button click. All previously selected entities cleared when mouse left button is clicked. So Editor.SelectAll before does nothing. You can remove the snippet from EditorEvent handler and paste it after Editor.SelectAll to check in debug mode. Please note, selection can be done when Editor mode is active.
Alexander.
CADEditor selects an entity by mouse left button click. All previously selected entities cleared when mouse left button is clicked. So Editor.SelectAll before does nothing. You can remove the snippet from EditorEvent handler and paste it after Editor.SelectAll to check in debug mode. Please note, selection can be done when Editor mode is active.
Code: Select all
CADViewX.Mode == 0 //Viewer mode
CADViewX.Mode == 1 //Editor mode
CADViewX.Mode == 2 //Redline mode
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to recognize on which entity is clicked?
hello
I verified: CADViewX.Mode == 1(editor mode).
However, when I left click on an entity, I still get : selected.count == 0.
I program on windev Language. I thought that it might be related to Windev. So I test in c #:
I get the same result: selected.count == 0 with Mode == 1
I don't understand...
Could you explain me.
Thanks
Xavier
I verified: CADViewX.Mode == 1(editor mode).
However, when I left click on an entity, I still get : selected.count == 0.
I program on windev Language. I thought that it might be related to Windev. So I test in c #:
Code: Select all
namespace TestCS
{
public partial class Form1 : Form
{
CADViewLib.CADEditor Editor = new CADViewLib.CADEditor();
private void Editor_EditorEvent(CADViewLib.TxCADEditorEventID ID, CADViewLib.CADImage AImage, CADViewLib.Entity AEntities)
{
CADViewLib.Entity selected = (CADViewLib.Entity)Editor.Selected;
MessageBox.Show("count : " + selected.Count.ToString());
if (selected.Count == 1)
MessageBox.Show((Editor.Selected.get_Entities(0)).CADHandle.ToString());
Editor.Clear();
}
public Form1()
{
InitializeComponent();
// fichier
this.axCADViewX1.LoadFile("Z:\\ActiveX\\Exe\\Test.dxf");
// Editor
this.Editor = axCADViewX1.GetCADEditor();
this.Editor.EditorEvent += new CADViewLib.ICADEditorEvents_EditorEventEventHandler(Editor_EditorEvent);
MessageBox.Show("mode : " + axCADViewX1.Mode.ToString());
}
}
}
I don't understand...
Could you explain me.
Thanks
Xavier
Re: How to recognize on which entity is clicked?
hello
an idea of why "selected.count" is equal to zero when I select an entity?
an idea of why "selected.count" is equal to zero when I select an entity?
Re: How to recognize on which entity is clicked?
Hello Xavier.
We've used other CADViewX build number for testing. You're correct, the library available with downloading link doesn't allow to receive selected entities with the provided code. We have updated the library. Please reinstall it and use the same code snippet.
http://www.cadsofttools.com/download/cadviewx.zip
Alexander.
We've used other CADViewX build number for testing. You're correct, the library available with downloading link doesn't allow to receive selected entities with the provided code. We have updated the library. Please reinstall it and use the same code snippet.
http://www.cadsofttools.com/download/cadviewx.zip
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to recognize on which entity is clicked?
Thanks
it works
it works