list manipulations

Discussion in 'AutoCAD' started by jwcampo, Jul 24, 2003.

  1. jwcampo

    jwcampo Guest

    (apologies of this is a duplicate posting, my original seems to have not made it)

    Could someone provide some guidance as how to resolve the following. A file which needs to be processed and made into a pline.

    The sample file below, is composed of object name, other data, and points.

    OPEN P8-160 ,PLAN,-45.59995 , 15
    OPEN P8-160 ,PLAN, 0.3000584 , 15
    OPEN P8-160 ,PLAN, 0.3000584 ,-15
    OPEN P8-160 ,PLAN,-45.59995 ,-15
    OPEN P8-160 ,PLAN,-45.59995 , 15
    OPEN P8-160 ,PROFILE,-45.59995 ,-15
    OPEN P8-160 ,DECK,-45.59995 , 15
    TOPN 160 ,PLAN,-45.59995 , -15
    TOPN 160 ,PLAN,-55.59995 , 15
    TOPN 160 ,PLAN,-55.59995 , 15
    TOPN 160 ,PLAN,-45.59995 , -15

    Processing:
    each line is read from the file
    - converted to a list
    - cleaned
    - modified
    then passed to the subroutine below.

    The following is result of processing and is then passed one line at a time to the subroutine below.

    OPEN P8-160,-45.59995,15
    OPEN P8-160, 0.3000584,15
    OPEN P8-160, 0.3000584,-15
    OPEN P8-160,-45.59995,-15
    OPEN P8-160,-45.59995,15
    TOPN 160,-45.59995,-15
    TOPN 160,-55.59995,15
    TOPN 160,-55.59995,15
    TOPN 160,-45.59995,-15

    Desired finished point lists:

    OPEN P8-160,-45.59995,15,0.3000584,15,0.3000584,-15,-45.59995,-15,-45.59995,15
    TOPN 160,-45.59995,-15,-55.59995,15,-55.59995,15,-45.59995,-15

    Where the OPEN P8-160 and TOPN 160 are the object name of the PLINE created.

    Problem:
     my subroutine below almost does the job. It fails to return the last object in the file, in the above example TOPN.

    ; plz = read-line as list
     ; Xplx = tmp
     ; Xplzz = output list

    (defun plplconv (plz / Xplx Xplzz)
      (setq Xplzz nil)
        (if (/= 0 (length Xplx))
         (progn
      (if (/= nil (member (nth 0 plz) Xplx))
               (progn
      (setq Xplx (cons (nth 1 plz) Xplx))
      (setq Xplx (cons (nth 2 plz) Xplx))
      )
      (progn
      (setq Xplzz Xplx)
      (setq Xplx nil)
      (setq Xplx (reverse plz))
      )
      )
          )
         (progn
      (setq Xplx nil)
      (setq Xplx (reverse plz))
      (setq Xplzz nil)
        )
       )
       (reverse Xplzz)
     )

    Oh and yes, this needs to be AutoCAD 14 compatible...
    Any help you can provide is appreciated.

    Joseph-
     
    jwcampo, Jul 24, 2003
    #1
  2. jwcampo

    jwcampo Guest

    luis, thanks

    I should have stated this is more of a collation of list instead of a list manipulation. Still I might learn something from what Ralph Gimenez has written.

    joseph
     
    jwcampo, Jul 24, 2003
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.