Jump to content

Find Curve Point


gS7

Recommended Posts

Hello CadTutor Friends ,

 

Check Example Code

 

(Defun c:Test(/ pline int in pt ppt mspace thepoint)
 (if (and (setq pline (car (entsel "\nSelect Polyline:")))
      (setq int (getdist "\nEnter Interval:"))
      (setq in int)
     )
   (progn
     (setq mspace (vla-get-modelspace
            (vla-get-activedocument
              (vlax-get-acad-object)
            )
          )
     )
     (while
   (Setq pt (vlax-curve-getPointAtDist pline int))
   (setq thepoint (vlax-invoke mspace 'addcircle pt 0.1))
   (setq int (+ int in))
     )
   )
 )(princ)
)

Here i want to find curve point

 

Also Please Check Attachment

Curve Point.dwg

Link to comment
Share on other sites

Pbe

 

I am Trying to Write Codes for My Project Purpose

 

Check Codes


 (defun c:Rail (/ *error* osm cmh adoc space s ename int l width d sp spp pt fd ang )
     (vl-load-com)
     (defun *error* (s)
    (if osm (setvar 'osmode osm))
    (and cmh (setvar 'cmdecho cmh))
    (and adoc (vla-endundomark adoc))
    (cond ((not s))
          ((member s '("Function cancelled" "quit / exit abort")))
          ((princ (strcat "\n--->Error:" s)))
    )
   (princ))
       (setq adoc(vlax-get (vlax-get-acad-object) 'ActiveDocument))
       (setq space(vlax-get adoc 'ModelSpace))
       (setq osm (getvar 'osmode)
         cmh (getvar 'cmdecho)
   )
       (setvar 'cmdecho 0)
       (setvar 'osmode 0)
       (if (setq s (car (entsel "\nSelect Alignment:")))
       (progn
            (setq ename(vlax-ename->vla-object s))
            (if
          (or
             (or
           (eq (vla-get-ObjectName ename) "AcDbPolyline")
           (eq (vla-get-ObjectName ename) "AcDb3dPolyline")
           (eq (vla-get-ObjectName ename) "AcDbLine")
             )
          )
          (progn (vla-startundomark adoc)
               (if
              (and
                  (and
                  (setq Int (getreal "\nIncrement Distace:"))
                  (setq L (getreal "\nLength:"))
                  (setq width (getreal "\nWidth:"))
                  )
              )
              (progn
                   (setq d (vlax-curve-getdistatparam s (vlax-curve-getendparam s)))
                   (setq sp (vlax-curve-getstartpoint s))
                   (setq spp(vlax-curve-getpointatdist s l))
                   (Gs:Apply_Hatch s width sp spp space (angle sp spp))
                   (setq i int)
                      (vla-offset ename (- (/ width 2)))
               (vla-offset ename (/ width 2))
                   (repeat (fix (/ d int))
                   (setq pt (vlax-curve-getpointatdist s int))
                   (setq fd(vlax-curve-getFirstDeriv s (vlax-curve-getparamatdist s int)))
                                   (setq ang (angle '(0.0 0.0 0.0) fd))
                   (if (setq npt(vlax-curve-getpointatdist s (+ (vlax-curve-getdistatpoint s pt) l)))
                     (progn
                   (Gs:Apply_Hatch s width pt npt space ang)
                     )
                   )
                   (setq int (+ i int))
               );repeat
                );progn
                (*error* "Values Must be Enter!")
             );if
              );progn
              (*error* "Invalid Object !")
          );if
         );progn
         (*error* "Nothing Selected !")
     );if
         (*error* nil)
         (vla-endundomark adoc)
         (vlax-release-object adoc)
         (princ)
   );end defun
(prompt "\n*** Enter \"Rail\" to execute Command ***")
                   
(defun Gs:Apply_Hatch (ss w p np spc a / fd ang a1 a2 a3 a4 pline h)
 (setq    a1 (polar p (- a (/ pi 2.0)) (/ w 2.0))
   a2 (polar np (- a (/ pi 2.0)) (/ w 2.0))
   a3 (polar np (+ a (/ pi 2.0)) (/ w 2.0))
   a4 (polar p (+ a (/ pi 2.0)) (/ w 2.0))
 )
 (vl-cmdf "_.PLINE" a1 a2 a3 a4 "c")
 (setq pline (vlax-ename->vla-object (entlast)))
 (setq    h (vla-addhatch
       spc
       acHatchPatternTypePredefined
       "SOLID"
       :vlax-true
     )
 )
 (vlax-invoke h 'AppendOuterLoop (list pline))
 (vlax-invoke h 'Evaluate)

)    

Here i got One Problem which is I Cannot Make Hatch Object in Curve Points

 

Please Check Attachment for your Reference Rail Track.dwg

Link to comment
Share on other sites

Another hint

instead of

(Setq pt (vlax-curve-getPointAtDist pline int))

use this one

(Setq pt (vlax-Curve-GetClosestPointTo pline (vlax-curve-getPointAtDist pline int)))

from my oldie experience on the quick glance

Link to comment
Share on other sites

In the future. are you planing to use this on plines with arcs? that will be a little complicated :)

 

Yes pbe but i Have another Plan , i.e. in that pline if i found curve point i want to skip my next point to 0.5 m from the curve point

and tel me How to find those curve points first

Link to comment
Share on other sites

Another hint

instead of

(Setq pt (vlax-curve-getPointAtDist pline int))

use this one

(Setq pt (vlax-Curve-GetClosestPointTo pline (vlax-curve-getPointAtDist pline int)))

from my oldie experience on the quick glance

 

Fixo i did not get Your Point please me clearly

Link to comment
Share on other sites

and tel me How to find those curve points first

 

(if (setq pline (car (entsel "\nSelect Polyline:")))
 (mapcar
   'cdr
   (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget pline))
 )
)

(if (setq pline (car (entsel "\nSelect Polyline:")))
 	(repeat (setq n (cdr (assoc 90 (entget pline))))
  	(setq pts (cons  (vlax-curve-getpointatparam pline (setq n (1- n)))  pts )))
)

(if (setq pline (car (entsel "\nSelect Polyline:")))
 (if (eq (setq p (vlax-curve-getEndParam pline)) (fix p))
   (repeat (setq p (1+ (fix p)))
     (setq l (cons (vlax-curve-getPointAtParam pline (setq p (1- p))) l))
   )
 )
)

(if (setq pline (car (entsel "\nSelect Polyline:")))
 (vlax-get (vlax-ename->vla-object pline) 'coordinates))

 

Pick your poison ;)

Link to comment
Share on other sites

(if (setq pline (car (entsel "\nSelect Polyline:")))
 (mapcar
   'cdr
   (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget pline))
 )
)

(if (setq pline (car (entsel "\nSelect Polyline:")))
 	(repeat (setq n (cdr (assoc 90 (entget pline))))
  	(setq pts (cons  (vlax-curve-getpointatparam pline (setq n (1- n)))  pts )))
)

(if (setq pline (car (entsel "\nSelect Polyline:")))
 (if (eq (setq p (vlax-curve-getEndParam pline)) (fix p))
   (repeat (setq p (1+ (fix p)))
     (setq l (cons (vlax-curve-getPointAtParam pline (setq p (1- p))) l))
   )
 )
)

(if (setq pline (car (entsel "\nSelect Polyline:")))
 (vlax-get (vlax-ename->vla-object pline) 'coordinates))

 

Pick your poison ;)

 

 

:huh:

 

:shock:

Link to comment
Share on other sites

You can use any of those snippets to retrieve the points gS7.

 

:lol: Yes I got it Pbe Nice collection for retrieve Vertex of Plines and That was Great !! Thank You So Much

 

and one more Question Pbe how do i Check Curve Points with Give Interval Distance Point

Link to comment
Share on other sites

.....

and one more Question Pbe how do i Check Curve Points with Give Interval Distance Point

 

vlax-curve-getPointAtDist or is it

vlax-curve-getDistAtPoint

 

Holler if you need help finishing your program gS7 :)

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