hexagon logo

Add Command - specific location

I have a basic script I want to insert an alignment command into the PCDMIS program at a given location. I use a comment to find the location, then InsertionPointAfter method before adding the command.

When the script is run from a menu button or the play button from the script editor, the added command ends up where I want it to. If I call the script from the PCDMIS program the added command ends up as part of the script group which is not the correct location.

Anyone know how to make this behave the same when executed from within a PCDMIS program as it does when run from a command button in the menu or played from the script editor?

Sample code:

Set DmisApp = CreateObject("PCDLRN.Application")
Set DmisPart = DmisApp.ActivePartProgram
Set DmisCommands = DmisPart.Commands
RstTrigger = False
CycleCnt=1

For Each Cmd In DmisCommands
If Cmd.IsComment Then
If RstTrigger = False Then
If Cmd.CommentCommand.GetLine (1) = "RST_INSERT" Then
RstTrigger = True
End If
End If
End If
If RstTrigger Then
If CycleCnt = 1 Then
DmisCommands.InsertionPointAfter Cmd
Set DmisCommand = DmisCommands.Add(RECALL_ALIGN, True)
DmisCommand.Marked = True
retval = DmisCommand.SetToggleString (1, INTERNAL_EXTERNAL, 0)
retval = DmisCommand.PutText ("STARTUP", REF_ID, 0)
CycleCnt = CycleCnt +1
End If
End If
Next
DmisPart.RefreshPart
End Sub


Thanks,
Parents Reply Children
No Data