See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: Need some help 'strcat'ing parts of a sublist and replacing that into the original list

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Civil Engineering Moderator MHultgren's Avatar
    Join Date
    2000-12
    Location
    Indy West (Not West Indies)
    Posts
    1,446
    Login to Give a bone
    0

    Default Need some help 'strcat'ing parts of a sublist and replacing that into the original list

    I started with one of Peter's AU06 routines to create a table (TableMagic.LSP - great code Peter!)

    and what I need to do is combine list positions 3,4,&5 and 6,7 & 8, add some extra text to the string,
    then create a new list with the same position 1 & 2 entries and add the resultant strings to convert the original list from an 8 entity list to a 4 entity list

    Here is one line of the external text file I am working with:

    10176,0+00.00,37,49,56.35,109,58,0.98



    here is part of the code that I am trying to wrap my head around.

    Code:
    ; Utility to import a comma separated ascii text file into a list of sublists
    
    (defun UELS:CSVFiletoList (strFilename   ; String Filename
                               strChar       ; String Delimiter
                               /
                               lstOfSublists ; List of Sublists
                               strText       ; String of Delimited Strings
                               fil)          ; File ASCII Comma Separated Values
     (setq fil (open strFilename "r"))
     (while (setq strText (read-line fil))
      (setq lstOfSublists (cons (UELS:CSVStringToList strText strChar) lstOfSublists)))
      (close fil)
     (reverse lstOfSublists)
    )
    
    ; Parsing a textstring to a list.
    
    (defun UELS:CSVStringToList  (strText     ; String of Delimited strings
                                  strChar     ; String Delimiter
                                  /
                                  intPosition ; Integer String Character Index
                                  lstStrings) ; List of Strings
     (while (setq intPosition (vl-string-search strChar strText 0))
      (setq lstStrings  (cons (substr strText 1 intPosition) lstStrings)
            strText     (substr strText (+ intPosition 1 (strlen strChar)))))
     (reverse (cons strText lstStrings))
    )
    
    ;**************************************************************************************
    ;**************************************************************************************
    
    ;This function concatenates the Latitude and longitude values
    
    (defun UELS:LatLongComp (/ lstSublist)
      (setq strCompressLat (strcat "N" (nth 2 lstSublist) "\U+00B0" (nth 3 lstSublist) "\'" (nth 4 lstSublist) "\""))
      (setq strCompressLong (strcat "W" (nth 5 lstSublist) "\U+00B0" (nth 6 lstSublist) "\'" (nth 7 lstSublist) "\""))
    )
    Last edited by MHultgren; 2018-06-13 at 02:40 PM. Reason: add external text string sample

Similar Threads

  1. Make parts keep their original family properties
    By Wish List System in forum Revit Structure - Wish List
    Replies: 0
    Last Post: 2013-11-10, 08:25 AM
  2. Parts From the CC Display Modified Lengths in Parts List
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 2
    Last Post: 2012-12-19, 04:16 AM
  3. Parts List Styles and Extents available in Parts List
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 0
    Last Post: 2009-06-19, 02:13 PM
  4. Adding Metric Parts in Parts List?
    By Keefe_Lee_G-and-O in forum AutoCAD Civil 3D - Pipes
    Replies: 1
    Last Post: 2008-08-19, 12:54 PM
  5. strcat
    By fletch97 in forum AutoLISP
    Replies: 6
    Last Post: 2005-07-18, 06:29 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •