!*****************************************************************
! PIN_0209A   / 13-03-2006 / Vertex Systems UK                    *
!                                                                *
!*****************************************************************

#UPDATE_JOINT#

!debug ./update_joint.dbg

set RETURN "-1"

I = new_iterator("",0,"ROLED","THIS")
This = next_item(I)
if (!This) then exit
init_iterator(I) "PROFOBJ",This,"CONNECTION_ROLEPARTS","PCE"
Pce = next_item(I)
if (!Pce) then exit

! Check object type

Type$ = get_object_type(Pce)
if (!cmp(Type$,"PROFOBJ")) then exit

! Check piece type

Mat$ = get_material_param(Pce,"SHAPE")
if (!cmp(Mat$,"C") and !cmp(Mat$,"U")) and (!cmp(Mat$,"S") and !cmp(Mat$,"T")) then exit

! Check shape

Geom = 1
get_vxgeom(Geom) Pce
Shape$ = get_vxgeom_shape(Geom);
if (cmp(Shape$,"LINE") = 0) then exit

! Locate joint

P = 1; X = 2; Y = 3; Z = 4; PJ = 5; XJ = 6; YJ = 7; ZJ = 8

get_joint_pos(This) PJ,XJ,YJ,ZJ
get_origin_pos(Pce) P,X,Y,Z
point_to_piece(P) Pce,PJ
set_joint_pos(This) P,Y,Z,X

set RETURN "1"

#UPDATE_JOINT#


#JOINT_TEST#

I = new_iterator("",0,"ROLED","THIS")
This = next_item(I)
if (!This) then exit
init_iterator(I) "PROFOBJ",This,"CONNECTION_ROLEPARTS","PCE"
Pce = next_item(I)
if (!Pce) then exit

get_joint_pnt(1) This
get_vxgeom(1) Pce
point_to_vxgeom(1) 1,1
if is_in_vxgeom(1,1,0,mm_to_dwg(0.1)) = 0 then exit

set RETURN "1"

#JOINT_TEST#


#JOINT_DETAILING#

debug ./joint_detailing.dbg

I = new_iterator("",0,"ROLED","THIS")
This = next_item(I)
if (!This) then exit

init_iterator(I) "PROFOBJ",This,"CONNECTION_ROLEPARTS","PCE"
Pce = next_item(I)
if (!Pce) then exit

PceHeight= get_section_param(Pce,"HEIGHT")
PceWidth = get_section_param(Pce,"WIDTH")
PceThick = get_section_param(Pce,"THICK")

JP= 1
JX= 2
JY= 3
JZ= 4
PP= 5
PX= 6
PY= 7
PZ= 8
P=  9
X= 10
Y= 11
Z= 12
D= 13
PN = 14

get_origin_pos(This) JP,JX,JY,JZ
get_origin_pos(Pce) PP,PX,PY,PZ

init_iterator(I) "",This,"CONNECTION_ROLEPARTS","P"
Punch = next_item(I)
if (!Punch) then exit

vec_copy(D) PY
Ok= proj_to_piece(JP,PN,JP,D,Pce,0,0)
set_origin_pos(Punch) JP,PZ,PX,PN

init_iterator(I) "",This,"CONNECTION_ROLEPARTS","P2"
Punch = next_item(I)
if (!Punch) then exit

vec_rev(D) PY
Ok= proj_to_piece(JP,PN,JP,D,Pce,0,0)
set_origin_pos(Punch) JP,PZ,PX,PN

! Set Box
init_iterator(I) "",This,"CONNECTION_ROLEPARTS","B"
Box= next_item(I)
if !Box then exit
get_origin_pos(This) JP,JX,JY,JZ
set_origin_pos(Box) JP,JX,JY,JZ
BoxHgt = PceWidth - (PceThick * 2)
if Dia1 > 0 then
  set_obj_param(Box) "DIA",Dia1
endif
set_obj_param(Box) "D",BoxHgt,1

set RETURN "1"

#JOINT_DETAILING#
