Extract an element from rawdescription

Extract an element from rawdescription

johnd
Contributor Contributor
1,379 Views
5 Replies
Message 1 of 6

Extract an element from rawdescription

johnd
Contributor
Contributor

This is the rawdescription of my cogo point for the Code PL_EX: 

"PL_EX 0 OTHER NATURAL_GAS VIVAX 7 0 STEEL_ENLINK (8254/15)"

I want to extract the "7" and the  "0" from the description separately.

What is the simplest way to do this?

The two values would always be in the same order but not at the same position since other elements before it may be longer or shorter.

0 Likes
Accepted solutions (1)
1,380 Views
5 Replies
Replies (5)
Message 2 of 6

Pointdump
Consultant
Consultant

Hi John,
Instead of COGO points I'd create a shapefile and use feature styling. The big plus would be the ability to query only those points with 7 or 0.
Dave

Dave Stoll
Las Vegas, Nevada

EESignature

64GB DDR4 2400MHz ECC SoDIMM / 1TB SSD
NVIDIA Quadro P5000 16GB
Windows 10 Pro 64 / Civil 3D 2027
0 Likes
Message 3 of 6

johnd
Contributor
Contributor

Thanks for the suggestion. However, this is going into an existing lisp routine that will modify the elevation of the point using those two varying numbers. The first (7) is a depth of cover from Grade and the second (0) is water depth if applicable. I will use these two values to calculate a new elevation in the point and use that value elsewhere in the routine. 

0 Likes
Message 4 of 6

ChicagoLooper
Mentor
Mentor

@johnd 

Can your routine call up a point group? If you can, then put the 7's and 0's in their own own individual group. Then call up the PG, not the description.

 

Chicagolooper

EESignature

0 Likes
Message 5 of 6

Jeff_M
Consultant
Consultant
Accepted solution

Split the rawdescription by the spaces, then use the 5th & 6th elements in the list:

;;;str2list by John Uhden, as posted to the adesk customization newsgroup
(defun Str2List (str pat / i j n lst)
  (cond
    ((/= (type str)(type pat) 'STR))
    ((= str pat)'(""))
    (T
      (setq i 0 n (strlen pat))
      (while (setq j (vl-string-search pat str i))
        (setq lst (cons (substr str (1+ i)(- j i)) lst)
              i (+ j n)
        )
      )
      (reverse (cons (substr str (1+ i)) lst))
    )
  )
)

 

Command: (setq str "PL_EX 0 OTHER NATURAL_GAS VIVAX 7 0 STEEL_ENLINK (8254/15)")
"PL_EX 0 OTHER NATURAL_GAS VIVAX 7 0 STEEL_ENLINK (8254/15)"

Command: (setq thelist (str2list str " "))
("PL_EX" "0" "OTHER" "NATURAL_GAS" "VIVAX" "7" "0" "STEEL_ENLINK" "(8254/15)")

Command: (nth 5 thelist)
"7"

Command: (nth 6 thelist)
"0"

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 6 of 6

johnd
Contributor
Contributor

Thank you,

that's just what I needed. worked as needed. now to decipher.

0 Likes