Showing results for 
Search instead for 
Did you mean: 

Move object to last click in Solidedge assembly

Valued Contributor
Valued Contributor

I'm implementing a program wich adds new occurrences in an active assembly file and puts them in the neighbourhood where the user is actively working (eg last click release).


Therefore I first add the occurence and remove the ground constraint. At last I move the occurrence but i can't get the right mouse-coordinates:


Sub addPart()
'Variable declaration
Dim oSE As SolidEdgeFramework.Application
Dim oDoc As SolidEdgeDocument
Dim oAsm As SolidEdgeAssembly.AssemblyDocument
Dim oOccs As Occurrences
Dim oOcc As Occurrence
Dim oMouse As SolidEdgeFramework.Mouse
Dim oCommand As SolidEdgeFramework.Command
Dim oOccRels As SolidEdgeAssembly.Relations3d
Dim oOccRel As SolidEdgeAssembly.GroundRelation3d
Dim FileName As string

'calling solidedge application
Set oSE = GetObject(, "solidedge.application") 

'Setting objects
Set oDoc = oSE.ActiveDocument
If oDoc.Type = igAssemblyDocument Then
    Set oAsm = oDoc
    Set oOccs = oAsm.Occurrences
    Set oCommand = oSE.CreateCommand(1)
    Set oMouse = oCommand.Mouse
end if

FileName = "M:\test.par"

'Add occurrence
Set oOcc = oOccs.AddByFilename(FileName)

'Delete groundrelation
Set oOccRels = oOcc.Relations3d
Set oOccRel = oOccRels.Item(1)

'Move occurence
oOcc.Move oMouse.LastEventUpX,_
   oMouse.LastEventUpY, oMouse.LastEventUpZ

End sub

 I'm under the impression that the values


oMouse.LastEventUpX,  oMouse.LastEventUpY and oMouse.LastEventUpZ


aren't updated. That's why I think that is should do something with the mouseUp event in the mouse class.


Unfortunatly, I don't know anything about setting up costum events in VBA. Does anyone maybe have a good refference or have a little example for me?




Re: Move object to last click in Solidedge assembly

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

The SE Samples from Jason Newell include a command demo which handles mouse events. Based on that, you could write your code.

But I am not sure what is the difference to the normal drag&drop behaviour of SE when adding a new occurrence to the active assembly?

In this case, the new occurrence will also appear under the mouse position, where you dropped it...