Need macro for merging multiple SUBE's

 

  • if (!!CE.Type NEQ 'SUBE') then
     !!alert.Message('You have to be located on a SUBE where you want to move other primitives')
     return
    endif
    --keep names
    !getCESUBERefno = !!CE.Refno.String()
    !getOwnerName = !!CE.Owner.Name
    --get collection
    VAR !getOtherSube COLLECT ALL SUBE WITH ( REFNO NEQ $!getCESUBERefno ) FOR $!getOwnerName
    !getMems = object array()
    !getMems.Clear()
    !getPos = object array()
    !getPos.Clear()
    do !x from 1 to !getOtherSube.Size()
      $!getOtherSube[$!x]
      VAR !getMems APPEND EVAL ( STRING( REFNO ) ) FOR ALL ( SUBE MEM ) FOR CE
      VAR !getPos APPEND EVAL ( STRING ( POS WRT /* ) ) FOR ALL ( SUBE MEM ) FOR CE
    enddo
    $!getCESUBERefno
    do !x from 1 to !getMems.Size()
     INCLUDE $!getMems[$!x]
     $!getMems[$!x]
     POSITION $!getPos[$!x] WRT WORLD
     OWNER
     
    enddo
    !isDelete = !!Alert.Confirm('Delete empty SUBEs?')
    if (!isDelete EQ 'YES') then
     do !x from 1 to !getOtherSube.Size()
      $!getOtherSube[$!x]
      DELETE SUBE
     enddo
    endif
    $!getCESUBERefno




    check before savework
  • or new variant with option whether to create new sube or move to existing

    !isNew = !!Alert.Confirm('Create new SUBE - YES, Use existing one - NO')
    if (!isNew EQ 'YES') then
     if (!!CE.Type NEQ 'EQUI') then
    !!alert.Message('You have to be located on EQUI to create new SUBE')
       return
     endif
    endif
    if (!isNew EQ 'NO') then
     if (!!CE.Type NEQ 'SUBE') then
        !!alert.Message('You have to be located on SUBE where you want to move other primitives')    return
     endif
    endif
    --keep names
    !getCERefno = !!CE.Refno.String()
    !getOwnerName = !!CE.Owner.Name
    --get collection
    if (!isNew EQ 'YES') then
     VAR !getOtherSube COLLECT ALL SUBE FOR $!getCERefno
    endif
    if (!isNew EQ 'NO') then
     VAR !getOtherSube COLLECT ALL SUBE WITH ( REFNO NEQ $!getCERefno ) FOR $!getOwnerName
    endif
    !getMems = object array()
    !getMems.Clear()
    !getPos = object array()
    !getPos.Clear()
    do !x from 1 to !getOtherSube.Size()
      $!getOtherSube[$!x]
      VAR !getMems APPEND EVAL ( STRING( REFNO ) ) FOR ALL ( SUBE MEM ) FOR CE
      VAR !getPos APPEND EVAL ( STRING ( POS WRT /* ) ) FOR ALL ( SUBE MEM ) FOR CE
    enddo
    $!getCERefno
    if (!isNew EQ 'YES') then
     NEW SUBE
    endif
    do !x from 1 to !getMems.Size()
     INCLUDE $!getMems[$!x]
     $!getMems[$!x]
     POSITION $!getPos[$!x] WRT WORLD
     OWNER
     
    enddo
    !isDelete = !!Alert.Confirm('Delete empty SUBEs?')
    if (!isDelete EQ 'YES') then
     do !x from 1 to !getOtherSube.Size()
      $!getOtherSube[$!x]
      DELETE SUBE
     enddo
    endif
    $!getCERefno

  • with orientation

    !isNew = !!Alert.Confirm('Create new SUBE - YES, Use existing one - NO')
    if (!isNew EQ 'YES') then
     if (!!CE.Type NEQ 'EQUI') then
    !!alert.Message('You have to be located on EQUI to create new SUBE')
       return
     endif
    endif
    if (!isNew EQ 'NO') then
     if (!!CE.Type NEQ 'SUBE') then
        !!alert.Message('You have to be located on SUBE where you want to move other primitives')    return
     endif
    endif
    --keep names
    !getCERefno = !!CE.Refno.String()
    !getOwnerName = !!CE.Owner.Name
    --get collection
    if (!isNew EQ 'YES') then
     VAR !getOtherSube COLLECT ALL SUBE FOR $!getCERefno
    endif
    if (!isNew EQ 'NO') then
     VAR !getOtherSube COLLECT ALL SUBE WITH ( REFNO NEQ $!getCERefno ) FOR $!getOwnerName
    endif
    !getMems = object array()
    !getMems.Clear()
    !getPos = object array()
    !getPos.Clear()
    !getOri = object array()
    !getOri.Clear()
    do !x from 1 to !getOtherSube.Size()
      $!getOtherSube[$!x]
      VAR !getMems APPEND EVAL ( STRING( REFNO ) ) FOR ALL ( SUBE MEM ) FOR CE
      VAR !getPos APPEND EVAL ( STRING ( POS WRT /* ) ) FOR ALL ( SUBE MEM ) FOR CE
      VAR !getOri APPEND EVAL ( STRING ( ORI WRT /* ) ) FOR ALL ( SUBE MEM ) FOR CE
     
    enddo
    $!getCERefno
    if (!isNew EQ 'YES') then
     NEW SUBE
    endif
    do !x from 1 to !getMems.Size()
     INCLUDE $!getMems[$!x]
     $!getMems[$!x]
     POSITION $!getPos[$!x] WRT WORLD
     ORIENTATION $!getOri[$!x] WRT WORLD
     OWNER
     
    enddo
    !isDelete = !!Alert.Confirm('Delete empty SUBEs?')
    if (!isDelete EQ 'YES') then
     do !x from 1 to !getOtherSube.Size()
      $!getOtherSube[$!x]
      DELETE SUBE
     enddo
    endif
    $!getCERefno

  • it is working on mine. I can't help not seeing your situation or at least screenshots
  • I wish i could see this equipment :) same ori and positions except up. If you can send data listing then i will check in your exact situation. Otherwise i can't fix. It is working on mine. I hope you used last ode
  • Need macro for merging multiple SUBE's to one SUBE without disturbing primitives ORI or POS
  • @RUAV
    thanks alot for the code
    tried this, I think position is working, but not orientation
    I guess need to update the code with orientation
  •  

      TYPE  NAME          POS WRT /*                           ORI WRT /*            
      EQUI  =XX/33757  W 29994.715 S 11681.208 U 39332.102  Y is W 39 N and Z is U
      SUBE  =XX/33758  W 29994.715 S 11681.208 U 32511.102  Y is W 39 N and Z is U
      SUBE  =XX/33761  W 29994.715 S 11681.208 U 45407.102  Y is W 39 N and Z is U
      SUBE  =XX/33764  W 29994.715 S 11681.208 U 43795.102  Y is W 39 N and Z is U
      SUBE  =XX/33767  W 29994.715 S 11681.208 U 42183.102  Y is W 39 N and Z is U
      SUBE  =XX/33770  W 29994.715 S 11681.208 U 40571.102  Y is W 39 N and Z is U
      SUBE  =XX/33773  W 29994.715 S 11681.208 U 38959.102  Y is W 39 N and Z is U
      SUBE  =XX/33776  W 29994.715 S 11681.208 U 37347.102  Y is W 39 N and Z is U
      SUBE  =XX/33779  W 29994.715 S 11681.208 U 35735.102  Y is W 39 N and Z is U
      SUBE  =XX/33782  W 29994.715 S 11681.208 U 34123.102  Y is W 39 N and Z is U
      SUBE  =XX/33785  W 29994.715 S 11681.208 U 39332.102  Y is W 39 N and Z is U