Jump to content

Fill in ascending numbers on each polylines vertex


Recommended Posts

Posted

Hello all

I have many polylines that I want to fill in numbers in the same order as the attached drawing. currently i have Vladimir Azarko's code. Can anyone help me to change this code to achieve the result. Thank youtest5.dwgcoorNp.lsp

Posted

This is just a simple lisp unlike coonp.lsp it will ask for a selection of polylines and then create text middle center on their vertices and on the same layer as the polyline.

"i" or the text number is reset for every polyline. So the start of the polyline will always be 1

 

But two things.

  • Because of the annotative text in another drawing text could be a different size.
  • the text ues the right style but annotative is set to no so you might have to change that after the fact (cant figure it out)
;;----------------------------------------------------------------------------;;
;; Add text to all Polylines Vertices
(defun C:PolyNumber (/ SS i lay poly)
  (if (setq ss (ssget '((0 . "*POLYLINE"))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq i 1 lay (cdr (assoc 8 (setq poly (entget ent)))))
      (foreach pt (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) poly))
        (entmake (list '(0 . "TEXT")
                        (cons 8 lay)
                        (cons 10 pt)
                        (cons 11 pt)
                       '(40 . 500)
                       '(41 . 0.85)
                        (cons 1 (rtos i 2 0))
                       '(72 . 4)
                       '(73 . 2)
                 )
          )
          (setq i (1+ i))
      )
    )
  )
  (princ)
)

 

  • Like 1
Posted
On 11/20/2022 at 3:45 AM, mhupp said:

This is just a simple lisp unlike coonp.lsp it will ask for a selection of polylines and then create text middle center on their vertices and on the same layer as the polyline.

"i" or the text number is reset for every polyline. So the start of the polyline will always be 1

 

But two things.

  • Because of the annotative text in another drawing text could be a different size.
  • the text ues the right style but annotative is set to no so you might have to change that after the fact (cant figure it out)
;;----------------------------------------------------------------------------;;
;; Add text to all Polylines Vertices
(defun C:PolyNumber (/ SS i lay poly)
  (if (setq ss (ssget '((0 . "*POLYLINE"))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq i 1 lay (cdr (assoc 8 (setq poly (entget ent)))))
      (foreach pt (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) poly))
        (entmake (list '(0 . "TEXT")
                        (cons 8 lay)
                        (cons 10 pt)
                        (cons 11 pt)
                       '(40 . 500)
                       '(41 . 0.85)
                        (cons 1 (rtos i 2 0))
                       '(72 . 4)
                       '(73 . 2)
                 )
          )
          (setq i (1+ i))
      )
    )
  )
  (princ)
)

 

thank you very much

Posted

I have this code which is very similar to your request.
It numbers with a block but also informs the cumulated length of the vertex, its position in X,Y,Z.
This can allow data to be extracted to a block attribute file for external processing.

BlockAtt2Vtx.lsp

  • Like 1
Posted
58 minutes ago, Tsuky said:

I have this code which is very similar to your request.
It numbers with a block but also informs the cumulated length of the vertex, its position in X,Y,Z.
This can allow data to be extracted to a block attribute file for external processing.

BlockAtt2Vtx.lsp 18.9 kB · 1 download

Great, thank you

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