Marked set editing with Basic automation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Marked set editing with Basic automation

    Hello,

    I often use Basic automation to edit my programs. Most of the time, I need to add some commands in all programs used in the company. As that makes hundreds of programs, it is always a long job.
    My problem is with marked sets.

    In the shop the programs are used in "operator mode", so marked sets are mandatory. And if you add a command through Basic, it will not be markes for execution in the marked set.

    Finally, I have found a solution I present here.

    First, to access to marked sets through Basic :

    Code:
     Set pcpart = pcapp.PartPrograms.Open( _
    "program.PRG", _
    "Offline")
    
    Set cmds = pcpart.Commands
    cmds.InsertionPointAfter cmds(87) 'just an example
    
    pcpart.ClearExecutionMarkedSet
    pcpart.SetExecutionBlock pcpart.Commands(1), pcpart.Commands(2)
    pcpart.Execute
    
    ' add a command. here, variable assignement with nothing in it
    Set cmd = cmds.Add(ASSIGNMENT, True)
    cmd.PutText "MA_VAR", DEST_EXPR, 0
    cmd.PutText "", SRC_EXPR, 0
    cmd.Marked = True
    You need to execute at least one command to really set the marked set

    Now, loop on all marked sets to mark the new command :
    Code:
        i = 0
        res1 = ""
        retVal = pcpart.GetMarkedSetName(i, res) 'initialize with first marked set
        While res <> res1
            pcpart.SetExecutionMarkedSet res
            pcpart.SetExecutionBlock pcpart.Commands(1), pcpart.Commands(2)
            pcpart.Execute
            Application.Wait Now + TimeValue("00:00:01")
            cmd.Marked = True
    
            i = i + 1
            res1 = res
            retVal = pcpart.GetMarkedSetName(i, res) ' if no new marked set : res will not bne changed => loop end
        Wend
    Edit : CODE /CODE tags

  • #2
    Don't really use marked sets or operator myself, but thank you for sharing.

    There's a Code subforum that this might have fit better into by the way.
    Automettech - Automated Metrology Technology

    Comment


    • #3
      Originally posted by NinjaBadger View Post
      There's a Code subforum that this might have fit better into by the way.
      OK can an admin move this post, or should I link / recreate a similar post in the Code subforum ?

      Comment

      Related Topics

      Collapse

      Working...
      X