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


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.  :crazy2:

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  :smitten:

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: ");
  4.        t_obj=vla.addtable(spc,vlax.3d_point(ipt),
  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)),
  8.              list(read("horzcellmargin",read("vertcellmargin"),read("rowheight")),
  9.              list(0.5,0.5,5.0));
  10.       vla.settextstyle(t_obj,acDataRow+acHeaderRow+acTitleRow,"TOPOCAD");
  11.       vlax.invoke(t_obj,read("setrowheight"),0,10.0);
  12.       vlax.invoke(t_obj,read("setcelltextheight"),0,0,2.5);
  13.       vlax.invoke(t_obj,read("settext"),0,0,title);
  14.       rows=vlax.get(t_obj,read("rows"))-2),
  15.       cols=vlax.get(t_obj,read("columns"))-1),
  16.       for(row=1;row<rows;row=row+1)
  17.         { for(rdat=nth(row-1),lst),cell=0;cell<cols;cell=cell+1)
  18.          { vlax.invoke(t_obj,read("setcelltextheight"),row,cell,2.5);
  19.            vlax.invoke(t_obj,read("settext"),row,cell,nth(cell,rdat));
  20.            vlax.invoke(t_obj,read("setcellalignment"),row,cell,acMiddleCenter);
  21.            cell= (cell+1);
  22.          };
  23.         row= (row+1);
  24.       ??? Please Help HERE HERE FIX ???
  25.       repeat(2)
  26.       { vlax.invoke(t_obj,read("setrowheight"),row,6.0);
  27.         vlax.invoke(t_obj,read("mergecells"),row,row,0,cols);
  28.         rdat=nth( (row-1),lst);
  29.         vlax.invoke(t_obj,read("setcelltextheight"),row,0,2.5);
  30.         vlax.invoke(t_obj,read("settext"),row,0,car(rdat));
  31.         row= (row+1);
  32.        };
  33.      };
  34.       vla.put_regeneratetablesuppressed(t_obj, vlax_false);
  35. */
  36. )
  37. %include=vl_load_com
  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. :sleezy:
(snapshot.gif "cl_aclayer_enttable_2020_pp_tablegreece-vlax.gif")
« Last Edit: September 07, 2020, 04:59:56 PM by d2010 »