!   TITLE:  create_lines.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates lines between newly created keypoints.
!
!
!   COMMAND SYNTAX:
!
!       CREATE_LINES, c_acs, seqnce
!
!
!   ARGUMENTS:
!
!       (1) c_acs = boolean operator to create lines in active coordinate
!                   system:
!
!               0 (or blank) = creates straight lines between KP's,
!                              regardless of active c.s.
!
!               1 = creates lines in active c.s.
!
!       (2) seqnce = boolean operator to create lines in a closed loop,
!                or lines in sequence from lowest to highest keypoint
!                order.
!
!               0 (or blank) = creates lines between KP's, forming a
!                              closed loop.
!
!               1 = creates lines between keypoints in sequence, but
!                   not forming a closed loop.
!
!
!   DESCRIPTION:
!
!   The lines may be created in a loop, or in sequence from lowest to high-
!   est keypoint values. This command is preceeded and followed by the command
!   INIT_ENTITY_NUM. Therefore, it may be used directly after the keypoint
!   commands (k,,XX,YY,ZZ); and directly before all other commands. The
!   retrieval of the maximum entities before and after the lines are created
!   is built in.
!
!   When creating lines, be sure that the proper coordinate system is active;
!   i.e., if arced lines are desired, then the active coordinate system must
!   be a cylindrical coordinate system; if spherical lines are desired, then
!   the active c.s. must be a spherical c.s.; etc.
!
!   Therefore, if straight lines in a closed loop is the desired objective,
!   no arguments need to be specified.  Only the macro title needs specified.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
init_entity_num
!
cacs_=arg1
seqnce_=arg2
!
newkps_=km-km_prev      ! number of new keypoints
!
*if,newkps_,ge,2,then
    *if,seqnce_,eq,0,then
        *if,cacs_,eq,0,then
            *do,iii_,1,newkps_,1
                *if,iii_,ne,newkps_,then
                    lstr,km-(newkps_-iii_),km-(newkps_-iii_-1)
                *else
                    lstr,km,km-(newkps_-1)
                *endif
            *enddo
        *endif
        !
        *if,cacs_,eq,1,then
            *do,iii_,1,newkps_,1
                *if,iii_,ne,newkps_,then
                    l,km-(newkps_-iii_),km-(newkps_-iii_-1)
                *else
                    l,km,km-(newkps_-1)
                *endif
            *enddo
        *endif
    *endif
    !
    !
    *if,seqnce_,eq,1,then
        *if,cacs_,eq,0,then
            *do,iii_,1,newkps_-1,1
                lstr,km-(newkps_-iii_),km-(newkps_-iii_-1)
            *enddo
        *endif
        !
        *if,cacs_,eq,1,then
            *do,iii_,1,newkps_-1,1
                l,km-(newkps_-iii_),km-(newkps_-iii_-1)
            *enddo
        *endif
    *endif
*endif
!
*if,arg3,eq,0,then
    *set,newkps_,
*endif
!
init_entity_num
!
lplot
!
*set,iii_,
*set,seqnce_,
*set,cacs_,
!
*if,prkey_,eq,1,then
    /go
*endif