TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TopoWAR on November 22, 2015, 07:40:08 PM

Title: problem with text - list
Post by: TopoWAR on November 22, 2015, 07:40:08 PM
Hi, I'm trying to make a polyline with this data but I can not pass "12.12 <342d17'0" to 12.12 <342d17'0, as I do, thank you !!!

Code: [Select]
;; ("12.12<342d17'0" "349.11<31d4'0" "25.00<102d57'0" "264.33<97d51'0" "26.96<9d9'0" "25.48<88d14'0")
(foreach TEMP lista_datos__real
    (command "_pline")
    (foreach TMP TEMP (command TMP))
    (command "")
  )
Title: Re: problem with text - list
Post by: ymg on November 22, 2015, 08:27:08 PM
Topowar,

Two problems, The format of your data must be "12.12<342d17'0\"" if you want to use seconds.

Alternatively, since your data is always 0"   it could be "12.12<342d17'"

For the code part, you are restarting the command pline at each iteration
use the following:

Code: [Select]
(setq data1  '("12.12<342d17'0\"" "349.11<31d4'0\"" "25.00<102d57'0\"" "264.33<97d51'0\"" "26.96<9d9'0\"" "25.48<88d14'0\""))
(setq data2  '("12.12<342d17'" "349.11<31d4'" "25.00<102d57'" "264.33<97d51'" "26.96<9d9'" "25.48<88d14'"))
(command "_PLINE")
   (foreach p data1
      (command p)
   )
(command "")
Title: Re: problem with text - list
Post by: Lee Mac on November 23, 2015, 05:24:20 AM
Alternatively:
Code: [Select]
(apply 'command (append '("_.pline") data1 '("")))
Beware of Object Snaps.
Title: Re: problem with text - list
Post by: CAB on November 23, 2015, 07:30:24 AM
Could one use polar and entmake the pline?
Title: Re: problem with text - list
Post by: TopoWAR on November 23, 2015, 11:18:52 AM
Could one use polar and entmake the pline?

hello, as if I really take care data is close to the end, for example:
vertices of poly 1 2 3 4 5 6, and eventually occupied the angle and distance data between 6 and 1 (closing data)
Title: Re: problem with text - list
Post by: ymg on November 23, 2015, 12:53:17 PM
TopoWar,

I don't understand your last comment.

CAB's suggestion make sense as using command is kind of slow.

Where is your data coming from?

ymg
Title: Re: problem with text - list
Post by: TopoWAR on November 23, 2015, 01:08:58 PM
ok, I have the following data:
"12.12 <342d17'0" "349.11 <31d4'0" "25.00 <102d57'0"
with this data I create a polyline with vertices
"12.12 <342d17'0" 1-2
"349.11 <31d4'0" 2-3
"25.00 <102d57'0" 3-4

I occupy the data really is: angle and distance of:

4-1 angle ?? distance ??

although I think these data we can use "polar" or "angtos" do not know.
Title: Re: problem with text - list
Post by: ymg on November 23, 2015, 08:45:24 PM
TopoWar,

Doing this you are always starting your polyline at 0,0

In order to use polar you would need to parse your data
into an angle  and a distance.

(setq dist (atof str) )   will give you the distance
(setq ang (angtof (substr str (+ (vl-string-position 60 str) 2))) gives you the angle in radian.

So (polar p ang dist) gives you the point.

This will work in the angle value are direction (azimut)

If they are angle from the last point you will have to add pi
to every angle but the first.

Where does the data come from ?

Your data is still wrong, the second symbol " must be escaped
like so \" and then the final " to close the string.

"12.12 <342d17'0" should be "12.12 <342d17'0\""