!   TITLE:  kp_intersect.mac (MANAGEMENT)
!
!
!   OBJECTIVE:
!
!   This sub-macro retrieves the keypoint at the intersection of a specified
!   set of lines. This intersection keypoint (IKP) is output in the variable:
!
!                       ikp_ = intersection keypoint number.
!
!
!   COMMAND SYNTAX:
!
!                                  (1)   (2)   (3)   (4) . . . . (15)
!       OPTION 1:   KP_INTERSECT, ln_1, ln_2, ln_3, ln_4,......, ln_15
!
!                                    (1)
!       OPTION 2:   KP_INTERSECT, ln_CG_name
!
!       OPTION 3:   KP_INTERSECT
!
!
!   ARGUMENTS:
!
!       OPTION 1:   (N=1...15) ln_N = line #N.
!
!       OPTION 2:   (1) ln_CG_name = name of component group containing
!                                    selected lines. The remaining argumens
!                                    (2...15) left blank.
!
!       OPTION 3:   (N=1...15) ln_N = all arguments left blank. The current
!                                     selected set of lines are used.
!
!
!   DESCRIPTION:
!
!   The IKP is one end keypoint for the specified set of lines. This information
!   may be used for various solid modeling tasks and operations.
!
!   There are 3 options available for specifying the lines in this macro:
!
!       (1) Enter the line numbers directly into the arguments. Up to 15
!           lines may be specified.
!
!       (2) If the lines exist in a component group, the name of the group
!           may be specified in the 1st argument. The remaining arguments
!           may be left blank. This option may be used if more than 15 lines
!           are to be specified.
!
!       (3) If the desired lines are currently selected in the database, then
!           simply executing this macro with no arguments specified will
!           determine the IKP.
!
!
*get,prkey_,active,0,prkey
/nopr
!
*do,ijk_,1,15,1
    *if,ijk_,le,9,then
        *get,argtyp_,parm,arg%ijk_%,type
        !
        *if,argtyp_,eq,0,then
            *if,arg%ijk_%,gt,0,then
                *if,ijk_,eq,1,then
                    lsel,s,line,,arg%ijk_%
                *elseif,ijk_,gt,1,then
                    lsel,a,line,,arg%ijk_%
                *endif
            *else
                *exit
            *endif
        *elseif,argtyp_,eq,3,then
            cmsel,s,arg%ijk_%,line
            *exit
        *endif
    *elseif,ijk_,gt,9,then
        *if,ar%ijk_%,gt,0,then
            lsel,a,line,,ar%ijk_%
        *else
            *exit
        *endif
    *endif
*enddo
!
entity_array,'l','lgrp_','array',2
lncnt_=ecount
cm,lngrp_,line
ksll,s
!
entity_array,'k','kgrp_','array',,,lncnt_+2
nkp_=ecount
!
*do,ijk_,1,nkp_,1
    cmsel,s,lngrp_
    ksel,s,kp,,kgrp_(ijk_,1)
    lslk,r,0
    *get,kgrp_(ijk_,2),line,,count
*enddo
!
*do,ijk_,1,nkp_,1
    cmsel,s,lngrp_
    ksel,s,kp,,kgrp_(ijk_,1)
    lslk,r,0
    entity_array,'l','lnhold_','array',2
    nlnkp_=ecount
    !
    *do,jkl_,1,nlnkp_,1
        kgrp_(ijk_,jkl_+2)=lnhold_(1,jkl_)
    *enddo
    !
    *set,lnhold_(1)
*enddo
!
max_value,'kgrp_',nkp_,1,1,1,1,2,1
arry_search,'kgrp_',max_val
!
*if,hits,eq,1,then


*elseif,hits,eq,0,then


*else





cmsel,s,lngrp_
!










lplot

!*set,ijk_,
*set,argtyp_,

!*set,
!*set,
!*set,
!*set,
!*set,
!*set,
!*set,
!*set,












!
*if,prkey_,eq,1,then
    /go
*endif