• Usefull when branch names are messed up. Just wanted to share this simple beginner macro.

    -- COLLECTING PIPE INFO --
    PIPE
    VAR !PIPENAME NAME
    VAR !BRANCHES COLL ALL BRAN for CE

    -- RENAME BRANCHES --
    GOTO MEM
    NAME $!PIPENAME/B1

    DO !n FROM 2 TO !BRANCHES.SIZE() BY 1
    NEXT
    NAME $!PIPENAME/B$!n
    ENDDO
  • you can also try to add "UNNAME" command to all brach first in case name is already used to prevent error. (example: NAME $!PIPENAME/B1 is already used but it is not modeled as first branch)

    Also make sure that the branch is in proper hierarchy to prevent some error.
  • Thanks!

    -----------------------------------------------
    -- MACRO TO RENAME BRANCHES OF SELECTED PIPE --
    -----------------------------------------------

    -- COLLECTING PIPE INFO --
    PIPE
    VAR !PIPENAME NAME
    VAR !BRANCHES COLL ALL BRAN for CE
    -- UNNAME ALL BRANCHES --
    GOTO MEM
    UNNAME
    DO !N FROM 2 TO !BRANCHES.SIZE() BY 1
    NEXT
    UNNAME
    ENDDO

    -- RENAME BRANCHES --
    PIPE
    GOTO MEM
    NAME $!PIPENAME/B1
    DO !X FROM 2 TO !BRANCHES.SIZE() BY 1
    NEXT
    NAME $!PIPENAME/B$!X
    ENDDO
  • how to run same macro from zone.  I want to change all zone member pipe branches
  • just make current element to zone or site and then add loop for pipe
    please see macro below that will rename all branch under current element.
    -----------------------------------------------
    -- MACRO TO RENAME BRANCHES OF SELECTED PIPE --
    -----------------------------------------------

    --COLLECT ALL PIPE IN CURRENT ELEMENT


    VAR !PIPES COLLECT ALL PIPE FOR CE

    IF !PIPES.SIZE() LT 1 THEN
       $P No Pipe on Current Element
       RETURN
    ENDIF

    DO !Y FROM 1 TO !PIPES.SIZE()
       
        $!PIPES[$!Y]

        -- COLLECTING PIPE INFO --
        PIPE
        VAR !PIPENAME NAME
        VAR !BRANCHES COLL ALL BRAN for CE
        -- UNNAME ALL BRANCHES --
        GOTO MEM
        UNNAME
        DO !N FROM 2 TO !BRANCHES.SIZE() BY 1
           NEXT
           UNNAME
        ENDDO

        -- RENAME BRANCHES --
        PIPE
        GOTO MEM
        NAME $!PIPENAME/B1
        DO !X FROM 2 TO !BRANCHES.SIZE() BY 1
            NEXT
            NAME $!PIPENAME/B$!X
        ENDDO
    ENDDO
  • other macro

    !Backtoce = REF
    !Type = Type

    if ('$!Type' eq 'PIPE' or '$!Type' eq 'ZONE' or '$!Type' eq 'CONVEY') then
    var !Pipelist Collect all PIPE for ce
    var !Unbranlist Collect all BRAN for ce
     elseif ('$!Type' eq 'SITE' or '$!Type' eq 'WORL') then
     !!alert.Warning (|Pleases Don't use this macro on site or world|)
     
      else
       PIPE
       var !Pipelist Collect all PIPE for ce
       var !Unbranlist Collect all BRAN for ce
    endif

    do !A index !Unbranlist
      var !Unbrancol $!Unbranlist[$!A]
    $!Unbrancol
    unname
    enddo
    do !B index !Pipelist
    var !Pipecec $!Pipelist[$!B]
    $!Pipecec
    var !Rebranlist Collect all BRAN for ce
    var !FNo (0)

     do !C index !Rebranlist
      var !Rebrancol $!Rebranlist[$!C]
      $!Rebrancol
      var !Pipe name of pipe
      var !FNo (!FNo + 1)
      var !Tfno |B$!FNo|
      var !Nbname |$!Pipe/$!Tfno|
      rename $!Nbname
       Handle any
        $!Nbname unname
        $!Rebrancol
        rename $!Nbname
       endhandle
     
     enddo  
     
    enddo
    $!Backtoce