Author Topic: polyline at 60m  (Read 2269 times)

0 Members and 1 Guest are viewing this topic.

mcn

  • Guest
polyline at 60m
« on: November 18, 2009, 10:46:24 AM »
Dear All,

I have one project in which i have to draw polylines and points.
The length of a polyline must be 50m and after one polyline i have to put a point.
There is a lisp for this?
or a lisp to select the line and then to split-it into segments of 50m and add point at the end of the segments?

In advanced Thank You!

B.R.,
Marius

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: polyline at 60m
« Reply #1 on: November 18, 2009, 10:48:16 AM »
have you looked at using the DIVIDE or MEASURE commands?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: polyline at 60m
« Reply #2 on: November 18, 2009, 11:01:31 AM »
Marius,
Are the polylines one object with 50m segments or separate plines 50m long?
Is the point object required at the beginning & end of the pline or just at 50m?
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: polyline at 60m
« Reply #3 on: November 18, 2009, 11:03:19 AM »
How about a making a block then insert it / rotate it / explode it?
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright 2016

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: polyline at 60m
« Reply #4 on: November 18, 2009, 11:27:23 AM »
Just to add points to a pline.
Code: [Select]
(defun c:AddPoints (/ ent elst pts)
  (while
    (cond
      ((null (setq ent (car (entsel "\nSelect pline."))))
       (princ "\nMissed, Try again.")
      )
      ((equal (assoc 0 (entget ent)) '(0 . "LWPOLYLINE")) nil)
      (t (princ "\nError- Not a ployline. Try again."))
    )
  )
  (setq elst (entget ent)
        pts  (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst))
  )
  (mapcar
    (function
      (lambda (pt)
        (entmake
          (list (cons 0 "POINT")
                (cons 6 "BYLAYER")
                (cons 8 "0")  ; layer, comment out for current layer
                (cons 10 pt)
                (cons 62 256)
          )
        )
      )
    )
    pts
  )
  (princ)
)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: polyline at 60m
« Reply #5 on: November 18, 2009, 12:16:26 PM »
or if all it is a a straight polyline segment (assuming no arcs); one could
draw the polyline, place a point on one end.
select both objects, and make a group out of them...then copy the group as many time as was required...
or without making a group..select the objects...grab hold of one of the grips....hit the SPACEBAR to switch from the STRETCH command, into the COPY command, and then copy as many as was required...

however if it a continuous polyline with arcs...that is in need of a point at a specified distance I would use Divide, or Measure command.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

mcn

  • Guest
Re: polyline at 60m
« Reply #6 on: November 18, 2009, 09:51:26 PM »
Marius,
Are the polylines one object with 50m segments or separate plines 50m long?
Is the point object required at the beginning & end of the pline or just at 50m?


CAB,

the plines should be separate objects 50m long each segment.
The point is required on both sides beginning and end.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: polyline at 60m
« Reply #7 on: November 18, 2009, 11:17:07 PM »
How are you placing them? Picking start & end point or start point & angle or other method?

The routine I posted will add points to existing plines picked one at a time. It may be modified to get them via selection set.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

mcn

  • Guest
Re: polyline at 60m
« Reply #8 on: November 19, 2009, 03:13:43 AM »
Well, Start& end is enough.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: polyline at 60m
« Reply #9 on: November 19, 2009, 08:27:13 AM »
I can change the lisp to select plines but a filter should be used:
Only specific layers?
Only 50m long?
Only one segment?

Will they every be touching each other? (end to end)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

mcn

  • Guest
Re: polyline at 60m
« Reply #10 on: November 19, 2009, 09:31:57 AM »
Only 50m long.
yes End to end, as you mentioned

Thanks.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: polyline at 60m
« Reply #11 on: November 19, 2009, 10:49:18 AM »
The only drawback with this routine is that plines end to end will have two points at the vertex.
Can you live with that?
Code: [Select]
(defun c:AddPoints (/ i ss ent elst pts)
  ;;  get only LW plines with 2 vertices
  (princ "\nSelect pline.")
  (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 2))))
  (setq i -1)
  (while (setq ent (ssname ss (setq i (1+ i))))
    (setq elst (entget ent)
          pts  (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst))
    )
    ;;  ignore if not equal to 50 units
    (if (equal (distance (car pts) (cadr pts)) 50.0 0.01)
      (mapcar
        (function
          (lambda (pt)
            (entmake
              (list (cons 0 "POINT")
                    (cons 6 "BYLAYER")
                    (cons 8 "0") ; layer, comment out for current layer
                    (cons 10 pt)
                    (cons 62 256)
              )
            )
          )
        )
        pts
      )
    )
  )
  (princ)
)
(princ "\nAddPoints loaded, Enter AddPoints to run.")
(princ)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: polyline at 60m
« Reply #12 on: November 19, 2009, 10:58:59 AM »
On second thought, maybe this will resolve the extra points issue.
Code: [Select]
(defun c:AddPoints (/ i ss ent elst pts ptsOld)
  ;;  get only LW plines with 2 vertices
  (princ "\nSelect pline.")
  (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 2))))
  (setq i -1)
  (while (setq ent (ssname ss (setq i (1+ i))))
    (setq elst (entget ent)
          pts  (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst))
    )
    ;;  ignore if not equal to 50 units
    (if (equal (distance (car pts) (cadr pts)) 50.0 0.01)
      (mapcar
        (function
          (lambda (pt)
            (if (not (vl-position pt ptsOld))
              (progn
                (entmake
                  (list (cons 0 "POINT")
                        (cons 6 "BYLAYER")
                        (cons 8 "0") ; layer, comment out for current layer
                        (cons 10 pt)
                        (cons 62 256)
                  )
                )
                (setq ptsOld (cons pt ptsOld))
              )
            )
          )
        )
        pts
      )
    )
  )
  (princ)
)
(princ "\nAddPoints loaded, Enter AddPoints to run.")
(princ)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

mcn

  • Guest
Re: polyline at 60m
« Reply #13 on: November 20, 2009, 03:10:44 AM »
Thanks, it's working, but what about a big pline to be splited at 50m and then add the points?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: polyline at 60m
« Reply #14 on: November 20, 2009, 09:20:21 AM »
Questions:
Do you need a vertex at 50m and a point? If so remove any other vertex?
Will the pline be exactly multiples of 50m?
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.