hexagon logo

Why is writing to PC-DMIS from VBA so slow?

I have two scripts that do very similar things : Read scan point data from PC-DMIS and then write scan point data back into PC-DMIS. One version of the script is written and executed in PC-DMIS basic. The other is written in Excel VBA and is executed through Excel by calling the macro from a very simple PC-DMIS script.

The PC-DMIS only version writes the scan data out to a temp file and then reads it back out of the file and writes to PC-DMIS. The excel version reads the data out into memory in a 2D array and then writes it back into PC-DMIS from the array, no external files involved.

I figured the Excel version would be faster since everything is in memory. It turns out that it is wicked slow and takes about 11 seconds to write a 64 point scan while the PC-DMIS version does it in less than 1 second. All the time is in the writing via the Puttext method. Reading from PC-DMIS into the array takes a fraction of a second but writing it back out into PC-DMIS takes 11 seconds. In the PC-DMIS only version both operations take a fraction of a second.

Is VBA just inherently slow for this kind of thing? Anyone else experienced this?
Parents
  • I meant to apply the Application.Visible property to the PcDmis object.

    The slowdown may be due to using a generic object in the function for the passed command. You could try the following and see if it helps any...

    Function WriteScanFromArray(ByRef Cmd As [COLOR="#FF0000"]PCDLRN.Command[/COLOR], ByRef ScanArry As Variant) As Boolean


    You will need the reference to Pcdlrn.tlb (PC_Dmis <version> Object Library).

    I have a VBA routine that extracts all data from all commands in a program(features, hits, alignment matrices, probes, legacy dims, FCF dims). Basically everything except derived coordinates for CLEARPLANE moves. It takes 3.7 seconds for a program with 1836 commands using Application.Visible = FALSE. Application.Visible=TRUE takes 33 seconds. This is on a box running @ 4.4 GHz. I haven't tried invoking code as you have in your example so cant predict what your results might be. Hope it helps.
Reply
  • I meant to apply the Application.Visible property to the PcDmis object.

    The slowdown may be due to using a generic object in the function for the passed command. You could try the following and see if it helps any...

    Function WriteScanFromArray(ByRef Cmd As [COLOR="#FF0000"]PCDLRN.Command[/COLOR], ByRef ScanArry As Variant) As Boolean


    You will need the reference to Pcdlrn.tlb (PC_Dmis <version> Object Library).

    I have a VBA routine that extracts all data from all commands in a program(features, hits, alignment matrices, probes, legacy dims, FCF dims). Basically everything except derived coordinates for CLEARPLANE moves. It takes 3.7 seconds for a program with 1836 commands using Application.Visible = FALSE. Application.Visible=TRUE takes 33 seconds. This is on a box running @ 4.4 GHz. I haven't tried invoking code as you have in your example so cant predict what your results might be. Hope it helps.
Children
No Data