Jump to content

Area table with plot number text + Area


Ish

Recommended Posts

Dear members,

 

Any lisp program or trick to make a area table

From a  plan.

I want a area table with plot number text along with area .

I will select all at time, the automatically generate area table.

 

Please See the attached image.

 

IMG_20210726_092717.jpg

AREA TABLE OF POLYGON.dwg

IMG_20210725_130140.jpg

Edited by Ish
Modified again
Link to comment
Share on other sites

But sir I need plot number also,

According leemac only area is coming.and 

I think we have to pick or select one by one also.

 

I need plot number text and  area of that plot.

Link to comment
Share on other sites

So this will get the text written in the rectangles, assuming they are polylines. Largely untested though, it is Sunday. See the 'princ' at the end for where the text is.

 

After that you could modify Lee Macs  LISP to add these names in, good luck to that, I have never been very successful in working out how he does things.

 

(defun c:txtinrect( / mytext myrectss acount)

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-xy-coordinates-of-2d-rectangle-lwpolyline/td-p/846832
  (defun massoc (key alist / x nlist)
    (foreach x alist
      (if (eq key (car x))
        (setq nlist (cons (cdr x) nlist))
      )
    )
    (reverse nlist)
  ) ;end

;;get rectangles
  (setq myrectsss (ssget '((0 . "LWPOLYLINE"))))

  (setq acount 0)
  (while (< acount (sslength myrectsss))
    (setq mycoords (massoc 10 (entget (ssname myrectsss acount))))
    (setq pt1 (nth 0 mycoords))
    (setq pt2 (nth 2 mycoords))
    (setq mytext (ssname (ssget "_W" pt1 pt2 '((0 . "*text"))) 0))

(princ (vla-get-textstring (vlax-ename->vla-object mytext))) ;;each text withn a rectangle

    (setq acount (+ 1 acount))
  )

)

 

 

you could also look at this to get the area of a rectangle using pt1 and pt2 above,

 

 

and then just find a lisp to create a table using these... it is Sunday though, TV to watch....

 

Link to comment
Share on other sites

You really need to have a go your just using this forum as a write it for me. Your community reputation is -19 not good. There is plenty of examples out there how to do this task. 

Link to comment
Share on other sites

The attached image just for example,

In main file there no rectangular shape,

Each shape are different .

Like a polygon, that's why pick point aur corner to corner selection will not be a solution.

Thanks

 

 

IMG_20210726_092717.jpg

AREA TABLE OF POLYGON.dwg

Edited by Ish
Modified
Link to comment
Share on other sites

(defun C:ADDTAB (/ ss lista2d arealist index ename listpoint pointtable objtable)
 (if (not (setq ss (ssget '((0 . "LWPOLYLINE")(8 . "BOUNDARY")))))
  (vl-exit-with-error "")
 ) 
 (defun lista2d (lst)
  (if lst
   (cons (list (car lst) (cadr lst)) 
	(lista2d (cddr lst))
   )
  )
 )
 (setq arealist '())
 (repeat (setq index (sslength ss))
  (setq ename (ssname ss (setq index (1- index))))
  (setq listpoint (lista2d (safearray-value (variant-value (vla-get-Coordinates (vlax-ename->vla-object ename))))))
  (if (not (setq sstext (ssget "_WP" listpoint '((0 . "MTEXT")(8 . "TABLE TEXT")))))
   (ssdel ename ss)
   (setq arealist (cons (list (vla-get-Textstring (vlax-ename->vla-object (ssname sstext 0))) (vla-get-Area (vlax-ename->vla-object ename))) arealist))
  ) 
 )
 (setq pointtable (getpoint "\nSelect point insertion table: ") 
       objtable (vla-AddTable (vla-get-modelspace (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-3d-Point pointtable) (+ 2 (sslength ss)) 2 6 17)
       index 0
 )
 (vla-SetText objtable index 0 "AREA TABLE")
 (vla-SetCellTextHeight objtable index 0 2.40)
 (vla-SetCellAlignment objtable index 0 acMiddleCenter)
 (vla-SetText objtable (setq index (1+ index)) 0 "PLOT NO.")
 (vla-SetCellTextHeight objtable index 0 2.10)
 (vla-SetCellAlignment objtable index 0 acMiddleCenter)
 (vla-SetText objtable index 1 "AREA")
 (vla-SetCellTextHeight objtable index 1 2.10)
 (vla-SetCellAlignment objtable index 1 acMiddleCenter)
 (foreach elem arealist
  (vla-SetText objtable (setq index (1+ index)) 0 (car elem))
  (vla-SetCellTextHeight objtable index 0 2.40)
  (vla-SetCellAlignment objtable index 0 acMiddleCenter) 
  (vla-SetText objtable index 1 (rtos (cadr elem) 2 3))
  (vla-SetCellTextHeight objtable index 1 2.10)
  (vla-SetCellAlignment objtable index 1 acMiddleCenter)
 )
) 

 

This should be fine. The programme selects the polylines on the BOUNDARY layer, the vertices of the polylines act as a selection for any text inside. If there is no text, the polyline is deleted from the selection set, otherwise a list is created with the text string and the corresponding polyline area. The rest is easy, the table is created with the list data in the AREALIST variable.

Edited by confutatis
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

You should be able to get the extents of each polygon using in my example if you modify Pt1 and Pt2 in my example making them up with the maximum and minimum values of x and y in the list of coordincates, and there should be example of this online.... like Big Al suggests, you have a couple of starting points now, have a go modifying these examples and let us know where you get stuck after this

Link to comment
Share on other sites

(defun C:ADDROWTAB (/ ss lista2d index ename listpoint objtable)
 (setvar "NOMUTT" 1)
 (princ "\nSelect table: ")
 (setq objtable (ssget "_+.:E:S" '((0 . "ACAD_TABLE"))))
 (setvar "NOMUTT" 0)
 (if (not (and  (setq ss (ssget '((0 . "LWPOLYLINE")(8 . "BOUNDARY"))))))
  (vl-exit-with-error "")
 ) 
 (defun lista2d (lst)
  (if lst
   (cons (list (car lst) (cadr lst)) 
	(lista2d (cddr lst))
   )
  )
 )
 (setq arealist '())
 (repeat (setq index (sslength ss))
  (setq ename (ssname ss (setq index (1- index))))
  (setq listpoint (lista2d (safearray-value (variant-value (vla-get-Coordinates (vlax-ename->vla-object ename))))))
  (if (not (setq sstext (ssget "_WP" listpoint '((0 . "MTEXT")(8 . "TABLE TEXT")))))
   (ssdel ename ss)
   (setq arealist (cons (list (vla-get-Textstring (vlax-ename->vla-object (ssname sstext 0))) (vla-get-Area (vlax-ename->vla-object ename))) arealist))
  ) 
 )
 (setq objtable (vlax-ename->vla-object (ssname objtable 0)))
 (setq stringlist '()
       index 0
 )      
 (while (/= (vla-GetText objtable index 0) "")
  (setq stringlist (cons (vla-GetText objtable index 0) stringlist))
  (setq index (1+ index))
 ) 
 (mapcar '(lambda (elem) (if (equal (car elem) (car (member (car elem) stringlist))) (setq arealist (vl-remove elem arealist)))) arealist)
 (setq index (vla-get-Rows objtable))
 (foreach elem arealist
  (vla-InsertRows objtable index 6 1)
  (vla-SetText objtable index 0 (car elem))
  (vla-SetCellTextHeight objtable index 0 2.40)
  (vla-SetCellAlignment objtable index 0 acMiddleCenter) 
  (vla-SetText objtable index 1 (rtos (cadr elem) 2 3))
  (vla-SetCellTextHeight objtable index 1 2.10)
  (vla-SetCellAlignment objtable index 1 acMiddleCenter)
  (setq index (1+ index))
 )
 (princ)
)

 

Since I have a lot of fun programming in autolisp, I just modified the ADDTAB program with a few changes.  The program adds rows to the table, selected additional polylines, without having to redo the table. If an area is already present in the table, it is not inserted again in the table.

Edited by confutatis
  • Like 1
Link to comment
Share on other sites

@confutatis my 2¢ might want to add a closed poly check when selecting the polylines on the boundary layer. you can still return an area on an open polyline and it might not be the full plot area.

 

(if (not (and  (setq ss (ssget '((0 . "LWPOLYLINE")(8 . "BOUNDARY")(70 . 1))))))

 

Also I didn't know this about 3 months ago but WP works great with polylines unless its has arcs. if you use the polyline vertices with WP selection window it will cut corners when their is an arc. Example it wont pick up "test1" text because its outside the white selection window. granted this probably isn't a problem with plots, but caused quite a bit of finger pointing at my work when one of my commands wasn't picking up everything "inside" the polyline.

 

fix here

 

 

image.thumb.png.6e2bb6ff2b7ca71a414fcec43af5e8b1.png

 

 

Edited by mhupp
  • Agree 1
Link to comment
Share on other sites

You're right, I hadn't accounted for closed polylines, though it should be the post author's job to verify that. However, the problem is easily solved with a fairly trivial command that I created some time ago and that is the closure of all open polylines selected, even those with the first vertex coincident with the last, but considered open. As for WP selection on curves, I had created a program similar to Lee Mac's, to convert arcs to line segments. I didn't look closely, but it seemed to me that there were no curves on polylines. What is represented on the DWG should be cadastral parcels, usually defined by polylines with no curved lines.

Link to comment
Share on other sites

2 hours ago, confutatis said:

I didn't look closely, but it seemed to me that there were no curves on polylines.

 

I just wanted to vent.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...