Inserting a left click through VBA

Hi you all,

I'm trying to learn a bit of programming in microstation, but I can't seem to figure this out:

I'm reworking a class I use to place cells in a drawing. Basicly the class gets a cell number from a userform, and looks up the cell, and it's "hanging" on the mousepointer. Then after a click the cell is placed in the spot in the drawing.

But now I'm rewriting the code to place multiple cells next to each other, and I have the code working to the point that when I provide the clicks manualy, a cell gets placed, the next one moves a to the left, and when I click again at the right time in the vba the next one gets placed. I've been searching the web for days now but I can't get a working solution. The code is inserted below, the sub "LeftMouseClick()" just isn't working . the out commented  lines are all thing I already tried

.

Option Explicit

Dim CellName As String
Public Breedte As Integer


Implements IPrimitiveCommandEvents
Public Sub SetCellName(Cell As String)
    
    CellName = Cell
    
End Sub
Private Sub IPrimitiveCommandEvents_Cleanup()

End Sub

Private Sub IPrimitiveCommandEvents_DataPoint(point As Point3d, ByVal View As View)

    Dim atPoint As Point3d

    atPoint.x = point.x + Breedte
    atPoint.y = point.y

    'draw the cell
    Dim oCellEl As CellElement
    Set oCellEl = CreateCellElement3(CellName, atPoint, True)
    ActiveModelReference.AddElement oCellEl
    oCellEl.Redraw

End Sub

Private Sub IPrimitiveCommandEvents_Dynamics(point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode)
    'method called to show dynamics
    
    Dim atPoint As Point3d
    
    atPoint.x = point.x + Breedte
    atPoint.y = point.y
    
    ' display a temporary cell
    Dim oCellEl As CellElement
    Set oCellEl = CreateCellElement3(CellName, atPoint, True)
    oCellEl.Redraw DrawMode

End Sub

Private Sub IPrimitiveCommandEvents_Keyin(ByVal KeyIn As String)
End Sub

Private Sub IPrimitiveCommandEvents_Reset()
    ' method called when the reset event occurs
    CommandState.StartDefaultCommand
    frmEltakoComp.Show
End Sub

Private Sub IPrimitiveCommandEvents_Start()
    'method called at the start of the command
    'Dim point As Point3d
    Dim c As Integer
    c = 0
    
    ShowCommand "Place Cell"
    CommandState.EnableAccuSnap
    CommandState.StartDynamics
    frmEltakoComp.Hide
    LeftMouseClick
    
End Sub

Private Sub LeftMouseClick()

'Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
 'Dim inputQueue As CadInputQueue

'Dim pointx As Point3d

' Set inputQueue = CadInputQueue
'  Set inputMessage = inputQueue.GetInput(msdCadInputTypeDataPoint, msdCadInputTypeAny)
'    Do
'        Select Case inputMessage.InputType
'            Case msdCadInputTypeDataPoint

'            Case msdCadInputTypeReset
'                Exit Sub
'        End Select
'   Loop

'CadInputQueue.SendCommand LeftMouseClick True

CadInputQueue.SendDataPoint Point3dZero
'   End Sub
'Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
'
'    Public Const MOUSEEVENTF_LEFTDOWN = &H2
'    Public Const MOUSEEVENTF_LEFTUP = &H4
'    End Sub
'
'
'Public Sub LeftClick()
'
'
'
'    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'   mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

And to be complete a piece of the sub that send the cellnumbers to the class:

Option Explicit


Dim Component(50) As String
Dim f
Dim Bestand As String
Dim i As Integer
Dim Cell As String
Dim AantalComp As String
Dim Widht As Integer

  
Sub CellNameProcess()
    
    Dim j As Integer
    Dim CellName As String
    Dim PlaceCell As clsPlaceCell
    Set PlaceCell = New clsPlaceCell
    Dim WidhtCalc As Integer
    
    WidhtCalc = 0
    
    For j = 0 To AantalBox1.Value
        PlaceCell.SetCellName (Cell)
        PlaceCell.Breedte = WidhtCalc
        WidhtCalc = WidhtCalc + Widht
    
        CommandState.StartPrimitive PlaceCell
    Next j
    
    AantalBox1.Value = 1

End Sub

Private Sub lblComponenten_Click()

End Sub

Private Sub Label6076_Click() 'used
Cell = "92.7000.230"
Widht = 18
Call CellNameProcess
End Sub
Any help would be greatley appreciated

Parents
  • Hi,

    I don't have much time at the moment, but hopefully this is a step in the right direction.  You do not need to give Microstation a "left click".  The process is to get the point where Microstation received the click, and then use that to add your elements.

    In  IPrimitiveCommandEvents_DataPoint, you have oCellEl that you create and then ActiveModelReference.AddElement .  For you to add multiple elements, you would use your atPoint and then add what ever offsets you want, create a new cell, and AddElement to the drawing.  (If you want a preview, you do the similar thing, but with the .Redraw Drawmode.

    --Robert

Reply
  • Hi,

    I don't have much time at the moment, but hopefully this is a step in the right direction.  You do not need to give Microstation a "left click".  The process is to get the point where Microstation received the click, and then use that to add your elements.

    In  IPrimitiveCommandEvents_DataPoint, you have oCellEl that you create and then ActiveModelReference.AddElement .  For you to add multiple elements, you would use your atPoint and then add what ever offsets you want, create a new cell, and AddElement to the drawing.  (If you want a preview, you do the similar thing, but with the .Redraw Drawmode.

    --Robert

Children
No Data