Help with numbering points

Help with numbering points

Anonymous
Not applicable
1,662 Views
8 Replies
Message 1 of 9

Help with numbering points

Anonymous
Not applicable

Salutations!

 

I have a problem. I need to create a set of numbered points from  polyline vertex (.-.-.-. to 1-2-3-n) and I know how to create the points based on the polyline, but I need to create em with object data attached with the number, in order to form a path.

 

sorry for the bad english and thanks for any help you can provide

0 Likes
Accepted solutions (1)
1,663 Views
8 Replies
Replies (8)
Message 2 of 9

john.uhden
Mentor
Mentor

i am not comprehending.  The polyline IS a path.  What can numbering the vertices do for you?

John F. Uhden

0 Likes
Message 3 of 9

Anonymous
Not applicable
Yes actually
the polyline is a path; Its to represent the garbage colllector trucks in
my hometown. thay provide us with polylines only and I need the nodes
numbered, because thy use a software that takes those points and make a
little truck follow the path in a map. from point to point. I tried ussing
topology but the order the nodes get is from top to bottom and not in the
sequence of the line.
0 Likes
Message 4 of 9

dbhunia
Advisor
Advisor

Explain more with sample.......

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 5 of 9

john.uhden
Mentor
Mentor
Accepted solution

Okay.  Then presuming the polyline is drawn in the correct direction (numerically ascending), then something like this can work...

(defun c:TruckPath ( / ts th e ent pts i p)
  (and
    (setq ts (* 1 (getvar "textsize")))
    (setq th (cdr (assoc 40 (entget (tblobjname "style" (getvar "textstyle"))))))
    (setq e (car (entsel "\nSelect polyline path: ")))
    (setq ent (entget e))
    (or
      (= (cdr (assoc 0 ent)) "LWPOLYLINE")
      (prompt "\nObject selected is not an LWPOLYLINE.")
    )
    (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x)(= (car x) 10)) ent)))
    (setvar "cmdecho" 0)
    (setq i 0)
    (foreach p pts
      (setq p (mapcar '+ p (list ts 0.0 0.0)))
      (if (zerop th)
        (vl-cmdf "_.text" "_non" p "" 0.0 (itoa (setq i (1+ i))))
        (vl-cmdf "_.text" "_non" p 0.0 (itoa (setq i (1+ i))))
      )
    )
  )
  (setvar "cmdecho" 1)
  (princ)
)

Of course it is lacking error and undo controls, but we/you can add those if necessary.

John F. Uhden

Message 6 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:
.... thay provide us with polylines only and I need the nodes numbered....

 

Here's a way that will number the vertices of either a LightWeight or a "heavy" Polyline [including a 3D one].

(vl-load-com)
(defun C:NPV (); = Number Polyline Vertices (if (and (setq esel (entsel "\nSelect Polyline: ")) (wcmatch (cdr (assoc 0 (entget (setq pl (car esel))))) "*POLYLINE") ); and (repeat ; then (setq n (fix (+ (vlax-curve-getEndParam pl) (if (vlax-curve-isClosed pl) 0 1)))) (command "_.text" "_mc" "_none" (vlax-curve-getPointAtParam pl (setq n (1- n))) "" 0 (itoa (1+ n)) ;;; [omit the "" if current Text Style is of fixed height] ); command ); repeat (prompt "\nNothing selected, or not a Polyline.") ); if (princ) ); defun

It uses whatever the current Text Style and height are -- a specific one could be built in if desired, and even created if it doesn't already exist in the drawing.

Kent Cooper, AIA
0 Likes
Message 7 of 9

Anonymous
Not applicable

This is it!!!!
this worked wonders for me

Thank you a lot!!

I was overcomplicating myself with entmake and other stuff

0 Likes
Message 8 of 9

john.uhden
Mentor
Mentor
That's great news!
I usually prefer entmake but I've had situations where it would blow up
AutoCAD.
As @Kent1Cooper seems to prefer, the command and vl-cmdf functions just
plain work. Though many people stumble not recognizing that they have to
know whether the text style height is zero or not.
The only major shortcoming in what I provided you was allowing for only
LWpolylines. If you need it, I have a preferred way of handling the
heavies.

John F. Uhden

0 Likes
Message 9 of 9

Sea-Haven
Mentor
Mentor

I found using the Vl 'coordinates the easiest way to get around 2d and 3d plines its just a case of 2 or 3 items make a point in the result from the 'coordinates just check what object is and divide by 2 o r 3 for number of points.

 

(defun getcoords (ent)
  (vlax-safearray->list
    (vlax-variant-value
      (vlax-get-property
    (vlax-ename->vla-object ent)
    "Coordinates"
      )
    )
 )
)
(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
0 Likes