# Lisp to move points in Z-Direction or Make points with certain distance Horizontaly

## Recommended Posts

Hello everyone,

i have a little problem here, i have some splines having profile in Z direction in autocad. i want to put points each 1m (or any distance defined by user) on those splines. When i do that with "Measure" it put point each 1m on the curvature of the curve, so in plan when i measure the distance between these points it will be less than 1m, i want the 1m to be horizontal or vertical (in plan not on the curve)

i thought the solution of this is that in plan i will create points each 1m or any distance (with array for example), these points in Z direction will not be on the curve (as these points are created in plan), i want a lisp to move these points (in Z direction only) so the points will be on the splines (this process is for multiple objects)

Does anyone have a lisp for that ?

##### Share on other sites

Have you looked for chainage LISPs, not sure if they work with splines though, I tend to use polylines instead

##### Share on other sites

22 hours ago, Steven P said:

Have you looked for chainage LISPs, not sure if they work with splines though, I tend to use polylines instead

I tried some of them but nothing made what i want, all of the lisps put lines or points with interval 1m on the curved path not 1m in plan distance

##### Share on other sites

7 hours ago, noyajr said:

I tried some of them but nothing made what i want, all of the lisps put lines or points with interval 1m on the curved path not 1m in plan distance

@noyajr some like it . it s spaced in 25  equal parts ,

##### Share on other sites

48 minutes ago, devitg said:

@noyajr some like it . it s spaced in 25  equal parts ,

@noyajr It seem it could be so  spaced

##### Share on other sites

Look for (vlax-curve-getclosestpointtoprojection) function... You make line horizontaly like in your picture, then measure - 1.0, then (foreach pt pts => (setq ptn (vlax-curve-getclosestpointtoprojection spline pt '(0.0 1.0 0.0)))... So ptn are your new points on spline - then just use (entmake) or POINT command to place them on spline...

##### Share on other sites

15 hours ago, devitg said:

@noyajr It seem it could be so  spaced

Yes this is perfect for me, but i have alot of these splines with very different lengths, so is there a way to do this spacing each 1m or any other distance ?

Posted (edited)

Edited by asdfgh
##### Share on other sites

On 8/7/2023 at 11:08 PM, marko_ribar said:

Look for (vlax-curve-getclosestpointtoprojection) function... You make line horizontaly like in your picture, then measure - 1.0, then (foreach pt pts => (setq ptn (vlax-curve-getclosestpointtoprojection spline pt '(0.0 1.0 0.0)))... So ptn are your new points on spline - then just use (entmake) or POINT command to place them on spline...

AS @marko_ribar SAY

@asdfgh TRY THIS

```

CONTROLPOINTN           DOC         ENAME
INT         IPOINT      LEN         OBJENTGET
OBJOBJECCOPYT           OBJOBJECT   POINT1
POINT2      PT1         PTN         STT
)

(if
(and
(setq objENTGET (entget (setq eName (car (entsel "\nSelect")))))
(setq int (getdist "\nSpecify spacing interval: "))
) ;_ end of and

(progn

(setq objobject (vlax-ename->vla-object eName))

(setq objobjeccopyt (vla-copy objobject))

;; Define the points that make up the move vector
(setq point1 (vlax-3d-point 0 0 0)
point2 (vlax-3d-point 0 0 -5)
) ;_ end of setq
(vla-move objobjeccopyt point1 point2)

(setq iPoint 0) ;_ end of setq

(while (> (vla-get-numberofcontrolpoints objobjeccopyt) iPoint)
(progn

(setq controlPoint
(vlax-safearray->list
(vlax-variant-value
(vla-getcontrolpoint objobjeccopyt iPoint)
) ;_ end of vlax-variant-value
) ;_ end of vlax-safearray->list
) ;_ end of setq

(setq controlPointn
(vlax-3d-point
(car controlPoint)
0
) ;_ end of vlax-3d-point
) ;_ end of setq
(vla-setcontrolpoint objobjeccopyt iPoint controlPointn)
(vla-update objobjeccopyt)

(setq iPoint (1+ iPoint))

) ;_ end of progn
) ;_ end of while

(setq len (vlax-curve-getdistatparam
objobjeccopyt
(vlax-curve-getendparam objobjeccopyt)
) ;_ end of vlax-curve-getDistAtParam
) ;_ end of setq

(setq stt 0) ;_ end of setq

(while (<= stt len)
(progn

(setq pt1 (vlax-curve-getpointatdist objobjeccopyt stt))
(setq ptn (vlax-curve-getclosestpointtoprojection
objobject
pt1
;'(0.0 1.0 0.0)
'(0.0 0.0 1.0)
)
) ;_ end of setq

;;;
(entmakex
(list
'(0 . "POINT")
(cons 10 ptn)
(cons 8 "00-point")
) ;_ end of list
) ;_ end of entmakex

(setq stt (+ int stt))

) ;_ end of progn

) ;_ end of while

(vla-delete objobjeccopyt)

) ;_ end of progn
) ;_ end of if
(princ)
) ;_ end of defun
(72 2 50 2 T "end of " 60 9 1 0 0 nil T nil T)
;*** DO NOT add text below the comment! ***|;```

##### Share on other sites

How to find intersect point of two selected line

##### Share on other sites

Simple with the inters command:

Bit more complex:

Vla-intrsectwith

A bit better with Lee Macs Intersection functions:

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

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.