MOVE POLYLINE TO SPECIFIC POINTS

MOVE POLYLINE TO SPECIFIC POINTS

Anonymous
Not applicable
2,808 Views
14 Replies
Message 1 of 15

MOVE POLYLINE TO SPECIFIC POINTS

Anonymous
Not applicable

IS THERE ANY CODE TO MOVE POLYLINE ,BY USING SPECIFIC POINTS , IWANT TO MOVE THE POLYLINE ,TO BELOW SHOWN POINTS , SOME TIMES

POINTS MAY BE IRREGULAR,

 

 

 

 

Untitled.jpg

0 Likes
Accepted solutions (3)
2,809 Views
14 Replies
Replies (14)
Message 2 of 15

pendean
Community Legend
Community Legend
Accepted solution
Or just draw a new PLINE at those points and delete the "old" one?
0 Likes
Message 3 of 15

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

IS THERE ANY CODE TO MOVE POLYLINE ,BY USING SPECIFIC POINTS ....


I agree that it may be easier to just draw a new one and delete the old one.  But in either case, how would the code be provided with those points?  Should it ask the User for them?  [If so, the User may as well just draw the Polyline manually instead.]  Are they in a list of points stored in a variable?  Are they coming from an external file?  Are they related to some other existing object(s) in the drawing?  Etc.

Kent Cooper, AIA
0 Likes
Message 4 of 15

Anonymous
Not applicable

polyline contains object data, and it can not be deleted,EDIT ONLY

 

 

POINTS DOES NOT COTAIN ANY DATA, JUST I WANT TO MOVE THE POLYLINE ,

 

 

JUST NEED TO ASK USER POSITION OF 1ST VERTEX, 2ND VERTEX ..............OF SELECTED POLYLINE

0 Likes
Message 5 of 15

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try to redraw the polyline with this routine... 

 

 

(vl-load-com)

(defun c:plinefrom ( / ss ed enlast ef)

  (if (and (princ "\nSelect pattern polyline: ")
	   (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))
	   (= 1 (sslength ss))
	   (setq ed (entget (ssname ss 0)))
	   (setq enlast (entlast))
	   (princ "\nDraw new polyline: ")
	   (progn
	     (command "_.PLINE")
	     (while (> (getvar 'CMDACTIVE) 0) (command PAUSE))
	     (if (not (equal enlast (entlast)))
	       (setq ef (entlast))))
	   )
      (progn
	(entmod
	  (setq ed (vl-remove-if '(lambda (x) (vl-position (car x) '(40 41 42 10 90 91))) ed)
		ed (append ed (vl-remove-if-not '(lambda (x) (vl-position (car x) '(40 41 42 10 90))) (entget ef)))))
	(entdel ef)
      )
  )
  (princ)
)

 

Message 6 of 15

Kent1Cooper
Consultant
Consultant
Accepted solution

@ВeekeeCZ wrote:

Try to redraw the polyline with this routine... 

.... 


Another [and shorter] way to accomplish the last part of that, if there are no arc segments or widths involved -- just impose the new Polyline's coordinates as a VLA Property on the original:

 

(vl-load-com)
(defun c:plinefrom ( / ss obj enlast ef)
  (if

    (and

      (princ "\nSelect pattern polyline: ")
      (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))
      (= 1 (sslength ss))
      (setq obj (vlax-ename->vla-object (ssname ss 0)))
      (setq enlast (entlast))
      (princ "\nDraw new polyline: ")
      (progn
        (command "_.PLINE")
        (while (> (getvar 'CMDACTIVE) 0) (command PAUSE))
        (if (not (equal enlast (entlast))) (setq ef (entlast)))

      ); progn

    ); and

    (progn ; then
      (vla-put-Coordinates obj (vla-get-Coordinates (vlax-ename->vla-object ef)))
      (entdel ef)

    ); progn

  ); if
  (princ)
); defun

Kent Cooper, AIA
0 Likes
Message 7 of 15

Anonymous
Not applicable

THANKS FOR RESPONSE

ITS WORKING FINE

0 Likes
Message 8 of 15

mihai_bantas
Enthusiast
Enthusiast

Hello everyone, please help me with a suggestion... is it possible for the selection to apply a block???

(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE,BLOCK"))))

Thanks in advance.

0 Likes
Message 9 of 15

ВeekeeCZ
Consultant
Consultant

@mihai_bantas wrote:

Hello everyone, please help me with a suggestion... is it possible for the selection to apply a block???

(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE,BLOCK"))))

Thanks in advance.


 

No. 

Start a new thread and explain what is your goal. Possibly post a dwg sample.

0 Likes
Message 10 of 15

mihai_bantas
Enthusiast
Enthusiast

hello BeekeeCZ, what I want is to select a block that contains several polylines and move them along a certain polyline (let's say I want a quick georeferencing along a certain polyline or polygon).

I also attach an explanatory file.

Thanks.

0 Likes
Message 11 of 15

mihai_bantas
Enthusiast
Enthusiast

hello everyone, I'm back with my problem related to the adaptation of the above code.
I kept trying to modify it... but I can't figure out where I'm going wrong.
Thank you in advance

(vl-load-com)

(defun c:plinefrom ( / ss ed enlast ef)

  (if (and (princ "\nSelect BLOCK:")
	   (setq ss (ssget "_X"'(0 . "INSERT")))
		   (setq p1 (getpoint "POINT1:"))
		   (setq p2 (getpoint "POINT2:"))
		   (setq p3 (getpoint "POINT3:"))
		   (setq p4 (getpoint "POINT4:"))
	   (= 1 (sslength ss))
	   (setq ed (entget (ssname ss 0)))
	   (setq enlast (entlast))
	   (princ "\nDraw new polyline: ")
	   (progn
		 (command "_.PLINE")
	     (while (> (getvar 'CMDACTIVE) 0) (command PAUSE))
	     (if (not (equal enlast (entlast)))
	       (setq ef (entlast))))
	   )
      (progn
	(entmod
	  (setq ed (vl-remove-if '(lambda (x) (vl-position (car x) '(40 41 42 10 90 91))) ed)
		ed (append ed (vl-remove-if-not '(lambda (x) (vl-position (car x) '(40 41 42 10 90))) (entget ef)))))
	(entdel ef)
      )
  )
  (princ)
)

TEST FILE2.jpg

0 Likes
Message 12 of 15

ВeekeeCZ
Consultant
Consultant

Ok, to clear things up.

 

THE METHOD USED IN THIS CODE IS NOT APPLICABLE TO BLOCKS AT ALL. 

 

It's nowhere close to being as simple as that.

0 Likes
Message 13 of 15

mihai_bantas
Enthusiast
Enthusiast

ok, then how can I modify the code to move multiple objects (line, polyline, circle, etc.) based on a single polyline?

Thanks for the info and time

0 Likes
Message 14 of 15

ВeekeeCZ
Consultant
Consultant

Do you know the ALIGN command?

Message 15 of 15

mihai_bantas
Enthusiast
Enthusiast

😁Thanks for the suggestions..it work for me with commnad.

0 Likes