total_nodes=0
ESEL,S,ENAME,,179 !select all pretension elements PRETS179
CM,bp_comp,ELEM !creates a component for the bolt pretension elements
NSLE,S,POS,3 !show/select head nodes for the pretension elements
CM,bphn_comp,NODE !creates a component for the bolt pretension head nodes
*GET,nr_nodes,NODE,0,COUNT !getting the number of head nodes
total_nodes=nr_nodes
*GET,NR_STEPS,ACTIVE,0,SET,NSET !get total number of time steps
*DIM,nids,ARRAY,nr_nodes,7 !array to store the forces
*DIM,bolt_force,ARRAY,NR_STEPS,nr_nodes+1 !array to store bolt forces
*IF,total_nodes,GE,1,THEN !if at least one bolt pretension exist in the model
*DO,i,1,NR_STEPS
SET,,,,,,,i
*GET,time,ACTIVE,0,SET,TIME
bolt_force(i,1)=time
*DO,q,1,nr_nodes
column = q+1
*GET,nodes,NODE,0,NUM,MIN !get minimum node number
*GET,nx,NODE,nodes,LOC,X !gets x coordinate of the node
*GET,ny,NODE,nodes,LOC,Y !gets y coordinate of the node
*GET,nz,NODE,nodes,LOC,Z !gets z coordinate of the node
NSEL,S,NODE,,nodes !select the identified head node
my_force = 0
*GET,my_force,NODE,nodes,RF,FX !gets the bolt force
bolt_force(i,column)=my_force
CM,pproc_node,NODE !creates component for the post processed head nodes
ESLN !selects the pretnesion elements which are connected to the head node
CM,pproc_sec,ELEM !creates component for the post processed pretension elements
my_elem=ELNEXT(0) !select the first element from the list
*GET,bpe_type,ELEM,my_elem,ATTR,TYPE !get element type of the selected pretention element
NSLE
ESLN
my_elem=ELNEXT(0) !select the first element from the list
!*GET,be_type,ELEM,my_elem,ATTR,TYPE !get element type of the selected bolt element (issue with this approac when the bolt have two type of elements tetras and hex as they have different element id)
*GET,mat_id,ELEM,my_elem,ATTR,MAT !get material id of the selected solid bolt element
nids(q,1)=q
nids(q,2)=nodes
nids(q,3)=mat_id
nids(q,4)=bpe_type
nids(q,5)=nx
nids(q,6)=ny
nids(q,7)=nz
!unselect processed elements and nodes
CMSEL,S,bp_comp
CMSEL,U,pproc_sec
CM,bp_comp,ELEM
CMSEL,S,bphn_comp
CMSEL,U,pproc_node
CM,bphn_comp,NODE
*GET,rem_nr_nodes,NODE,0,COUNT
!/com, **rem_nr_nodes: %rem_nr_nodes%
CMSEL,S,bphn_comp
*ENDDO
ALLSEL
ESEL,S,ENAME,,179 !select all pretension elements PRETS179
CM,bp_comp,ELEM !creates a component for the bolt pretension elements
NSLE,S,POS,3 !show/select head nodes for the pretension elements
CM,bphn_comp,NODE
*ENDDO
*ENDIF