Author Topic: help with coordinate table with area  (Read 841 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 »

HOSNEYALAA

  • Newt
  • Posts: 53
Re: help with coordinate table with area
« Reply #15 on: September 07, 2020, 04:25:37 PM »
hi test this


Code: [Select]

;;;https://www.theswamp.org/index.php?topic=56230.0


(defun rh:yn (msg default / tmp) (initget 6 "Yes No") (cond ( (getkword (strcat msg " [Yes/No] < " default " > : "))) (default)))

(defun rh:pchk (vlst pt fz / tmp) (while (not (equal pt (car vlst) fz)) (setq tmp (car vlst) vlst (append (cdr vlst) (list tmp)))))

(defun rh:pcw-p ( obj / tmp flg)
  (if (= (type obj) 'ENAME) (setq obj (vlax-ename->vla-object obj)))
  (cond ( (vlax-method-applicable-p obj 'offset)
          (setq tmp (car (vlax-invoke obj 'offset -0.005))
                flg (if (> (vlax-get tmp 'area) (vlax-get obj 'area)) T nil)
          );end_setq
          (vla-delete tmp)
          flg
        )
        (t "")
  );end_cond
);end_defun

(vl-load-com)

;;Polyline Area Table
(defun C:PAT ( / *error* sv_lst sv_vals c_doc c_spc acc iunits dut aut ccf acf fuzz flg ent pt obj cw ss cnt ent nme vlst bent tlst)

  (defun *error* ( msg )
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nAn Error : " msg " occurred.")))
    (princ)
  );end_local_*error*_defun

  (setq sv_lst (list 'cmdecho 'osmode 'dynprompt 'dynmode)
        sv_vals (mapcar 'getvar sv_lst)
        c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        acc (getvar 'luprec)
  );end_setq

  (cond ( (= (setq iunits (getvar 'insunits)) 6) (setq dut "m" aut (strcat "sq." dut) ccf 1.0 acf 1.0 fuzz 0.001)); CHANGE so dut=distance & aut=Area
        ( (= iunits 4)
          (setq dut "mm" aut (strcat "sq." dut) ccf 1.0 acf 1.0 fuzz 1.0); CHANGE dut & aut
          (if (= (rh:yn "\nInsertion Units are Millimetres. Convert Areas & Coordinates to Metres : ?" "No") "Yes")
            (setq dut "m" aut (strcat "sq." dut) ccf 1000.0 acf 1.0e6); CHANGE dut & aut
          );end_if
        )
        (t (setq iunits nil ccf 1.0 acf 1.0 fuzz 1.0))
  );end_cond

  (mapcar 'setvar sv_lst '( 0 1 3 1))

  (while (not flg)
    (setq ent (car (entsel "\nSelect Closed LWPolyline : "))
          obj (vlax-ename->vla-object ent)
    );end_setq

    (cond ( (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE")
            (setq pt (reverse (cdr (reverse (getpoint "\nSelect Start Point : "))))
                  vlst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent)))
            );end_setq
            (cond ( (equal (car vlst) (last vlst) fuzz)
                    (setq vlst (reverse (cdr (reverse vlst))))
                    (if (= :vlax-false (vlax-get-property obj 'closed)) (vlax-put-property obj 'closed :vlax-true))
                    (setq flg T cw (rh:pcw-p ent))
                  )
                  ( (= :vlax-true (vlax-get-property obj 'closed)) (setq flg T cw (rh:pcw-p ent)))
                  (t (alert "NOT a CLOSED LWPolyline"))
            )
            (if (not cw) (setq vlst (reverse vlst)))
          )
          (t (alert "NOT a LWPolyline"))
    );end_cond
  );end_while

  (setvar 'osmode 0)
  (setq vlst (rh:pchk vlst pt fuzz))

   
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq blksObj (vla-get-blocks doc))
  (vla-endundomark doc)
  (vla-startundomark doc)
  (setq spc (vla-get-modelspace doc))

 
  (cond (flg
          (setq nme (strcase (getstring "\nEnter Area Name : "))
                tlst (cons (list (strcat "E{\\H0.8x;" nme "} = " (rtos (/ (vlax-curve-getarea ent) acf) 2 2) " " aut)) tlst)
                tlst (cons (list "E=1/2 S(Xi + Xi+1)(Yi - Yi+1)") tlst)
                ss (ssget "F" vlst '((0 . "INSERT") (66 . 1)))
          );end_setq
          (repeat (setq cnt (sslength ss))
            (setq bent (ssname ss (setq cnt (1- cnt))));;; ("34" "161.028" "199.985")
   
    (setq atts (vlax-invoke
                     (setq blk (vlax-ename->vla-object bent))
                     'getattributes
                   )
        )

    (foreach att atts
;;;       (setq att (CAR atts))
              (cond
                    (
     (eq (vla-get-tagstring att) "POINT")
                     (setq elev (vla-get-textstring att))
                     
                    )
                   
              )
            )
(setq pt (vlax-get blk 'insertionpoint))
   
                 (setq tlst (cons (list elev
                                   (rtos (car pt) 2 acc)
                                   (rtos (cadr pt) 2 acc)
                             )
                             tlst
                       )
            );end_setq
          );end_repeat
          (setq tlst (cons (list "A/A" (strcat "X" (if iunits (strcat " (" dut ")") " (?)")) (strcat "Y" (if iunits (strcat " (" dut ")") " (?)"))) tlst)); CHANGE column headers
          (rh:AMT c_spc (strcat "TABLE " nme) tlst)
        )
        (t (alert "No Polyline Selected"))
  );end_cond

  (mapcar 'setvar sv_lst sv_vals)
  (princ)
);end_defun

    (defun rh:AMT ( spc title lst / ipt t_obj rows cols row cell rdat)

  (setq ipt (getpoint "\nSelect Table Insertion Point: ")
        t_obj (vla-addtable spc (vlax-3d-point ipt) (1+ (length lst)) (length (car lst)) 5.0 22.5)
  );end_setq

  (vla-put-regeneratetablesuppressed t_obj :vlax-true)

  (mapcar '(lambda (x y) (vlax-put-property t_obj x y)) (list 'horzcellmargin 'vertcellmargin 'rowheight) (list 0.5 0.5 5.0))
  (vla-settextstyle t_obj (+ acDataRow acHeaderRow acTitleRow) "TOPOCAD")

  ; Title row
  (vlax-invoke t_obj 'setrowheight 0 10.0)
  (vlax-invoke t_obj 'setcelltextheight 0 0 2.5)
  (vlax-invoke t_obj 'settext 0 0 title)

  (setq rows (- (vlax-get t_obj 'rows) 2)
        cols (1- (vlax-get t_obj 'columns))
        row 1
        cell 0
  );end_setq

  ; loop through data cells
  (while (< row rows)
    (setq rdat (nth (- row 1) lst))
    (while (<= cell cols)
      (vlax-invoke t_obj 'setcelltextheight row cell 2.5)
      (vlax-invoke t_obj 'settext row cell (nth cell rdat))
      (vlax-invoke t_obj 'setcellalignment row cell acMiddleCenter)
      (setq cell (1+ cell))
    );end_while
    (setq row (1+ row) cell 0)
  );end_while
  (repeat 2
    (vlax-invoke t_obj 'setrowheight row 6.0)
    (vlax-invoke t_obj 'mergecells row row 0 cols)
    (setq rdat (nth (1- row) lst))
    (vlax-invoke t_obj 'setcelltextheight row 0 2.5)
    (vlax-invoke t_obj 'settext row 0 (car rdat))
    (setq row (1+ row))
  );end_repeat
  (vla-put-regeneratetablesuppressed t_obj :vlax-false)
);end_defun


Dlanor

  • Bull Frog
  • Posts: 260
Re: help with coordinate table with area
« Reply #16 on: September 07, 2020, 06:18:05 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")

What version of AutoCAD are you using? The GET/SETPROPERTYVALUE and DUMPALLPROPERTIES weren't implimented until 2012. If you have a later version you may have another problem.  :thinking: 


BIGAL

  • Swamp Rat
  • Posts: 516
  • 30 + years of using Autocad
Re: help with coordinate table with area
« Reply #17 on: September 07, 2020, 08:48:01 PM »
Bricscad does not support get set property also.
A man who never made a mistake never made anything

PM

  • Newt
  • Posts: 127
Re: help with coordinate table with area
« Reply #18 on: September 11, 2020, 01:58:16 AM »
Hi Dlanor . I test a lot this code and i see that export to a table the coordinates of all block are near or even touch a polyline. I want to export only the blocks are on vertices of the polyline, because when i have a lot of points become chaos. Look the test.dwg . Is a simple example

Thanks

Dlanor

  • Bull Frog
  • Posts: 260
Re: help with coordinate table with area
« Reply #19 on: September 11, 2020, 02:49:25 AM »
Not much I can do at the moment, I won't have time to look at it until late afternoon. I know what the solution is but no time to code it.

BIGAL

  • Swamp Rat
  • Posts: 516
  • 30 + years of using Autocad
Re: help with coordinate table with area
« Reply #20 on: September 11, 2020, 03:22:24 AM »
Maybe this simple test

Code: [Select]
(setq pt (getpoint))
(setq ss (ssget pt (list (cons 0 "insert"))))
(entget (ssname ss 0))
A man who never made a mistake never made anything

BIGAL

  • Swamp Rat
  • Posts: 516
  • 30 + years of using Autocad
Re: help with coordinate table with area
« Reply #21 on: September 11, 2020, 03:25:31 AM »
Translating lisp code can only really translate the messages or questions. The code seems to still need the operations to be in english.

"Insertion Units are Millimetres. Convert Areas & Coordinates to Metres : ?" "No") "Yes")
A man who never made a mistake never made anything

PM

  • Newt
  • Posts: 127
Re: help with coordinate table with area
« Reply #22 on: September 11, 2020, 04:29:01 AM »
Ok Dlanor i will wait . Thanks

HOSNEYALAA

  • Newt
  • Posts: 53
Re: help with coordinate table with area
« Reply #23 on: September 11, 2020, 07:53:25 AM »
اhi Dlanor  and PM

Block selection by fence
;;; ss (ssget "F" vlst '((0 . "INSERT") (66 . 1)))


Therefore, he chooses the blocks that pass through the polyline
The solution is primarily to scale all blocks by .8 so as not to choose the side blocks



HOSNEYALAA

  • Newt
  • Posts: 53
Re: help with coordinate table with area
« Reply #24 on: September 11, 2020, 07:56:40 AM »
this

d2010

  • Newt
  • Posts: 77
Re: help with coordinate table with area
« Reply #25 on: September 11, 2020, 09:33:09 AM »
Block selection by fence
;;; ss (ssget "F" vlst '((0 . "INSERT") (66 . 1)))
Step01) I add inside maxp and minp and calculateIterator between line07...line11
Code - Auto/Visual Lisp: [Select]
  1.   (setq noe (getint "\nEnter AreaName:(1.Youtube)(2.Facebook)(3.Yeromonah)(5.Handle):"))
  2.   (if (= noe 1) (setq mne "https://youtu.be/LGZ8aZXDkI4")
  3.     (if (= noe 2)
    --I restore to 100%Vlisp from code-source-step01. :wideeyed2:
    Step02)
    Step03)I compile the secondsource to
    • autoarom_jsldc11.lsp
    • autoarom_jsdup35.lsp
    Step04)I compile the mainsource to
    • MyPin-Code for Execute 6473=pp_tablegreece_jspin15.lsp
    • pp_tablegreece.lsp
« Last Edit: September 11, 2020, 12:17:13 PM by d2010 »

Dlanor

  • Bull Frog
  • Posts: 260
Re: help with coordinate table with area
« Reply #26 on: September 11, 2020, 09:43:10 AM »
Ok Dlanor i will wait . Thanks

Attached is revised lisp. This checks that the block is on the polyline, and within 10mm of a vertex. This should eliminate blocks on the polyline but not close to a vertex.

If the block isn't on the polyline it checks if the block is within 10mm of the polyline and 10mm of a vertex (max dist 14.14mm) This will eliminate blocks not on a vertex and not on the polyline.

This will allow for a minor misplacement of a block that perhaps should be on a polyline. Whatever happens the listed x and y coords are the coords of the closest vertex.

If you want this changing, please let me know.


PM

  • Newt
  • Posts: 127
Re: help with coordinate table with area
« Reply #27 on: September 11, 2020, 10:31:06 AM »
hi Dlanor. Now gives me this error

Quote
An Error : too many arguments occurred.


Dlanor

  • Bull Frog
  • Posts: 260
Re: help with coordinate table with area
« Reply #28 on: September 11, 2020, 10:49:16 AM »
Oops, added the correct file from the wrong location.  :crazy2:

Attached

PM

  • Newt
  • Posts: 127
Re: help with coordinate table with area
« Reply #29 on: September 11, 2020, 11:06:49 AM »
I have the same problem with the blocks near polyline .check the test2.dwg. Is problem because i can not trust the results of the table. I have any time to check all the coordinates.

Is not any other way to export polyline coordinates and use the names of the blocks on polyline vertex ?

HOSNEYALAA

  • Newt
  • Posts: 53
Re: help with coordinate table with area
« Reply #30 on: September 11, 2020, 11:27:43 AM »
Block selection by fence
;;; ss (ssget "F" vlst '((0 . "INSERT") (66 . 1)))
Step01) I add inside maxp and minp and calculateIterator between line07...line11
Code - Auto/Visual Lisp: [Select]
  1.       for(elev=nil;cnt>=0;cnt=cnt-1)
  2.             bent=ssname(ss,cnt),
  3.             blk=vlax_ename2vla_object(bent),
  4.             atts=vlax.invoke(blk,read("getattributes")),
  5.             elev=foreach(atv,atts,(vla.get_tagstring(atv)=="POINT")?vla.get_textstring(atv):elev),
  6.             ptc=vlax.get(blk,read("insertionpoint")),
  7.             maxp=(maxp==nil)?ptc:(car(maxp)<car(ptc))?list(car(ptc),cadr(maxp),0.0):maxp,
  8.             maxp=(cadr(maxp)<cadr(ptc))?list(car(maxp),cadr(ptc),0.0):maxp,
  9.             minp=(minp==nil)?ptc:(car(minp)>car(ptc))?list(car(ptc),cadr(minp),0.0):minp,
  10.             minp=(cadr(minp)>cadr(ptc))?list(car(minp),cadr(ptc),0.0):minp,
  11.             tlst=cons(list(elev,rtos(car(ptc),2,acc),rtos(cadr(ptc),2,acc)),tlst);
  12.  
    --I restore to 100%Vlisp from code-source-step01. :wideeyed2:
    Step02)You will get greatEffects , If you insert Youtube/Links  inside Table.
    Step03)I compile the secondsource to
    • autoarom_jsldc11.lsp
    • autoarom_jsdup35.lsp
    Step04)I compile the mainsource to
    • MyPin-Code for Execute 6473=pp_tablegreece_jspin15.lsp
    • pp_tablegreece.lsp

I'm sorry my english is not good
If you explain on a DRAWING what you want
Do you want to merge the codes?

d2010

  • Newt
  • Posts: 77
Re: help with coordinate table with area
« Reply #31 on: September 11, 2020, 11:42:18 AM »
I'm sorry my english is not good. If you explain on a DRAWING what you want
Do you want to merge the codes?
Your Lisp is very good and work fine.
Do you want to merge the codes? No. I want, if you insert many "https://www.youtube.com/xxxxx" inside table@drawing.dwg
then you will get  great-true-Effects.
You fill the table@drawing.dwg with  *www.youtube* & own-adresses(xxxxx), I hope you will get more happy.Thanks./

« Last Edit: September 11, 2020, 12:05:24 PM by d2010 »

PM

  • Newt
  • Posts: 127
Re: help with coordinate table with area
« Reply #32 on: September 11, 2020, 12:22:03 PM »
i want when export only the coordinates on polyline vertises with the number of the attribiute block in corect order.

in tes2dwg i have the numbers 32-33-34-k40

when i pick nmber 32 the correct order is  32-33-34-k40 but the pat.lsp gives me

32-k40-33-34 because k40 touch two sides of the polyline. This is the problem . Thats why i ask to export only the coordinates of vertices and no other. if the code search to find blocks neat the polyline the coordinates never be correct.

if for a reson one block is not on the polyline by mistake this code will export wrong coordinates. It is a big risk !!!

thanks

HOSNEYALAA

  • Newt
  • Posts: 53
Re: help with coordinate table with area
« Reply #33 on: September 11, 2020, 02:36:27 PM »
I'm sorry my english is not good. If you explain on a DRAWING what you want
Do you want to merge the codes?
Your Lisp is very good and work fine.
Do you want to merge the codes? No. I want, if you insert many "https://www.youtube.com/xxxxx" inside table@drawing.dwg
then you will get  great-true-Effects.
You fill the table@drawing.dwg with  *www.youtube* & own-adresses(xxxxx), I hope you will get more happy.Thanks./



thank you so much
But I didn't write the LISP
Which was written by  Dlanor

As for your idea is beautiful

Dlanor

  • Bull Frog
  • Posts: 260
Re: help with coordinate table with area
« Reply #34 on: September 11, 2020, 02:40:11 PM »
The x and y coordinates in the table should be the vertices of the polyline, not the insertion point of the block.

The problem you were seeing was caused by the selection method and the cannoscale setting. The fence selection should pick the blocks in the correct order, but it picking up the K40 block in the wrong place and not filtering it because its insertion point is on the polyline. The quickest method to get round this is to temporarily set the cannoscale to 1:1m, make the selection then reset it. This of course all hinges on 1:1m being present as an annotative scale in all drawings.

This works well in my tests, but requires two regens of the current viewport (modelspace) which I have included. However this may slow down the lisp if you have a large drawing. The only other alternative that come immediately to mind is to make multiple selection set selections at every vertex and hope that the point in the centre of the block is found. This would require some sort of a re-write, but I have something that I may be able to adapt (when I can find it).

Attached is the revised lisp, I also found and re-corrected the problem of not starting at certain points.

 

PM

  • Newt
  • Posts: 127
Re: help with coordinate table with area
« Reply #35 on: September 11, 2020, 05:35:21 PM »
Thank you Dlanor. I test the code and i think it work fine. Thanks for your time.  :smitten:

PM

  • Newt
  • Posts: 127
Re: help with coordinate table with area
« Reply #36 on: September 12, 2020, 01:15:31 AM »
Hi Dianor one last question. I know if i want to change tab from model space to layout  use

Code - Auto/Visual Lisp: [Select]
  1.    (command "_.Tilemode" 0)
  2.  

I add this command before "Select Table Insertion Point " but the table insert in modelspace. How to change it to insert the table in layout ?

Thanks

d2010

  • Newt
  • Posts: 77
Re: help with coordinate table with area
« Reply #37 on: September 12, 2020, 05:44:23 AM »
You replace ~ (command "_.Tilemode" 0)~
with ~(setvar "tilemode" 1) or (setvar "tilemode" 0)~
When you use (command..) you check the command is active or not.

Code - Auto/Visual Lisp: [Select]
  1.    (command "_.Tilemode" 0)
  2.  

Dlanor

  • Bull Frog
  • Posts: 260
Re: help with coordinate table with area
« Reply #38 on: September 12, 2020, 08:40:27 AM »
Hi Dianor one last question. I know if i want to change tab from model space to layout  use

Code - Auto/Visual Lisp: [Select]
  1.    (command "_.Tilemode" 0)
  2.  

I add this command before "Select Table Insertion Point " but the table insert in modelspace. How to change it to insert the table in layout ?

Thanks

See amended attached lisp.

You can now start in Paperspace and it will switch to Modelspace. After entering the Table name you will be asked "Modelspace" or "Paperspace" using the dynamic prompt (default "Modelspace")

If you select "Paperspace" it will switch before asking for an insertion point. Tested and working, but haven't had time to test all cases. Everything should be reset on exit.

I will try to refine this when I have time but "She who must be obeyed" has other plans for my time this weekend, and I would rather it was  :smitten: than  :knuppel2: and :tickedoff:
 

PM

  • Newt
  • Posts: 127
Re: help with coordinate table with area
« Reply #39 on: September 12, 2020, 11:59:38 AM »
Thanks Dlanor

i add this 4  lines to change table colum width

Code - Auto/Visual Lisp: [Select]
  1.   (repeat 2
  2.     (vlax-invoke t_obj 'setrowheight row 6.0)  
  3.     (vlax-invoke t_obj 'mergecells row row 0 cols)
  4.     (setq rdat (nth (1- row) lst))
  5.     (vla-put-width t_obj 75); width of all table
  6.     (vla-setcolumnwidth t_obj 0 15); width A/A
  7.     (vla-setcolumnwidth t_obj 1 30);width X
  8.     (vla-setcolumnwidth t_obj 2 30); width Y
  9.     (vlax-invoke t_obj 'setcelltextheight row 0 2.5)
  10.     (vlax-invoke t_obj 'settext row 0 (car rdat))
  11.     (setq row (1+ row))
  12.   );end_repeat
  13.  
  14.  

I didnt change ths line and the code works.But i think this 22.5 is not nessesary

Code - Auto/Visual Lisp: [Select]
  1.         t_obj (vla-addtable spc (vlax-3d-point ipt) (1+ (length lst)) (length (car lst)) 5.0 22.5) ; all colum width 22.5
  2.  

Is important to change it or doesn't mater ?

Thanks

Dlanor

  • Bull Frog
  • Posts: 260
Re: help with coordinate table with area
« Reply #40 on: September 12, 2020, 01:17:49 PM »
It's not important if you are changing the column widths later, but something has to be there or it won't create the table and will error.