!   Commands inserted into this file will be executed just prior to the Ansys SOLVE command.
!   These commands may supercede command settings set by Workbench.

!   Active UNIT system in Workbench when this object was created:  Metric (mm, kg, N, C, s)


! Perform a Craig-Bampton type solution.  Loop over the pilot nodes assuming
! a name of "NPILOTxx" where xx is a number.  After the solution is over
! the rst will contain N result sets where N=NSUMSEL*6
!
! Note:  For this macro to work, you must keep the ANSYS file generated
!        This is set in the "Options" panel 
!
! Set "NUMSEL" equal to the number of selections
NUMSEL = 3

! first create a component holding all the fix for ease of use to fix later
nsel,none
*do,i,1,NUMSEL
  nsel,a,node,,npilot%i%
*enddo
cm,allfix,node
nsel,all 

! Do NUMSEL*6 - 1 solutions in this macro (the last solution will be performed
! by ANSYS as part of the regular WB solution

numSol = NUMSEL*6 - 1

currSol=0

*do,i,1,NUMSEL
  currFix = npilot%i%
  *do,j,1,6
   !
   ! move the current DOF by 1 and fix the rest
   d,allfix,all
   !
   *if,j,eq,1,then
     d,currFix,ux,1
   *elseif,j,eq,2,then
     d,currFix,uy,1
   *elseif,j,eq,3,then
     d,currFix,uz,1
   *elseif,j,eq,4,then
     d,currFix,rotx,1
   *elseif,j,eq,5,then
     d,currFix,roty,1
   *elseif,j,eq,6,then
     d,currFix,rotz,1
   *endif

   currSol=currSol+1

   *if,currSol,le,numSol,then
     solve       ! solve
   *endif
  
  *enddo
*enddo


