!   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)


! This macro will loop over the named selections with the prefix "ATTACH" and will
! use 174 elements via either CERIG/RBE3 style to fix the component at a single point
! The fixed point will be at NPILOTXX where XX is the number like "ATTACH3"
!
! NOTE:  This macro will only work on 3D geometries only and will only work if the 
!        named selection is scoped to a surface
!
!
! Set "NUMSEL" equal to the number of selections
! Set "CNTYPE" to 1 for a deformable surface constraint
!              to 2 for a rigid surface constraint
NUMSEL = 3
CNTYPE = 2
!
!
/prep7
*get,maxet,etyp,0,num,max
tid = maxet + 2
cid = maxet + 1

et,tid,170
et,cid,174

keyo,cid,12,5     ! bonded contact
keyo,cid,4,CNTYPE ! RBE3/CERIG style contact
keyo,cid,2,2      ! MPC contact

mat,cid
realnum = cid 

! get a unique coord system number; needed for centroid calc.
*get,maxcsys,cdsy,0,num,max
maxcsys=maxcsys+1
*if,maxcsys,lt,11,then
  maxcsys=11
*endif

*get,npilot,ndmx  ! get the highest number number defined

*do,i,1,NUMSEL
  cmsel,s,attach%i%
  !
  ! get the centroid of the nodes
  nwpave,all
  cswpla,maxcsys
  
  ! first create contacts on this guy
  realnum = realnum + 1    ! need to have a unique real for each pilot node
  real,realnum
  type,cid
  esurf
  
  ! now create the single pilot node
  csys,maxcsys
  n,,0,0,0
  csys,0

  ! create the single target element
  npilot=npilot+1
  npilot%i% = npilot   ! store the pilot node number for later 
  type,tid
  tshape,pilo 
  e,npilot 
  tshape    ! reset tshape in case used later

  ! fix all DOF on the pilot
  d,npilot,all

*enddo

! reselect everything back
nsel,all
esel,all

! go back into solution
/solu

  

  
  
  

  
  