hexagon logo

Basic Script for Execution

Hello all,

Before I spend a bunch of time digging into this I figured I would reach out to the community fist.  Somebody may already have created the kind of script.  My company has decided to get away from Datapage since it is no longer supported.  All reports end up put into an excel file, so that is my end goal.  I want a script that will execute all dimensions (all dimensions in a single execution).  I will simply place that at the end of our thousands of existing programs with the excel form report.  This would give me the ability to not have to install excel on 12 machines utilizing the excel form report within DMIS.  (already have a manipulated script that maps everything out to an excel file)  I just want to be able to execute the script and excel form report code together, so there is always full complete report uploaded.  I want the operators to be able to correct any errors as needed while running and then always include a complete report so we are not combining multiple reports together or appending the single report.  To put simply I just want the ability to create every dimension in the same execution (dimensions only).

Regards,

Matt Eaders

  • It must have been the same one lol the whole things pretty much needed mapped out.  Yes! that may be useful as that was one avenue of the script I was exploring.  I would appreciate it very much if you could!

  • This is something I threw together just for practice for another user on the forum. It currently is set to only collect features, but can easily be changed to contain DimensionCommands If you need help with this you can always send me a DM.

    Edit: I added the functionality to execute the dimension commands again after executing the selected code block to help update dimensions. Included a check method to ignore "DATDEF" as they are considered DimensionCommands

    Sub Main()
        Dim DmisApp As Object
        Set DmisApp = CreateObject("PCDLRN.Application")
        Dim DmisParts As Object
        Set DmisParts = DmisApp.PartPrograms
        Dim DmisPart As Object
        Set DmisPart = DmisApp.ActivePartProgram
        Dim DmisCmds As Object
        Set DmisCmds = DmisPart.Commands
        Dim DmisCmd As Object
        Dim EditWin As Object
        Set EditWin = DmisPart.EditWindow
        Dim StartCmd As Object
        Dim EndCmd As Object
        Dim FeatureList$(99999)
    
    Fcntr = 0    
    For Each DmisCmd In DmisCmds
            If DmisCmd.IsMeasuredFeature Then
    	' Measured (learned) feature
                FeatureList(Fcntr) = DmisCmd
                Fcntr = Fcntr + 1
            End If        
            If DmisCmd.IsDCCFeature Then
    	' Autofeature (flagged As DCC feature)
                 FeatureList(Fcntr) = DmisCmd
                 Fcntr = Fcntr + 1
            End If
    Next DmisCmd 'Get the Next Feature
    
    'Dialog Box Parameters: X, Y (position), DX, DY (size), Title, VariableName.
    Begin Dialog DIALOG_1 31,48, 155, 80, "Select Features For Execution Block"
      Text 10,8,50,12, "Start Command"
      Text 80,8,50,12, "End Command"
      DropListBox 10,20,60,80, FeatureList$(), .ListBox1
      DropListBox 80,20,60,80, FeatureList$(), .ListBox2
      PushButton 10,40,50,12, "Execute Block", .PointsBtn
      PushButton 80,40,50,12, "Cancel", .CancelBtn
    End Dialog
    
    Dim Dlg1 As DIALOG_1
    button = Dialog(Dlg1)
     'button 1 = Execute 
     'button 2 = Cancel
    
    If button = 1 Then
    
      Set StartCmd = DmisCmds.Item(FeatureList(Dlg1.Listbox1))
      Set EndCmd = DmisCmds.Item(FeatureList(Dlg1.Listbox2))
    
      EditWin.Visible = True
      EditWin.selectCommands StartCmd, EndCmd
      DmisPart.SetExecutionBlock StartCmd, EndCmd
      DmisPart.Execute
    End If
    
    If button = 2 Then 'Cancel Execution
      GoTo 2
    End If
    
    'Execute dimension commands after block
    Fcntr = 0
    For Each DmisCmd In DmisCmds
            'Tells script To ignore Any datum definitions As they are considered Dimension commands
            If DmisCmd.IsDimension And Not DmisCmd.Type = DATDEF_COMMAND Then
                FeatureList(Fcntr) = DmisCmd
                Fcntr = Fcntr + 1
            End If
    Next DmisCmd
    Set StartCmd = DmisCmds.Item(FeatureList(0))
    Set EndCmd = DmisCmds.Item(FeatureList(Fcntr - 1))
    EditWin.Visible = True
    EditWin.selectCommands StartCmd, EndCmd
    DmisPart.SetExecutionBlock StartCmd, EndCmd
    DmisPart.Execute
    
    2:
        Set DmisCmd = Nothing
        Set DmisCmds = Nothing
        Set DmisPart = Nothing
        Set DmisParts = Nothing
        Set DmisApp = Nothing
        Set EditWin = Nothing
    
    End Sub