Your Products have been synced, click here to refresh
...the conversion should go much faster if you convert the old VB6 into VB.Net. There are tools to make that transition somewhat painless.
PCCommands = PCPart.Commands; var traceName; var PCCommand; [COLOR="#FF0000"]var executedCommands;[/COLOR] [COLOR="#008000"]//What is this for?[/COLOR] [COLOR="#FF0000"]var executedCommandsCount;[/COLOR] [COLOR="#008000"]//What is this for?[/COLOR] for (int i = 1; i <= PCPart.Commands.Count; i++) { PCCommand = PCPart.Commands.Item(i); if (PCCommand != null) { if (PCCommand.IsTraceField) { traceName = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_NA ME, 0); switch (traceName) { case "Die Number": dieNumber = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VA LUE, 0); break; case "Part Number": partNumber = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VA LUE, 0); break; case "Cast Date": this.CastDate = PCCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.TRACE_VA LUE, 0); break; other case statements } } } } for (int i = 1; i <= PCPart.Commands.Count; i++) { PCCommand = PCPart.Commands.Item(i); executedCommands = PCPart.ExecutedCommands; executedCommandsCount = executedCommands.Count; if (PCCommand != null) { if (PCCommand.IsDimension) { pcCommandId = PCCommand.ID; axis = PCCommand.AxisLetter measured = PCCommand.Measured //write dieNumber, partNumber, pcCommandId, axis, measured etc, etc to file [COLOR="#008000"]\\What is happening here?[/COLOR] } } }
For Each PcCmd In PcCmds
for (int i = 1; i <= PCPart.Commands.Count; i++) { var PCCommand = PCPart.Commands.Item(i);
Just a thought.
Maybe the problem is in the 'for (...,PCPart.Commands.Count,...)' line. Does this query the number of commands in PC-DMIS for every iteration of the loop? If yes, this would slow it down (use a variable instead).
The big difference lies in
For Each PcCmd In PcCmds
vs.
for (int i = 1; i <= PCPart.Commands.Count; i++) { var PCCommand = PCPart.Commands.Item(i);
Indexing into .Commands seems to be quite a bit slower compared to getting the next one through For Each.... If the modern language doesn't support For Each, I think you can use a while-loop and PCCommand.Next (or something similar) instead.
The "write to file" part is probably also much slower in .NET than in VB6.
© 2025 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |