### Author Topic: help with coordinate table with area  (Read 869 times)

0 Members and 1 Guest are viewing this topic.

#### PM

• Newt
• Posts: 127
##### help with coordinate table with area
« on: September 05, 2020, 11:26:11 AM »
Hi i have a drawing with 23 polylines . I have to export the coordinates to tables with area at the end. On each vertex of the polyline is a block attibiute (not the same attriute on each vertex)

I upload a sample with one polyline for example.

I am searching for a lisp to select the polyline ,pick the start point and export the attribiute coordinates with the number of each attriute. look the test .dwg

Thanks
« Last Edit: September 05, 2020, 11:30:04 AM by PM »

#### PM

• Newt
• Posts: 127
##### Re: help with coordinate table with area
« Reply #1 on: September 06, 2020, 04:16:05 AM »
I understand that what i ask is difficult.

Is it possible to select

1) a polyline
2)pick the start point
3)export the coordinates from the attribiuts on polyline vertex (P,X,Y) clockwise to a txt file

thanks

#### PM

• Newt
• Posts: 127
##### Re: help with coordinate table with area
« Reply #2 on: September 06, 2020, 10:16:29 AM »
Here is all the block attribiute names i use

Code - Auto/Visual Lisp: [Select]
1. Point,KORYFES
2. station
3. trigonom
4. KOKAEK
5. KOROT
6. AnnotPoint
7. AnnotKORYFES
8. Annotstation
9. Annottrigonom
10. AnnotKOKAEK
11. AnnotKOROT
12. ("Point,KORYFES,station,trigonom,KOKAEK,KOROT,AnnotPoint,AnnotKORYFES,Annotstation,Annottrigonom,AnnotKOKAEK,AnnotKOROT")
13.

I have this code . Export polyline vertex coordinates. I want to update it.

1) select the polyline
2)pick the start point
3 )export the coordinates from the attribiuts on polyline vertex (P,X,Y) clockwise to a txt file

I attach a dwg file with a polyline example with attribiute points

Code - Auto/Visual Lisp: [Select]
1. (defun c:test (/ *error* file sset ename lst i)
2.     (defun *error* (s)
3.  (if file
4.      (close file)
5.  )
6.  (cond
7.      ((not s))
8.      ((member s '("Function cancelled" "quit / exit abort")))
9.      ((princ (strcat "\n---->Error:" s)))
10.  )
11.  (princ)
12.     )
13.     (if (setq sset (ssget "_:L" '((0 . "LWPOLYLINE,POLYLINE"))))
14.      (if (setq file (open (strcat (getvar 'dwgprefix)
15.       "Lwpolyline Vertex List.txt"
16.      )
17.      "w"
18.       )
19.   )
20.       ;(write-line (strcat "X" "," "Y") file)
21.       (repeat (setq i (sslength sset))
22.    (setq ename (vlax-ename->vla-object
23.      (ssname sset (setq i (1- i)))
24.         )
25.    )
26.    (setq lst (vlax-safearray->list
27.           (vlax-variant-value
28.        (vla-get-coordinates ename)
29.           )
30.       )
31.    )
32.    (repeat (/ (length lst) 2)
33.     (strcat (rtos (car lst))
34.      ","
36.     )
37.     file
38.        )
39.        (setq lst (cddr lst))
40.    )
41.       )
42.       (close file)
43.
44.   )
45.      )
46.  )
47.  (*error* "Nothing Selected.")
48.     )
49.     (*error* nil)
50.     (princ)
51. )
52.
53.

Thanks

#### Dlanor

• Bull Frog
• Posts: 260
##### Re: help with coordinate table with area
« Reply #3 on: September 06, 2020, 11:25:26 AM »
Hi i have a drawing with 23 polylines . I have to export the coordinates to tables with area at the end. On each vertex of the polyline is a block attibiute (not the same attriute on each vertex)

I upload a sample with one polyline for example.

I am searching for a lisp to select the polyline ,pick the start point and export the attribiute coordinates with the number of each attriute. look the test .dwg

Thanks

Try the attached will only do one polyline at a time as you want to select the start point. It will only work with LWPolylines, will select the blocks in a clockwise direction even if the line is constructed counterclockwise, and uses the blocks insertion point for the coords i.e. assumes the insertion point is on the vertex.

It will work in metres and millimetres (for the latter it will ask if you want the results in metres and if so converts the coords and areas)

The created table is a fraction smaller than the example as i've rounded the column widths to the nearest half unit.

#### PM

• Newt
• Posts: 127
##### Re: help with coordinate table with area
« Reply #4 on: September 06, 2020, 02:35:52 PM »
Hi Dlanor thanks for the help but i need two small changes

1) The area to have 2 decimals  .
2) You add after Area  m2 .I want to change it to sq.m .I can not find were the m2
3)And nme text size 2

i find this part .

Code - Auto/Visual Lisp: [Select]
1. (setq dut "m" aut (strcat dut (chr 178)) ccf 1.0 acf 1.0 fuzz 0.001))
2.
3.
Code - Auto/Visual Lisp: [Select]
1. (setq dut "m" aut (strcat dut ) ccf 1.0 acf 1.0 fuzz 0.001))
2.
3.

then i  change this

Code - Auto/Visual Lisp: [Select]
1. (strcat "E" nme " = " (rtos (/ (vlax-curve-getarea ent) acf) 2 acc) " " aut)) tlst)
2.

to

Code - Auto/Visual Lisp: [Select]
1. (strcat "E" nme " = " (rtos (/ (vlax-curve-getarea ent) acf) 2 2) " " aut)) tlst)

and works

Only the 3 i dont know how to change it

Thanks
« Last Edit: September 06, 2020, 03:46:47 PM by PM »

#### PM

• Newt
• Posts: 127
##### Re: help with coordinate table with area
« Reply #5 on: September 06, 2020, 04:01:26 PM »
How to change  nme text size to 2 ?

And if it possible to add a merge line before area to add this type

Code - Auto/Visual Lisp: [Select]
1. E=1/2 S(Xi + Xi+1)(Yi - Yi+1)
2.

Thanks
« Last Edit: September 06, 2020, 04:11:07 PM by PM »

#### Dlanor

• Bull Frog
• Posts: 260
##### Re: help with coordinate table with area
« Reply #6 on: September 06, 2020, 06:02:20 PM »
change

Code - Auto/Visual Lisp: [Select]
1. (setq dut "m" aut (strcat dut ) ccf 1.0 acf 1.0 fuzz 0.001))

to

Code - Auto/Visual Lisp: [Select]
1. (setq dut "m" aut (strcat "sq." dut ) ccf 1.0 acf 1.0 fuzz 0.001))

As to 3, I not sure.

You could try finding

Code - Auto/Visual Lisp: [Select]
1.  tlst (cons (list (strcat "E " nme " = " (rtos (/ (vlax-curve-getarea ent) acf) 2 acc) " " aut)) tlst)

and changing to

Code - Auto/Visual Lisp: [Select]
1. tlst (cons (list (strcat "E{\\H0.8x;" nme "} = " (rtos (/ (vlax-curve-getarea ent) acf) 2 2) " " aut)) tlst)

but I don't know if this will work. If this doesn't work I have no other answer

#### Dlanor

• Bull Frog
• Posts: 260
##### Re: help with coordinate table with area
« Reply #7 on: September 06, 2020, 06:05:12 PM »
And if it possible to add a merge line before area to add this type

Code - Auto/Visual Lisp: [Select]
1. E=1/2 S(Xi + Xi+1)(Yi - Yi+1)
2.

Thanks

Don't understand this. make the change to your original drawing and re-attach it to a new post.

#### PM

• Newt
• Posts: 127
##### Re: help with coordinate table with area
« Reply #8 on: September 06, 2020, 06:17:12 PM »
tHIS WORKS

Code - Auto/Visual Lisp: [Select]
1. tlst (cons (list (strcat "E{\\H0.8x;" nme "} = " (rtos (/ (vlax-curve-getarea ent) acf) 2 2) " " aut)) tlst)
2.

#### PM

• Newt
• Posts: 127
##### Re: help with coordinate table with area
« Reply #9 on: September 06, 2020, 06:32:11 PM »
You said to do ths change

Code - Auto/Visual Lisp: [Select]
1.     (setq dut "m" aut (strcat "sq." dut ) ccf 1.0 acf 1.0 fuzz 0.001))
2.

i did

Code - Auto/Visual Lisp: [Select]
1.     (setq dut "t.m" aut (strcat  dut ) ccf 1.0 acf 1.0 fuzz 0.001)) ; is this wrong? the result is correct !!!
2.
3.

#### Dlanor

• Bull Frog
• Posts: 260
##### Re: help with coordinate table with area
« Reply #10 on: September 06, 2020, 07:03:52 PM »
You said to do ths change

Code - Auto/Visual Lisp: [Select]
1.     (setq dut "m" aut (strcat "sq." dut ) ccf 1.0 acf 1.0 fuzz 0.001))
2.

i did

Code - Auto/Visual Lisp: [Select]
1.     (setq dut "t.m" aut (strcat  dut ) ccf 1.0 acf 1.0 fuzz 0.001)) ; is this wrong? the result is correct !!!
2.
3.

I don't know, I'm working with an english version of AutoCAD and I think you have an international version.

There are 3 lines in that section of code that set variables dut and aut for metres, millimetres and millimetres converted to metres. The changes to variables dut and aut should be applied to all three.

I have looked at the new posted drawing. Adding the extra line is easy, but getting it into the table correctly needs testing as i have to change the while loops and I can't do that until I have a full version of AutoCAD to work on tomorrow morning.

#### Dlanor

• Bull Frog
• Posts: 260
##### Re: help with coordinate table with area
« Reply #11 on: September 07, 2020, 02:51:14 AM »
OK. Attached is revised lisp and your original drawing. The drawing contains a table from your example polyline and shows what and where the variables control. I have also marked the lines in the lisp that control these variable so you can set up the headers and units how you wish.

#### PM

• Newt
• Posts: 127
##### Re: help with coordinate table with area
« Reply #12 on: September 07, 2020, 05:28:17 AM »
Thanks Dlanor

#### Dlanor

• Bull Frog
• Posts: 260
##### Re: help with coordinate table with area
« Reply #13 on: September 07, 2020, 11:51:01 AM »
Please you fix error at Line24?
I do not understand, can you fix at line24. Where You close first-for and Second-For?
Why you use both row=row+1?  You see at line23 and line31.
OK. Attached is revised lisp and your original drawing. The drawing contains a table
Code - Auto/Visual Lisp: [Select]
1. #region rh_amt
2. (defun rh_AMT ( spc title lst ipt / t_obj rows cols row cell rdat)
3. /*c2s: if (!ipt) ipt=getpoint("\nSelect Table Insertion Point: ");
5.                        (1+(length lst)),(length (car lst)),5.0,22.5);
6.        vla.put_regeneratetablesuppressed(t_obj,vlax_true);
7.        mapcar(lambda(x(y),vlax.put_property(t_obj,x,y)),
9.              list(0.5,0.5,5.0));
16.       for(row=1;row<rows;row=row+1)
17.         { for(rdat=nth(row-1),lst),cell=0;cell<cols;cell=cell+1)
21.            cell= (cell+1);
22.          };
23.         row= (row+1);
25.       repeat(2)
28.         rdat=nth( (row-1),lst);
31.         row= (row+1);
32.        };
33.      };
34.       vla.put_regeneratetablesuppressed(t_obj, vlax_false);
35. */
36. )
38. #endregion
39.

There is no error in the lisp code. It works. I have no idea into which language you're trying to translate it? A for loop is not a direct substitute for a while loop, the work slightly differently. Since you are setting row=row+1 on line 16 I would assume that line 23 isn't needed.

The original had a while loop testing if row meets a condition i.e. it was less than (the number of rows minus 2),  for that row must be incremented for each iteration, which also enables it to be used to extract the correct list from the data. The inside while loop is used to fill each cell in the row, so at the end of the outer while loop row is incremented and cell reset to 0 (zero). The data consists of a list of lists. Each list in the list has 3 items, except for the last 2 which only have 1 item.

The repeat 2 is to merge cells on the last 2 rows and place the correct single item data in that row, therefore row again needs to be incremented for each iteration.

#### d2010

• Newt
• Posts: 77
##### Re: help with coordinate table with area
« Reply #14 on: September 07, 2020, 02:06:17 PM »
I got this error isInside AutoCad.exe
Code: [Select]
`Select Closed LWPolyline :Select Start Point :Enter Area Name : "https://sdaromania.clickmeeting.com/394199842/ended"An Error : no function definition: GETPROPERTYVALUE occurred.Command:Automatic save to "Automatic Tester for Software"`I try fill the table with web-link adresses.
(snapshot.gif "cl_aclayer_enttable_2020_pp_tablegreece-vlax.gif")
« Last Edit: September 07, 2020, 04:59:56 PM by d2010 »