Sign in to follow this  
LMVUICHARD

Corners coordinates of a box selection

Recommended Posts

Hello,

Is it possible to retrieve the corners coordinates of a user box selection ?

(in view coordinates AND screen coordinate, for a projected application, i will need the both...)

For example,  after a line like this :

SelectionManager.BoxSelectGeometry("Select the holes", New GeometryMask(True), 1)

How is it possible to know the corner position of the user selection box?

I have try to use and understand the "McUIEvent.GetEvent Method", without success.

I don't understand  how i must use the UIEventData Class, Is it possible to give me some example with this Method and this class?

 

Thanks in advance!

 

I use VS2019 Vb.net, with Mastercam 2020

Share this post


Link to post
Share on other sites

The SelectionManager.BoxSelectGeometry method does not provide access to the (2) corners of the user sketched window. 
There is the SelectionManager::WindowSelect method where your NET-Hook supplied the corner of the window.

The first question would be, exactly what are you wanting to do using the UIEventData Class?
(You almost always use this along with a modeless dialog.)
I have a (C#) NET-Hook project the uses a GetEvent loop.
If you email us with your company contact to [email protected] we can get you a copy of this sample project.
 

Share this post


Link to post
Share on other sites

Thank you for your quick answer.

Probably, one again more, I’ve gave you bad explanations, sorry my English isn’t, one again more, very clear…

It's a part of a big customer project we have, and to solve it, we are looking for the better solution. Inside this project, it can be a way if it's possible to make somes extractions directly Inside a Mastercam session that's the reason i try to test that.


What I want to do:

-              Ask the user to make a box selection
-              Letting him to do that on the graphics screen area
-              After it’s done, retrieve the box corners values the user has done
-              With these values, launch the two treatments I need, on Entities and on bitmap image. I think I have the ability to do that.

I have seen the SelectionManager.WindowSelect method, but it’s not what I want. With that I must give the corners coordinate, not retrieve the user's one, it’s exactly the reverse…

As asked, I've send an e-mail at [email protected] with more explanations.

Thanks

Share this post


Link to post
Share on other sites
31 minutes ago, LMVUICHARD said:

have seen the SelectionManager.WindowSelect method, but it’s not what I want. With that I must give the corners coordinate, not retrieve the user's one, it’s exactly the reverse…

Maybe do both?

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.cursor.position?redirectedfrom=MSDN&view=netcore-3.1#System_Windows_Forms_Cursor_Position

Get the cursor position from windows and pass it to mastercam.

 

32 minutes ago, LMVUICHARD said:

With these values, launch the two treatments I need, on Entities and on bitmap image.

What do you mean treatments?

 

Share this post


Link to post
Share on other sites
15 hours ago, LMVUICHARD said:

SelectionManager.BoxSelectGeometry("Select the holes", New GeometryMask(True), 1)

If you are selecting geometry there are several ways to extrapolate the minimum maximum xyz coordinates, such as getting an array of centerpoints then finding the limits or the arcs.(probably easier to use creep_record at that point rather than messing with the views to get the arcs position.

Share this post


Link to post
Share on other sites

Thanks for your answers Byte (Peter?)!


For the bitmap side, I have already tryed to use the windows graphic management.
But there is a big issue with 4K screens (3840x2160).
To manage with these, it's mandatory to make some additionnal declarations in the dot.net project
(Add a manifest file, make some declarations (Win10 app, Dpi Aware app, etc..).
https://docs.microsoft.com/en-us/dotnet/framework/winforms/high-dpi-support-in-windows-forms

I have try to do it and that run normally on a stand alone windows form.

But when i try to do that inside a NETHook project, and run it inside Mastercam, that's wrong,
these declarations have no effect and all cursor position or windows dimensioning refers to a
screen resolution with 1920x1080  one quater of the real screen...


It's not possible or I have not been able to properly insert the statements.
I believe that in any case the app inherits The Windows settings of Mastercam, and I can not change them.

That's the reason I want to try with NetHook commands, I hope that will gave a different result.

For the other side, sorting of Mastercam entities, for sure, there is many ways to do that, 
If it's possible to retrieve the view coordinates of user's box, i think it will be easier,
i have some ideas to achieve that (most based on arrays, yes...).

 

Thanks for your help!

Share this post


Link to post
Share on other sites
2 hours ago, LMVUICHARD said:

(Peter?)!

Yes sir,

Try linking to this DLL the way you do to NEThook_3.DLL https://github.com/PeterRussellEvans/ApiToolsManagedMc2020Dll

Place it in your -> Program Files/Mcam2020 Folder

Then you can access it from VB.net


' -------------------------------------------------------------------------------------------------------------------- 
Imports Mastercam.App
Imports Mastercam.App.Types
Imports Mastercam.IO
Imports Mastercam.Support
Imports Mastercam.Curves
Imports Mastercam.Database.Types
Imports Mastercam.Math
Public Class NethookMain
    Inherits NetHook3App

#Region "Public Methods"
    ''' <summary>
    ''' This method is designed to be the main entry point for your NetHook app. This is where your app should do
    ''' all of the things it's supposed to do and then return an MCamReturn value representing the outcome of your
    '''  NetHook application. 
    ''' </summary>
    ''' <param name="param">Parameter is not used</param>
    ''' <returns>A <c>MCamReturn</c> return type.</returns>
    ''' <remarks></remarks>
    Public Overrides Function Run(param As Integer) As MCamReturn
        Dim a As ArcGeometry

        If SearchManager.GetSelectedGeometry().Any() Then
            SelectionManager.UnselectAllGeometry()
        End If
        a = SelectionManager.AskForGeometry("Select Arc", New GeometryMask(False, False, True, False, False, False, False, False))
        If IsNothing(a) = True Then
            System.Windows.Forms.MessageBox.Show("No Arc Found In .NET")
            Return MCamReturn.NoErrors
            Exit Function
        End If
        Dim ents = ApiTools.Database.PointerArrays.GetEntitiesMask(4, True, 0, 0)
        If IsNothing(ents) = True Then
            System.Windows.Forms.MessageBox.Show("No Arcs Found in C++")
            Return MCamReturn.NoErrors
            Exit Function
        End If
        Dim lstOfPoints = New List(Of Mastercam.Math.Point3D)()
        For Each arrayItem In ents
            Dim creepamount = 0.002
            ApiTools.CreepRecord.GetPointsFromWireframe(arrayItem, creepamount, lstOfPoints)
            Next
            GraphicsManager.ClearColors(New GroupSelectionMask(True))
            GraphicsManager.Repaint(True)
            SelectionManager.UnselectAllGeometry()
            a = Nothing
        If IsNothing(lstOfPoints) = True Then
            System.Windows.Forms.MessageBox.Show("No Points Found in C++")
            Return MCamReturn.NoErrors
            Exit Function
        End If
        For Each arrayItem In lstOfPoints
            System.Windows.Forms.MessageBox.Show("X = " + arrayItem.x.ToString() + " Y = " + arrayItem.y.ToString() + " Z = " + arrayItem.z.ToString())
        Next
        Return MCamReturn.NoErrors
    End Function
#End Region
End Class

This will give you an array of points that represent all the positions in the arc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us