Jump to content

Recommended Posts

Posted

How are you with making up a LISP?

 

If you use something like 

(setq MyText (entget (car (Entsel "Select Text"))))

 

this will give you a list of all of that text attributes. If you use the assoc command then you can extract the values to use elsewhere, so you might try something like

(setq MyTextValue (assoc 1 MyText)) ;; Gives you the text string, for example C10

 

and you can use the getpoint command to cet the coordinates of the corner

(setq MyCoords (getpoint "Get Point"))

(setq MyXCoord (nth 0 MyCoords))
(setq MyYCoord (nth 1 MyCoords))
(setq MyZCoord (nth 2 MyCoords))

 

 

So if you put all this together and into a LISP you should be able to make up a routine that asks for the label and also the corner point of the 2 lines. Just need to make a table after. For your table do you want it to be created as you select the points and text, or after you have selected them all, and do you want the table to be lines and text or as a table object?

 

 

 

 

There is probably a clever way to do this with just selecting the text or the corner and LISP will find the other but the above works in a simple way.

  • Like 1
Posted

props @Steven P But if they cant even take the time to type a few sentences I'm out.

  • Like 2
Posted

@ cepsoe12  For better understanding, and  maybe get further help, please upload such sample.dwg
As far as I know, ACAD only can edit DWG.
 Or send it to devitg@gmail.com 

Posted

No header, no title, and merge cell 0,0 1,0

 

For me draw the title part, then as pick text,  add row to table much easier than lines and text.

 

Devitg has it under control. 

 

Posted

So back to the top, how are your skills with putting this all together?

Looking at your example table, lines and text, you can find many examples to draw them using LISP out there with an internet search. I'm on holiday next week however might be appreciated if you can let us know what you have managed to do with this so far and where you need help. For example, you might want help creating the text in a table but can draw the lines and get the data by a LISP, it might be that you can't do any programming at all - both are good but we do like to know so we can help you better.

Posted

Here is a start, like StevenP Google is your friend. make-example-table.lsp

 

A double check is to select text then double check find the nearest pline vertice point and use that, if your text is not exactly on a point you will get a incorrect answer.

  • Like 1
Posted

Here you go with waterproof version and you can find my website address at the top of the codes if you would like to donate for the time I spent on this complete program for you. :) 

 

(defun c:Test (/ tbl ins row col int sel ent get pts rtn tbl txt)
  ;;------------------------------------------------------------;;
  ;;	Author: Tharwat Al Choufi - Date: 28.Mar.2022		;;
  ;;	website: https://autolispprograms.wordpress.com		;;
  ;;------------------------------------------------------------;;
  (and
    (setq sel (car (entsel "\nPick polyline : ")))
    (or (= (cdr (assoc 0 (setq get (entget sel)))) "LWPOLYLINE")
        (alert "Invalid object. Try again")
    )
    (princ
      "\nSelect texts that represent the previously selected polyline : "
    )
    (setq int -1
          sel (ssget (list '(0 . "TEXT")))
    )
    (foreach itm get
      (or (and (= (car itm) 10)
               (setq
                 pts (cons
                       (list (setq int (1+ int)) (append (cdr itm) '(0.0)))
                       pts
                     )
               )
          )
          t
      )
    )
    (setq int -1)
    (or (while (setq int (1+ int)
                     ent (ssname sel int)
               )
          (setq get (entget ent)
                ins (cdr (assoc 10 get))
                txt (cdr (assoc 01 get))
          )
          (vl-some
            (function (lambda (q)
                        (and (equal (cadr q) ins 1e-2)
                             (setq rtn (cons (append q (list txt)) rtn))
                        )
                      )
            )
            pts
          )
        )
        t
    )
    (or
      rtn
      (alert
        "None of selected texts belong to any of the vertices of the selected polyline <!"
      )
    )
    (setq ins (getpoint "\nSpecify table insertion point : "))
    (setq tbl (vla-addtable
                (vla-get-modelspace
                  (vla-get-activedocument (vlax-get-acad-object))
                )
                (vlax-3d-point ins)
                (+ (length rtn) 2)
                3
                5.0
                1.0
              )
          row 2
          col -1
    )
    (progn
      (defun Set:text:contents_ (o_ r_ c_ v_)
        (vla-settext o_ r_ c_ v_)
        (vla-setcelltextheight o_ r_ c_ 0.5)
        (vla-setcellalignment o_ r_ c_ acmiddlecenter)
      )
      (mapcar
        '(lambda (w) (vla-setcolumnwidth tbl (setq col (1+ col)) w))
        '(3 5 5)
      )
      (setq col -1)
      (vla-put-RegenerateTableSuppressed tbl :vlax-true)
      (vla-unmergecells tbl 0 0 0 3)
      (vla-mergecells tbl 0 1 0 0)
      (vla-mergecells tbl 0 0 1 2)
      (mapcar '(lambda (s r c)
                 (Set:text:contents_ tbl r c s)
                 (vla-setrowheight tbl r 1.0)
               )
              '("No" "Coordinate" "X" "Y")
              '(0 0 1 1)
              '(0 1 1 2)
      )
      (setq row 2
            col -1
      )
      (foreach itm
               (vl-sort rtn
                        (function (lambda (j k) (= (car j) (car k))))
               )
        (mapcar '(lambda (s c)
                   (Set:text:contents_ tbl row c s)
                 )
                (list (caddr itm)
                      (rtos (car (cadr itm)) 2 4)
                      (rtos (cadr (cadr itm)) 2 4)
                )
                '(0 1 2)
        )
        (vla-setrowheight tbl row 1.0)
        (setq row (1+ row)
              col -1
        )
      )
      (vla-put-RegenerateTableSuppressed tbl :vlax-false)
    )
  )
  (princ)
) (vl-load-com)

 

  • Like 1
  • Thanks 1
Posted
7 hours ago, cepsoe12 said:

Thank you    😍

You're welcome anytime. :) 

Posted

can without select polyline first? 

Posted
13 hours ago, cepsoe12 said:

can without select polyline first? 

Does that mean that you have one polyline in a drawing ?

And what about the related texts ?

 

You need to elaborate your request a bit further.

  • Thanks 1
  • 2 weeks later...

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