Jump to content

3D/2D Polyline....


Recommended Posts

Posted

I have to use 2d & 3D polylines on a daily basis and don't feel secure using the distance to measure the distance between two points along a polyline that has arcs, curves etc.

 

My curiosity brings me here asking how other people go about this and if any tips or tricks can be offered when using complex polylines in general.

Posted

IDD returns distance between 2 selected points, IDS returns distance from beginning of line. You better test on 3D polylines, I haven't

;;;reports distance between two selected points along an entity LPS 8-8-08

(defun c:idd ()
 (vl-load-com)
 (command "UCS" "W")
 (setq    ename-pline    (car (entsel "\nPick entity to be measured: "))
   vlaobject-pline    (vlax-ename->vla-object ename-pline)
   pt1        (getpoint "\nPick start point on entity: ")
   pt1a        (vlax-curve-GetClosestPointTo vlaobject-pline pt1)
   pt2        (getpoint "\nPick second point on entity: ")
   pt2a        (vlax-curve-GetClosestPointTo vlaobject-pline pt2)
   sta1        (vlax-curve-getDistatPoint vlaobject-pline pt1a)
   sta2        (vlax-curve-getDistatPoint vlaobject-pline pt2a)
   delta        (abs (- sta2 sta1))
   delta-str    (strcat
             "The distance along the entity\n between the two points is "
             (rtos delta 2 2)
             "'"
           )
           ;;strcat
 )
 ;;setq
 (command "ucs" "p")
 (alert delta-str)
)
;;defun

;reports distance from beginning of a polyline.LPS 8-8-08

(defun c:ids ()
(vl-load-com)
 (command "ucs" "w")
(setq ename-pline (car (entsel "\nPick a Polyline:"))
        vlaobject-pline (vlax-ename->vla-object ename-pline) ;make vla-object from entity name
       pt1 (vlax-curve-getClosestPointTo vlaobject-pline (getpoint "\nPick point on Polyline: ")) 
       ;pt1 (getpoint "Pick point on Polyline: ")
        sta (vlax-curve-getDistatPoint vlaobject-pline pt1)
        sta-str (strcat "The distance from the start of the Polyline is " (rtos sta 2 2) "'")
);setq
 (command "ucs" "p")
(alert Sta-str)
);defun

Posted

Not too bad.

 

How about some LISP's that can move items along complex polyline? If I could move an object from its location by a set distance that would be pretty handy. Particularly so if it doesnt have to be a new instance of a block and the LISP can choose to ignore Z values.

Posted

Here's one that will place a point at a specified distance along a polyline. Hack it up.

;places point at specified station along a polyline, measured from start LPS 2008

(defun c:pop ()
(vl-load-com)
(setq oldosnap (getvar "osmode"))
(setvar "osmode" 0)
(command "ucs" "w")
(if (/= (getvar "pdmode") 3)(setvar "pdmode" 3))
(setq ob (entsel "Select curve: "))
(setq p2 (getreal "\n Specify Distance : "))
(setq obj (vlax-ename->vla-object (car ob)))
(setq pt1 (vlax-curve-getPointAtDist Obj p2))
(command "Point" pt1)
(command "ucs" "p")
(setvar "osmode" oldosnap)
(princ)
)

Posted

Cheers, thanks.

 

Any chance you could amend the code so the start of the line is replaced with another selectpoint instead, please?

Posted
;;;puts a point on a polyline a specified distance from a selected point LPS 12-22-08

(defun c:pt@dist (/          oldosnap      ename-pline vlaobject-pline
         pt1          pt1a      dist1          dist2
         dist3          pt2
        )
 (vl-load-com)
 (setq oldosnap (getvar "osmode"))
 (setvar "osmode" 0)
 (command "UCS" "W")
 (if (/= (getvar "pdmode") 3)
   (setvar "pdmode" 3)
 )
 (setq    ename-pline
           (car (entsel "\nPick polyline: "))
   vlaobject-pline
           (vlax-ename->vla-object ename-pline)
   pt1        (getpoint "\nPick start point on polyline: ")
   pt1a        (vlax-curve-GetClosestPointTo vlaobject-pline pt1)
   dist1        (vlax-curve-getDistAtPoint vlaobject-pline pt1a)
   dist2        (getdist "\nEnter distance along polyline: ")
   dist3        (+ dist1 dist2)
   pt2        (vlax-curve-getPointAtDist vlaobject-pline dist3)
 )
 (command "Point" pt2)
 (command "ucs" "p")
 (setvar "osmode" oldosnap)
 (princ)
)
;;defun

Posted

Actually, sorry to hassle you. It doesnt actually place a point.

Posted

Sincerest apologies - the current layer was turned off.

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