Reply

Get point coords on draft...help me please

[ Edited ]

Hello programmers, I'm new entry in this forum (and sorry for my poor english)

 

I use .NET now and ST3.

 

My problem is get coordinates point on a draft, on muose click SE event....

 

I see this post: http://www.jasonnewell.net/Community/Forums/tabid/55/aft/3206/Default.aspx

 

But I didn't resolved....

 

This is my poor creation, i try to put coords on Label4:

 

Imports System.Runtime.InteropServices

Imports SolidEdgeConstants

Imports System

Imports System.IO

'---------------------------------

Public Class Principale

 

    Dim WithEvents oComm As SolidEdgeFramework.Command

    Dim WithEvents oMouse As SolidEdgeFramework.Mouse

'---------------------------------

    Private Sub Principale_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        Dim objApp As SolidEdgeFramework.Application = Nothing

        Dim objType As Type

        Dim oSE As SolidEdgeFramework.Application

        Dim oDFT As SolidEdgeDraft.DraftDocument

 

        Try

 

            objApp = Marshal.GetActiveObject("SolidEdge.Application")

 

        Catch ex As Exception

            'New Visual Basic.NET Syntax ' Get the type from the Solid Edge ProgID

            objType = Type.GetTypeFromProgID("SolidEdge.Application")

            ' Start Solid Edge

            objApp = Activator.CreateInstance(objType)

            ' Make Solid Edge visible

            objApp.Visible = True

            Console.WriteLine(ex.Message)

 

        Finally

            If Not (objApp Is Nothing) Then

                Marshal.ReleaseComObject(objApp)

                objApp = Nothing

            End If

        End Try

 

        oSE = Marshal.GetActiveObject("SolidEdge.Application")

        oDFT = oSE.ActiveDocument

        oComm = oSE.CreateCommand(2)

        oMouse = oComm.Mouse

        oComm.Start()

 

End Sub

'---------------------------------

 

Private Sub oMouse_MouseUp(ByVal sButton As Integer, ByVal sShift As Integer, ByVal dX As Double, ByVal dY As Double, ByVal dZ As Double, ByVal pWindowDispatch As Object, ByVal lKeyPointType As Long, ByVal pGraphicDispatch As Object)

        If sButton = 1 Then

            'left mouse button. get coordinates.

            Label4.Text = ("X=" & Format(dX * 1000, "0.00") & vbTab & "Y=" & Format(dY * 1000, "0.00"))

        Else

            'finish. Right mouse button

            End

        End If

 

    End Sub

'---------------------------------

End Class

 

 

Please help me with an example

 

Regards, Fabiano

 

 

 

Posted by: metalworld metalworld
Post date: 12/20/2010 7:54:14 PM

2 REPLIES

RE: Get point coords on draft...help me please

[ Edited ]

I solved!!!

 

 

Posted by: metalworld metalworld
Post date: 12/21/2010 12:51:26 AM

RE: Get point coords on draft...help me please

[ Edited ]

Posted By metalworld on 21 Dec 2010 06:51 AM

I solved!!!

 

Hi,

How did u solve this?

Could you please send the sample code for this?

 

I am  trying this example to get mouse coordinates. But I am not able to get the coordinates.

Is this the correct way to get the coordinate.

 

My code

 

        private void button1_Click_1(object sender, EventArgs e)

        {

            SolidEdgeDraft.DraftDocument document = null;

            try

            {               

                document = (SolidEdgeDraft.DraftDocument)m_application.ActiveDocument;

                SolidEdgeFramework.Layer layer = (SolidEdgeFramework.Layer) document.ActiveSheet.Layers.ActiveLayer;

                SolidEdgeDraft.Sheet activeSheet = (SolidEdgeDraft.Sheet)document.ActiveSheet;

 

                SolidEdgeFramework.Command oComm = m_application.CreateCommand(2);

                SolidEdgeFramework.Mouse oMouse = oComm.Mouse;

                oComm.Start();

           }

            catch (System.Exception ex)

            {

                MessageBox.Show(ex.Message, "Invalid unit");

            }

            finally

            {

                if (document != null)

                {

                    Marshal.ReleaseComObject(document);

                    document = null;

                }

            }  

        }

 

        private void oMouse_MouseUp(int sButton, int sShift, double dX, double dY, double dZ, object pWindowDispatch, long lKeyPointType, object pGraphicDispatch)

        {

            MessageBox.Show("Called");

            if(sButton == 1)

            {

                //left mouse button. get coordinates.

                MessageBox.Show("X=" + dX * 1000 + " Y=" + dY * 1000);

            }

            else

            {

                //tests;

            }

        }

 

 

 

Posted by: Amit Wadekar
Post date: 7/28/2011 2:39:46 AM