*get,prkey_,active,0,prkey
/nopr
prof=arg1
n_thrd=arg2
thrd_ln=arg3
n_inch=arg4
stndrd=arg5
d_mjr=arg6
d_min=arg7
lstart=lm_prev
*get,zzzz,parm,stndrd,type
*if,zzzz,eq,0,then
stndrd='un'
*endif
*if,n_thrd,eq,0,then
n_thrd=nint(thrd_ln*n_inch)+1
*endif
p_thrd=1/n_inch
*if,d_mjr,eq,0,then
h_thrd=(sqrt(3)/2)*p_thrd
*else
h_thrd=(d_mjr-d_min)/2
*endif
thrd_ang=(2*atan((p_thrd/2)/h_thrd))*dconv
r_thrd=0.15011*p_thrd
*go,:skip
*if,prof,eq,'x',then
*get,thrd_cs,active,,csys
csn=csn+1
ndselcs=csn
clocal,ndselcs,0,0,0,0,(90-thrd_ang/2),0,0
csys,thrd_cs
*if,stndrd,eq,'j',then
*do,iii,0,2*n_thrd,1
*if,mod(iii,2),eq,0,then
k,,iii*(p_thrd/2),0,0
*elseif,mod(iii,2),eq,1,then
k,,iii*(p_thrd/2),h_thrd,0
init_entity_num
k_tip=km
*endif
init_entity_num
*if,iii,gt,0,then
*if,mod(iii,2),eq,0,then
lstr,km,k_tip
*elseif,mod(iii,2),eq,1,then
lstr,km-1,k_tip
*endif
*endif
init_entity_num
*if,iii,ge,3,then
*if,mod(iii,2),eq,1,then
lfillt,lm-1,lm,r_thrd
*endif
*endif
init_entity_num
*enddo
r_width=p_thrd/8
root_h=(r_width/2)/tan((thrd_ang/2)*rconv)
r2edge=0.649519*p_thrd
h_thrd2=root_h+r2edge
k,,0,h_thrd2,0
k,,kx(km),h_thrd2,0
create_lines
lsel,selv,loc,x,(0.5*p_thrd),(n_thrd-0.5)*p_thrd
lsel,r,loc,y,(r_thrd/cos(thrd_ang*rconv))*(sin(thrd_ang*rconv))**2,h_thrd
lsel,r,loc,z,0
lsel,a,line,,lm-1
lsel,a,line,,lm-(2*n_thrd+n_thrd-1)
ln_part_ln,lm
init_entity_num
*do,iij,1,2*n_thrd-1,2
lstr,km-(2*n_thrd-iij),km-(2*n_thrd-iij-1)
*enddo
init_entity_num
*if,d_mjr,eq,0,then
lsel,selv,loc,y,1.015*((7/8)*h_thrd),h_thrd
*else
lsel,selv,loc,y,1.015*(h_thrd2),h_thrd
*endif
lsel,r,loc,x,0,n_thrd*p_thrd
lsel,r,loc,z,0
ldele,all,,,1
init_entity_num
ksel,selv,loc,x,0
ksel,r,loc,y,0
ksel,r,loc,z,0
get_max_entity
k1_thrd=km
init_entity_num
ksel,selv,loc,x,n_thrd*p_thrd
ksel,r,loc,y,0
ksel,r,loc,z,0
get_max_entity
k2_thrd=km
init_entity_num
*elseif,stndrd,eq,'un',then
*do,ijk,0,2*n_thrd,1
*if,mod(ijk,2),eq,0,then
k,,ijk*(p_thrd/2),0,0
*elseif,mod(ijk,2),eq,1,then
k,,ijk*(p_thrd/2),h_thrd,0
*endif
init_entity_num
*if,ijk,gt,0,then
lstr,km-1,km
*endif
init_entity_num
*enddo
k,,0,h_thrd/4,0
k,,kx(km),h_thrd/4,0
create_lines
*if,d_mjr,eq,0,then
k,,0,(7/8)*h_thrd,0
k,,kx(km),(7/8)*h_thrd,0
*else
r_width=p_thrd/4
root_h=(r_width/2)/tan((thrd_ang/2)*rconv)
r2edge=(d_mjr-d_min)/2
h_thrd2=root_h+r2edge
k,,0,h_thrd2,0
k,,kx(km),h_thrd2,0
*endif
create_lines
lsel,s,line,,lm-1
cm,lcut,line
init_entity_num
lsel,s,line,,lm-(2*n_thrd+1),lm
ln_part_ln,lcut
init_entity_num
ldele,lcut,,,1
init_entity_num
*do,iij,1,4*n_thrd-2,2
*if,iij,eq,1,then
counter=0
incrm=3
*endif
counter=counter+1
lstr,km-(4*n_thrd-1)+iij,km-(4*n_thrd-1)+(iij+1)
*get,lm,line,,num,max
*if,mod(counter,2),eq,0,then
lfillt,lm,lstart+(2*n_thrd+5)+incrm,.0010
lfillt,lm,lstart+(2*n_thrd+5)+incrm+3,.0010
incrm=incrm+6
*endif
*enddo
init_entity_num
lsel,selv,loc,y,0,0.985*(h_thrd/4)
*if,d_mjr,eq,0,then
lsel,a,loc,y,1.015*((7/8)*h_thrd),h_thrd
*else
lsel,selv,loc,y,1.015*(h_thrd2),h_thrd
*endif
lsel,r,loc,x,0,n_thrd*p_thrd
lsel,r,loc,z,0
ldele,all,,,1
init_entity_num
ksel,selv,loc,x,(h_thrd/4)/tan(thrd_ang*rconv)
ksel,r,loc,y,h_thrd/4
ksel,r,loc,z,0
get_max_entity
k1_thrd=km
init_entity_num
ksel,selv,loc,x,(n_thrd*p_thrd)-((h_thrd/4)/tan(thrd_ang*rconv))
ksel,r,loc,y,h_thrd/4
ksel,r,loc,z,0
get_max_entity
k2_thrd=km
init_entity_num
*endif
k,,kx(k1_thrd),-1.3*p_thrd,0
k,,kx(k2_thrd),-1.3*p_thrd,0
create_lines
lstr,km-1,k1_thrd
lstr,km,k2_thrd
init_entity_num
isolate_lines
al,all
init_entity_num
lplot
*endif
*if,prof,eq,'i',then
*if,stndrd,eq,'j',then
*do,iii,0,2*n_thrd,1
*if,mod(iii,2),eq,0,then
k,,iii*(p_thrd/2),0,0
*elseif,mod(iii,2),eq,1,then
k,,iii*(p_thrd/2),h_thrd,0
init_entity_num
k_tip=km
*endif
init_entity_num
*if,iii,gt,0,then
*if,mod(iii,2),eq,0,then
lstr,km,k_tip
*elseif,mod(iii,2),eq,1,then
lstr,km-1,k_tip
*endif
*endif
init_entity_num
*if,iii,ge,3,then
*if,mod(iii,2),eq,1,then
lfillt,lm-1,lm,r_thrd
*endif
*endif
init_entity_num
*enddo
r_width=p_thrd/8
root_h=(r_width/2)/tan((thrd_ang/2)*rconv)
r2edge=0.649519*p_thrd
h_thrd2=root_h+r2edge
k,,0,h_thrd2,0
k,,kx(km),h_thrd2,0
create_lines
lsel,selv,loc,x,(0.5*p_thrd),(n_thrd-0.5)*p_thrd
lsel,r,loc,y,(r_thrd/cos(thrd_ang*rconv))*(sin(thrd_ang*rconv))**2,h_thrd
lsel,r,loc,z,0
lsel,a,line,,lm-1
lsel,a,line,,lm-(2*n_thrd+n_thrd-1)
ln_part_ln,lm
init_entity_num
*do,iij,1,2*n_thrd-1,2
lstr,km-(2*n_thrd-iij),km-(2*n_thrd-iij-1)
*enddo
init_entity_num
*if,d_mjr,eq,0,then
lsel,selv,loc,y,1.015*((7/8)*h_thrd),h_thrd
*else
lsel,selv,loc,y,1.015*(h_thrd2),h_thrd
*endif
lsel,r,loc,x,0,n_thrd*p_thrd
lsel,r,loc,z,0
ldele,all,,,1
init_entity_num
ksel,selv,loc,x,0
ksel,r,loc,y,0
ksel,r,loc,z,0
get_max_entity
k1_thrd=km
init_entity_num
ksel,selv,loc,x,n_thrd*p_thrd
ksel,r,loc,y,0
ksel,r,loc,z,0
get_max_entity
k2_thrd=km
init_entity_num
*elseif,stndrd,eq,'un',then
*do,ijk,0,2*n_thrd,1
*if,mod(ijk,2),eq,0,then
k,,ijk*(p_thrd/2),0,0
*elseif,mod(ijk,2),eq,1,then
k,,ijk*(p_thrd/2),h_thrd,0
*endif
init_entity_num
*if,ijk,gt,0,then
lstr,km-1,km
*endif
init_entity_num
*enddo
k,,0,(0.250*p_thrd)/(2*tan((thrd_ang/2)*rconv)),0
k,,kx(km),(0.250*p_thrd)/(2*tan((thrd_ang/2)*rconv)),0
create_lines
*if,d_mjr,eq,0,then
k,,0,h_thrd-(0.041667*p_thrd)/(2*tan((thrd_ang/2)*rconv)),0
k,,kx(km),h_thrd-(0.041667*p_thrd)/(2*tan((thrd_ang/2)*rconv)),0
*else
r_width=p_thrd/4
root_h=(r_width/2)/tan((thrd_ang/2)*rconv)
r2edge=(d_mjr-d_min)/2
h_thrd2=root_h+r2edge
k,,0,h_thrd2,0
k,,kx(km),h_thrd2,0
*endif
create_lines
lsel,s,line,,lm-1,lm
cm,lcut,line
init_entity_num
lsel,s,line,,lm-(2*n_thrd+1),lm
ln_part_ln,lcut
init_entity_num
ldele,lcut,,,1
init_entity_num
*do,iij,1,4*n_thrd-2,2
*if,iij,eq,1,then
counter=0
incrm=3
*endif
counter=counter+1
lstr,km-(4*n_thrd-1)+iij,km-(4*n_thrd-1)+(iij+1)
*get,lm,line,,num,max
*if,mod(counter,2),eq,0,then
lfillt,lm,lstart+(2*n_thrd+5)+incrm,.0050
lfillt,lm,lstart+(2*n_thrd+5)+incrm+3,.0050
incrm=incrm+6
*endif
*enddo
init_entity_num
lsel,selv,loc,y,0,0.985*(0.250*p_thrd)/(2*tan((thrd_ang/2)*rconv))
*if,d_mjr,eq,0,then
lsel,a,loc,y,1.015*(h_thrd-(0.041667*p_thrd)/(2*tan((thrd_ang/2)*rconv))),h_thrd
*else
lsel,selv,loc,y,1.015*(h_thrd2),h_thrd
*endif
lsel,r,loc,x,0,n_thrd*p_thrd
lsel,r,loc,z,0
ldele,all,,,1
init_entity_num
ksel,selv,loc,x,(h_thrd/4)/tan(thrd_ang*rconv)
ksel,r,loc,y,h_thrd/4
ksel,r,loc,z,0
get_max_entity
k1_thrd=km
init_entity_num
ksel,selv,loc,x,(n_thrd*p_thrd)-((h_thrd/4)/tan(thrd_ang*rconv))
ksel,r,loc,y,h_thrd/4
ksel,r,loc,z,0
get_max_entity
k2_thrd=km
init_entity_num
*endif
k,,kx(k1_thrd),-1.3*p_thrd,0
k,,kx(k2_thrd),-1.3*p_thrd,0
create_lines
lstr,km-1,k1_thrd
lstr,km,k2_thrd
init_entity_num
isolate_lines
al,all
init_entity_num
lplot
*endif
*get,thrd_cs,active,,csys
csn=csn+1
*if,prof,eq,'x',then
min_d_cs=csn
clocal,min_d_cs,0,-kx(k1_thrd),-ky(k1_thrd),0,0,0,0
csys,thrd_cs
atran,min_d_cs,am,,,,0,1
nscp=n_thrd
y_nd_d=h_thrd
*elseif,prof,eq,'i',then
mjr_d_cs=csn
clocal,mjr_d_cs,0,-kx(k1_thrd),-ky(k1_thrd),0,0,0,0
csys,thrd_cs
atran,mjr_d_cs,am,,,,0,1
*endif
init_entity_num
lplot
*if,thrd_ass,eq,0,then
*set,iii,
*set,iij,
*set,ijk,
*set,k_tip,
*set,n_thrd,
*set,n_inch,
*set,r_thrd,
*set,p_thrd,
*set,h_thrd,
*set,h_thrd2,
*set,k1_thrd,
*set,k2_thrd,
*set,thrd_ang,
*set,root_h,
*set,r_width,
*set,r2edge,
*set,prof,
*set,stndrd,
*set,d_mjr,
*set,d_min,
*set,zzzz,
*set,counter,
*set,incrm,
*set,lstart,
*set,thrd_ln,
*set,y_nd_d,
*endif
*if,prkey_,eq,1,then
/go
*endif
:skip