Author Topic: Align Polyline to Polyline  (Read 2481 times)

0 Members and 1 Guest are viewing this topic.

chvnprasad

  • Guest
Align Polyline to Polyline
« on: April 03, 2012, 02:56:05 PM »
How to align one polyline to another polyline.both polylines are different number of verices. If i select source polyline and target polyline,source polyline should be align(coincide) with target poly line
« Last Edit: April 03, 2012, 02:59:42 PM by chvnprasad »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Align Polyline to Polyline
« Reply #1 on: April 03, 2012, 04:24:07 PM »
How should they align? Simply the picked vectors to be co-linear? Or should the one also scale such that the picked vectors are the same length and / or start & end points? Are both always on the same UCS? Should something else than the picked vectors be used for alignment, say vectors closest to each other? What about curved vectors, should these be ignored?
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Align Polyline to Polyline
« Reply #2 on: April 03, 2012, 10:28:18 PM »
Would this be essential to using Rotate by Reference?

eg.
Code: [Select]
Command: r
ROTATE
Current positive angle in UCS:  ANGDIR=counterclockwise  ANGBASE=0d

Select objects: Specify opposite corner: 1 found

Select objects:

Specify base point:
Specify rotation angle or [Copy/Reference] <0d>: r
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Align Polyline to Polyline
« Reply #3 on: April 04, 2012, 03:58:50 AM »
Or simply using the Align command? E.g.:
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:AlignPoly (/ SelPoly p1 p2 en1 en2 p3 p4)
  3.   (defun SelPoly ( msg / p )
  4.     (while (and (setq p (entsel msg)) (not (eq (cdr (assoc 0 (entget (car p)))) "LWPOLYLINE")))
  5.       (princ "That's not a polyline, try again.\n"))
  6.     p)
  7.  
  8.   (if (setq p1 (SelPoly "Pick Polyline to rotate/move/scale <Exit>: "))
  9.     (exit))
  10.   (if (setq p2 (SelPoly "Pick target Polyline <Exit>: "))
  11.     (exit))
  12.   (command "._ZOOM" "_Object" en1 en2 "")
  13.         p4 (vlax-curve-getPointAtParam en2 (1+ p2)))
  14.           (setq p2 (vlax-curve-getPointAtParam en2 p2))
  15.           2 1)
  16.   (grdraw p3 p4 2 1)
  17.   (initget "Swap Continue")
  18.   (if (eq (getkword "Is this corect? [Swap/Continue] <Continue>: ") "Swap")
  19.     (progn (redraw) (command "._ALIGN" en1 "" p3 p2 p1 p4 ""))
  20.     (progn (redraw) (command "._ALIGN" en1 "" p1 p2 p3 p4 "")))
  21.   (princ))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

ribarm

  • Gator
  • Posts: 3297
  • Marko Ribar, architect
Re: Align Polyline to Polyline
« Reply #4 on: April 04, 2012, 04:23:27 AM »
Irneb, I think command ALIGN has some sort of bug when calling from inside routine...
I suggest that you use (arxload "geom3d.arx") and call (align) sub-function shown in this example :

http://www.theswamp.org/index.php?topic=41382.msg464959#msg464959

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Align Polyline to Polyline
« Reply #5 on: April 04, 2012, 04:38:21 AM »
I don't know ... for me on Vanilla 2012 it seems to work fine.

Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Align Polyline to Polyline
« Reply #6 on: April 04, 2012, 09:54:23 AM »
Oh yeah, Align. drrr
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox