Reply

How to get mouse click event of draft document

[ Edited ]

 

Dear all,

Can anybody tell how to get mouse click event of draft document in VB6 and solid edge V19.

Scenario is:

If user clicks on draft document in the one of view (after 'drawinview' command), I need to pick that event to get clicked coordintates.

Can anybody explain me how to do it? Any sample code will be very very useful.

Thanks to all of you in advance.

Madhav

 

 

Posted by: madhav dhamale
Post date: 6/21/2009 10:44:00 PM

7 REPLIES

RE: How to get mouse click event of draft document

[ Edited ]

 

I don't know if this is what you are looking for. After "draw in view" you should call this program to get the coordinates of point that you click on the sheet.

 'Generate a form with a listbox called "List1"'Run this and you'll get the coordinates in the list in the formDim oSE As SolidEdgeFramework.ApplicationDim oDFT As SolidEdgeDraft.DraftDocumentDim WithEvents oComm As CommandDim WithEvents oMouse As MousePrivate Sub Form_Load()Set oSE = GetObject(, "solidedge.application")Set oDFT = oSE.ActiveDocumentSet oComm = oSE.CreateCommand(2)Set oMouse = oComm.MouseoComm.StartEnd SubPrivate 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. List1.AddItem "X=" & Format(dX * 1000, "0.00") & vbTab & "Y=" & Format(dY * 1000, "0.00") Else 'finish. Right mouse button End End IfEnd Sub

 

Posted by: Julian Guillo
Post date: 6/22/2009 11:37:38 PM

RE: How to get mouse click event of draft document

[ Edited ]

Thanks Julian. It works.

 

Posted by: madhav dhamale
Post date: 6/23/2009 9:07:22 PM

RE: How to get mouse click event of draft document

[ Edited ]

Create a new class:

class NewCommand : SolidEdgeFramework.ISECommand, SolidEdgeFramework.ISECommandEvents, SolidEdgeFramework.ISEMouse, SolidEdgeFramework.ISEMouseEvents

{

private Hashtable connectionPoints = new Hashtable();

private ISECommand cmd;

private ISEMouse mouse;

private SolidEdgeFramework.Application application;

private SolidEdgeDraft.DraftDocument dftdoc;

public AddHoleCommand(SolidEdgeFramework.Application app)

{

application = app;

cmd =(ISECommand) application.CreateCommand((int)SolidEdgeConstants.seCmdFlag.seNoDeactivate);

mouse = (ISEMouse)cmd.Mouse;

dftdoc= application.ActiveDocument as SolidEdgeAssembly.AssemblyDocument;

cmd.Start();

}

private void HookEvents(object source, Guid eventGUID)

{

try

{

// Cast the source using the UCOMIConnectionPointContainer interface.

System.Runtime.InteropServices.ComTypes.IConnectionPointContainer connectionPointContainer = (System.Runtime.InteropServices.ComTypes.IConnectionPointContainer)source;

System.Runtime.InteropServices.ComTypes.IConnectionPoint connectionPoint = null;

 

if (connectionPointContainer != null)

{

// Ask the connectable object if it has a connection point for a particular GUID,

// and if so, return the IConnectionPoint interface pointer to that connection point.

connectionPointContainer.FindConnectionPoint(ref eventGUID, out connectionPoint);

if (connectionPoint != null)

{

int cookie = 0;

// Establish an advisory connection between the connection point and the caller's sink object.

connectionPoint.Advise(this, out cookie);

if (cookie != 0)

{

// Add the UCOMIConnectionPoint to the Hashtable.

this.connectionPoints.Add(connectionPoint, cookie);

}

else

{

throw new System.Exception("Advisory connection between the connection point and the caller's sink object failed.");

}

}

}

else

{

throw new System.Exception("Source does not implement IConnectionPointContainer.");

}

}

catch (System.Exception e)

{

throw e;

}

}

 

/// Custom method to remove any previously attached hooks into events.

private void UnhookEvents()

{

try

{

// Unadvise the UCOMIConnectionPoint objects.

IDictionaryEnumerator enumerator = this.connectionPoints.GetEnumerator();

while (enumerator.MoveNext())

{

((System.Runtime.InteropServices.ComTypes.IConnectionPoint)enumerator.Key).Unadvise((int)enumerator.Value);

}

// Clear the Hashtable

this.connectionPoints.Clear();

}

catch

{

}

}

void ISECommandEvents.Activate()

{

//throw new NotImplementedException();

 

/**/

mouse.ScaleMode = 1;

mouse.WindowTypes = 1;

mouse.EnabledMove = true;

mouse.EnabledDrag = false;

mouse.LocateMode = (int)SolidEdgeConstants.seLocateModes.seLocateQuickPick;

mouse.ClearLocateFilter();

mouse.AddToLocateFilter((int)SolidEdgeConstants.seLocateFilterConstants.seLocatePart);

}

void ISEMouseEvents.MouseClick(short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)

{

//throw new NotImplementedException();

if (sButton == 1)

{

if (pGraphicDispatch == null)

return;

object=pGraphicDispatch;

}

if (sButton == 2)

cmd.Done = true;

}

}

 

Posted by: assassin 007
Post date: 6/26/2009 2:23:18 AM

RE: How to get mouse click event of draft document

[ Edited ]

c# codes; you can create a new class instance where you need. And then edit the function void ISECommandEvents.Activate() and ISEMouseEvents.MouseClick.

And I'm sorry that public AddHoleCommand(SolidEdgeFramework.Application app) should be public NewCommand(SolidEdgeFramework.Application app).

 

Posted by: assassin 007
Post date: 6/26/2009 2:26:19 AM

Re: RE: How to get mouse click event of draft document

Hello assassin,

 

I know this is a very old post I'm replying to but I am trying very hard to apply your code example in C# and I cannot get anything to work. I am still rather new to coding and it's easier to see the full code.

 

What I am trying to do is simply get a script to connect to the Solid Edge mouse events and give me a messagebox with the X and Y coordinates I clicked on the active document when I click on it. I've tried dozens of things based on examples and nothing is clear. I am using Visual studio for my programming which has helped me figure out a lot but I can't get this mouse stuff...

 

Any help is appreciated!

Re: RE: How to get mouse click event of draft document

[ Edited ]

Hi
Have a look at the mouse program in the custom directory of the installation. There are also a lot of examples here: https://github.com/SolidEdgeCommunity

regards

JB
VS2015, SE ST10

Re: RE: How to get mouse click event of draft document

What JB said. Download the Samples repository and check out the MouseEvents sample.

Jason Newell
Applications Architect
www.jasonnewell.net