I cleaned up my code a little more and made it a little more adjustible and the output is more informative now.
~Scott
!*****************************************************************
!Bolt Creates a bolt joint
!*****************************************************************
*GET,StartTime,ACTIVE,0,TIME,CPU
!-----------------------------------------------------------------
!Passed arguments
!-----------------------------------------------------------------
Xh =ARG1
Yh =ARG2
Zh =ARG3
Radius =ARG4
Thickness1 =ARG5
Thickness2 =ARG6
HolePlane =ARG7
ignoreNum =7 !Creates beams only every N Selected nodes.
MaxBeams =50 !Set to negative if you wish to create all beams
/NOPR
!-----------------------------------------------------------------
!Setup
!-----------------------------------------------------------------
/PREP7
ALLSEL
*GET,Last_ET,ETYP,,NUM,MAX
NextElem = Last_ET+1
*GET,Last_Real,RCON,,NUM,MAX
nReal = Last_Real+1
*GET,Last_Mat,MAT,,NUM,MAX
nMat = Last_Mat+1
*GET,mnode,NODE,,NUM,MAX
PointNode = mnode+1
*GET,csMax,CDSY,,NUM,MAX
*IF,csMax,LE,10,THEN
CSnum = 11
*ELSE
CSnum=csMax+1
*ENDIF
CSYS,0
WPCSYS,,0
!-----------------------------------------------------------------
!Element definition for beams
!-----------------------------------------------------------------
ET,NextElem,4 !Define element as a BEAM4 and set constants
KEYOPT,NextElem,6,1
r,nReal,8,8,8,8,8
MP,EX,nMat,1.000000e+07
MP,NUXY,nMat,0.300000e+00
MP,DENS,nMat,0.00000e+00
!-----------------------------------------------------------------
!Select nodes from one side to connect
!-----------------------------------------------------------------
WPOFFS,Xh,Yh,Zh
*IF,HolePlane,EQ,'XY',THEN
WPROTA,0,0,0
*ELSEIF,HolePlane,EQ,'XZ',THEN
WPROTA,0,-90,0
*ELSEIF,HolePlane,EQ,'YZ',THEN
WPROTA,0,0,90
*ENDIF
CSWPLA,CSnum,1
CSnum = CSnum+1
NALL
NSEL,S,LOC,X,0,Radius
NSEL,R,LOC,Z,0,Thickness1
CM,Set1,NODE
*GET,i1node,NODE,,COUNT
/COM,Nodes selected from first side = %i1node%.
!Return to the global coordinate system
NALL
!-----------------------------------------------------------------
!Select nodes for second side
!-----------------------------------------------------------------
NSEL,S,LOC,X,0,Radius
NSEL,R,LOC,Z,0,-Thickness2
CM,Set2,NODE
CM,Set2Full,NODE
*GET,i2node,NODE,,COUNT
/COM,Nodes selected from second side = %i2node%.
!Return to the global coordinate system
CSYS,0
WPCSYS,,0
!-----------------------------------------------------------------
!Connect nodes from both sides
!-----------------------------------------------------------------
TYPE,NextElem
REAL,nReal
MAT,nMat
Other1=1
Other2=1
BeamCount=0
*GET,i2node,NODE,,COUNT
CMSEL,S,Set1
*GET,i1node,NODE,,COUNT
*DOWHILE,i1node
/NOPR
CMSEL,S,Set1
*GET,Low1,NODE,,NUM,MIN
NSEL,U,NODE,,Low1
CM,Set1,NODE
i1node=i1node-1
*IF,Other1,LT,IgnoreNum,THEN
Other1=Other1+1
*CYCLE
*ENDIF
CMSEL,S,Set2Full
CM,Set2,NODE
*GET,i2node,NODE,,COUNT
*DOWHILE,i2node
/NOPR
CMSEL,S,Set2
*GET,Low2,NODE,,NUM,MIN
NSEL,U,NODE,,Low2
CM,Set2,NODE
i2node=i2node-1
*IF,Other2,LT,ignoreNum,THEN
Other2=Other2+1
*CYCLE
*ENDIF
*IF,Low1,EQ,Low2,THEN
*CYCLE
*ENDIF
E,Low1,Low2
BeamCount=BeamCount+1
*IF,BeamCount,EQ,MaxBeams,THEN
i1node=0
i2node=0
*CYCLE
*ENDIF
Other2=1
Other1=1
*ENDDO
*ENDDO
/NOPR
*GET,EndTime,ACTIVE,0,TIME,CPU
CalcTime=EndTime-StartTime
/COM,-----------------------------------------------------------------
/COM,End with %BeamCount% beams created in %CalcTime% seconds.
/COM,-----------------------------------------------------------------
!Return to the global coordinate system
CSYS,0
WPCSYS,,0
ALLSEL
FINISH
/GOPR
/EOF