Jump to content

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


Recommended Posts

Posted

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)

image.thumb.png.9ca433b3783058490b0cd5bd91e72e3b.png

 

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)

image.thumb.png.1e15025d6d8a9621e314368fb6009831.png

 

Does anyone have a lisp for that ?

 

Thanks in advance

Sample.dwg

Posted

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

Posted
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

Thanks for your reply,

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

Posted
7 hours ago, noyajr said:

Thanks for your reply,

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 , 

 

one spaced spline.dwg

Posted

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

  • Like 1
Posted (edited)

Any news about this topic ?

Edited by asdfgh
Posted
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

 



(defun c:Spline_Copy (/           ACADOBJ     CONTROLPOINT
                      CONTROLPOINTN           DOC         ENAME
                      INT         IPOINT      LEN         OBJENTGET
                      OBJOBJECCOPYT           OBJOBJECT   POINT1
                      POINT2      PT1         PTN         STT
                     )


  (setq acadObj (vlax-get-acad-object))
  (setq doc (vla-get-activedocument acadObj))

  (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)
                    (cadr 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
;|«Visual LISP© Format Options»
(72 2 50 2 T "end of " 60 9 1 0 0 nil T nil T)
;*** DO NOT add text below the comment! ***|;

 

111.gif

  • Like 1

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