Jump to content

Points along a line


myself

Recommended Posts

Hello there, here i am with another doubt that i hope to clarify with your help. How do i put a point at a certain distance along the length of a line, i mean, i have a curved line with curves to both side more less like a spline, and now i wanna put a point on that line on every 5m. i hope you understand what i mean,

 

Thank you very much in advanced ;)

Link to comment
Share on other sites

That is nice, but from what i got "measure" splits the line into equal segments but does not put the point at the precise distande i want...

 

P.S-Sorry guys, thats just perfect for what i want ;)

 

thanks NBC

Link to comment
Share on other sites

MEASURE puts a point (or a block) at specified distances along other entities. DIVIDE will put a point (or a block) at a specified number of segments along the entity.

Link to comment
Share on other sites

Try this LISP, similar what you want, you may also need to generate a point along your curve at a specific distance.

aquired this code from ipseifer if i remember

 
(defun c:xdiv(/ *error* cCurve curPt dPar dPt
      enPt fPar fPt maxLen obType oldDis
      oldOsn posDir rClose sFlag stPt
      sumDis swMod undoLst vClose whatDo)
 (vl-load-com)
 (defun asmi_GetActiveSpace(/ actDoc)
   (if
     (= 1(vla-get-ActiveSpace
    (setq actDoc
    (vla-get-ActiveDocument
      (vlax-get-acad-object)
      ); end vla-get ActiveSpace
     ); end setq
    ); end vla-get-ActiveDocument
 ); end =
     (vla-get-ModelSpace actDoc)
     (vla-get-PaperSpace actDoc)
     ); end if
   ); end of asmi_GetActiveSpace
 (defun RestorePointStyle()
   (if
     (and xdiv:oldPm xdiv:oldPs)
     (progn
(initget "Yes No")
(setq swMod
     (getkword
       "\nRestore point style? [Yes/No] <No>: "))
(if(null swMod)(setq swMod "No"))
(if
 (= swMod "Yes")
  (progn
    (princ "\nPlease wait... \n")
    (setvar "PDMODE" xdiv:oldPm)
    (setvar "PDSIZE" xdiv:oldPs)
  ); end progn
 ); end if
); end progn
     ); end if
(princ)
     ); end of RestorePointStyle
 (defun AddPointOrInsert(Mode Block Scale)
   (vla-AddPoint
 (asmi_GetActiveSpace)
      (vlax-3d-point curPt))
   ); end of AddPointOrInsert
 (defun AddPointOrInsert(Mode Block Scale / outObj)
   (setq undoLst
    (append
     (list
(list
 (setq outObj
   (vla-AddPoint
 (asmi_GetActiveSpace)
      (vlax-3d-point curPt))); end setq
  curPt xdiv:curDis
); end list
      ); end list
        undoLst); end append
 ); end setq
   outObj
   ); end of AddPointOrInsert
 (defun *error*(msg)
   (if cCurve
     (progn
 (vla-Highlight cCurve :vlax-false)
   (setvar "OSMODE" oldOsn)
  ); end progn
); end if
    (princ "\n*Cancel*")
   (princ)
   ); end of *error*  
 (if
   (member
     (setq xdiv:oldPm(getvar "PDMODE"))
     '(0 1)
     ); end member
   (progn
     (setq xdiv:oldPs(getvar "PDSIZE"))
     (initget "Yes No")
     (setq swMod
     (getkword
       "\nChange points style to good visible? [Yes/No] <Yes>: "))
     (if(null swMod)(setq swMod "Yes"))
     (if
(= swMod "Yes")
 (progn
   (princ "\nPlease wait... \n")
   (setvar "PDMODE" 35)
   (setvar "PDSIZE" -2)
  ); end progn
); end if
     ); end progn
   ); end if
 (setq oldOsn
 (getvar "OSMODE")); end setq
 (if
   (not xdiv:curDis)
     (setq xdiv:curDis 1.0
    xdiv:oldDis 1.0); end setq
     ); end if
 (if
    (setq cCurve
   (entsel
       "\nSelect curve > ")); end setq
   (progn
     (setq cCurve
     (vlax-ename->vla-object
       (car cCurve))); end setq
     (if
(member
  (setq obType
  (vla-get-ObjectName cCurve))
  '("AcDbLine" "AcDbPolyline" "AcDb3dPolyline"
    "AcDbSpline" "AcDbArc" "AcDbCircle" "AcDbEllipse")
  ); end member
(progn
  (vla-Highlight cCurve :vlax-true)
  (setvar "OSMODE" 3071)
  (setq stPt
 (vlax-curve-GetStartPoint cCurve)
 enPt
 (vlax-curve-GetEndPoint cCurve)
 fPt
  (getpoint
    "\nPick start markup point at curve > ")
 ); end setq
  (if fPt
     (setq fPt(trans fPt 1 0)
           curPt(vla-AddPoint
    (asmi_GetActiveSpace)
      (vlax-3d-point fpt)); end vla-AddPoint
    undoLst
     (list
       (list curPt 0.0 0.0)); end list
    ); end setq
    ); end if
  (if
    (and
      fPt
      (setq fPar
      (vlax-curve-GetParamAtPoint cCurve fPt))
      ); end and
    (progn
      (if
 (and
   (not(equal fPt stPt 0.0001))
   (not(equal fPt enPt 0.0001))
   ); end or
 (progn
   (setq dPt
   (getpoint fPt
     "\nPick point at curve to specify markup direction > "))
   (if dPt
            (setq dPt(trans dPt 1 0))); end if
   (if
     (and
       dPt
       (setq dPar
       (vlax-curve-GetParamAtPoint cCurve dPt))
      ); end and
     (progn
       ); end progn
       (princ "\nEmpty input or point not at curve! ")
     ); end if
   ); end progn
 ); end if
      ); end progn
    (princ "\nEmpty input or point not at curve! ")
    ); end if
  ); end progn
(princ "\nInvalid object type! ")
); end if
     (setq maxLen
     (-
       (vlax-curve-GetDistAtPoint cCurve enPt)
       (vlax-curve-GetDistAtPoint cCurve stPt)
       ); end -
    rClose
     (vlax-curve-IsClosed cCurve)
    ); end setq
     (if(equal fPt stPt 0.0001)
(setq vClose T)
); end if
     (if
(or
  (equal fPt stPt 0.0001)
  (and
    dPar
    (> dPar fPar)
    ); end and
  ); end or
(setq posDir T
      sumDis
  (vlax-curve-GetDistAtPoint cCurve fPt)
      ); end setq
(setq sumDis
       (- maxLen
 (- maxLen
  (vlax-curve-GetDistAtPoint cCurve fPt)))
      ); end setq
); end if
            (while(not sFlag)
 (setq whatDo
        (getstring
   (strcat
   "\nSpecify distance or [undo/Quit] <"
   (if xdiv:curDis(rtos xdiv:curDis) "not defined")
     ">: "); end strcat
   ); end getstring
       ); end setq
 (cond
   ((or
      (= 'REAL(type(distof whatDo)))
      (= "" whatDo)
      ); end or
    (if(= "" whatDo)
      (setq xdiv:curDis xdiv:oldDis)
      (setq xdiv:curDis(distof whatDo))
      ); end if
    (setq xdiv:oldDis xdiv:curDis); end setq
     (cond
    (posDir
       (setq sumDis
       (+ sumDis xdiv:curDis)
      curPt
       (vlax-curve-GetPointAtDist cCurve sumDis)
      ); end setq
       (if curPt
         (AddPointOrInsert nil nil nil)
         (princ "\n>>> End of line <<< ")
            ); end if
       ); end condition # 1
    ((not posDir)
       (setq sumDis
       (- sumDis xdiv:curDis)
      curPt
       (vlax-curve-GetPointAtDist cCurve sumDis)
      ); end setq
       (if curPt
         (AddPointOrInsert nil nil nil)
         (princ "\n>>> End of line <<< ")
            ); end if
       ); end condition # 1
    ); end cond
    ); end condition #1
   ((=(strcase whatDo) "Q")
    (if
      (= 1(length undoLst))
       (vla-Delete(caar undoLst))
      ); end if
    (RestorePointStyle)
    (if cCurve
            (progn
             (vla-Highlight cCurve :vlax-false)
              (setvar "OSMODE" oldOsn)
            ); end progn
           ); end if
    (setq sFlag T)
    )
   ((=(strcase whatDo) "U")
    (if
      (and
        undoLst
        (/= 1(length undoLst))
        ); end and
      (progn
       (vla-Delete(caar undoLst))
       (setq undoLst(cdr undoLst)
      curPt(cadar undoLst)
      sumDis(- sumDis
        (last
          (car undoLst)))
      ); end setq
       ); end progn
      (princ "\n>>> Nothing to undo <<< ")
      ); end if
    )
   ); end cond
 ); end while
     ); end progn
   (princ "\nEmpty selection! ")
   ); end if

 (princ)
 ); end of xdiv

Link to comment
Share on other sites

aquired this code from lpseifert if i remember

Sorry to say I didn't write that code, ASMI gets all the credit.

 

But you may want to try this pared down version instead.

 
;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)
)


Link to comment
Share on other sites

Sorry to say I didn't write that code, ASMI gets all the credit.

[/code]

 

:D well you shared it; thats credit enough for me.

I use that LISP very often to locate a point along a road or pipe centerline and track its coordinates.

Will try this new one,,,

thanks again :)

Link to comment
Share on other sites

lpseifert, sorry, just took a look at the code, and was just wondering does the line.

 

;end of pop

 

need to be put in there at the end or am i being daft?

(not know much about lisp yet):oops:

Link to comment
Share on other sites

Puts one point on the curve at the specified distance.

 

Whilst that is a great option, and I'm not doubting the ability of the code to do what it should; i think it does not answer the OP's request of:

 

, and now i wanna put a point on that line on every 5m
Link to comment
Share on other sites

;end of pop

 

need to be put in there at the end or am i being daft?

 

No it isn't necessary... in lisp anything after a ; is a comment

Funny, I don't see ;end of pop in the above code....

Link to comment
Share on other sites

No it isn't necessary... in lisp anything after a ; is a comment

Funny, I don't see ;end of pop in the above code....

 

no that's what i meant, i thought the code hadn't been closed, didn't realise ; ment comment,

 

(Can a moderator please move my posts out of this thread and into their own please - don't want to highjack op's qestion/thread)

Link to comment
Share on other sites

Whilst that is a great option, and I'm not doubting the ability of the code to do what it should; i think it does not answer the OP's request of:

 

Sorry totally my fault, just added that lisp as an alternative for this part of the question.

"How do i put a point at a certain distance along the length of a line, i mean, i have a curved line with curves to both side more less like a spline"

Link to comment
Share on other sites

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