hexagon logo

How to use AppEvents?

Hello all After searching the forums and spending time trying to figure this out I came up short. I am trying to run code as soon as a DIMENSION command is created via the AppEvents automation in Excel VBA.for example
Private Sub AppEvents_OnAddObject(ByVal PartProg As PCDLRN.IPartProgram, ByVal DimensionCommand As Command)
    ' Event subroutine. This activates when a dimension command is fired.
MsgBox "Do something"
End Sub

At the moment it's triggered by ANY new item inserted in PcDmis no matter the type. How do you get it to trigger for SPECIFIC commands ONLY?

Any input is welcomed?
Thanks,
Kp61dude!
  • The AppEvents_OnAddObject is doing exactly was designed to do, trigger an event whenever something is added to the PC-Dmis program. If you're interested in capturing Dimension data after the Dimension object was executed during part measurement you may want to look at the DmisLib code and PcdmisMenu code in my thread. The DmisLib captures the Dimension Data of each Dimension command after it is executed and passes it to the PcdmisMenu application where it is written into the Main window textboxes.
  • kneislyd my goal is to use your app for reporting purpose and to use C Sharp a little more. In this scenario I want to add a report comment each time a DIMENSION command is used.

    The code would probably look like...
    Private Sub AppEvents_OnAddObject(ByVal PartProg As PCDLRN.IPartProgram, ByVal DimensionCommand As Command)
    
    ' Event subroutine. This activates when a dimension command is fired.
    If [B][I]Command is dimension type[/I] [/B]then
        ' Do something here or for this example add new comment to PcD program
    end If
    End Sub
  • Solved!!!

    Private Sub AppEvents_OnAddObject(ByVal PartProg As PCDLRN.IPartProgram, ByVal CurrentCommand As Command)
        ' Event subroutine. This activates when a dimension command is fired.
        If CurrentCommand.IsDimension = True Then
            MsgBox "It's a dimension"
        End If
    End Sub