Author Topic: find a point on arc then break with known distance  (Read 3091 times)

0 Members and 1 Guest are viewing this topic.

EddieFromDc

  • Newt
  • Posts: 34
find a point on arc then break with known distance
« on: June 17, 2009, 01:28:56 PM »
Hello,

I came up with this lisp routine that will break a line..for simplicity 12 inches.

I need help for arcs. I want it to work with arcs too..How can I find a point on an arc?



(Defun c:test ( / l1 pt pt1 pt2 ang)
(setq dis 12)                 ;;;;;;break distance
(setq l1 (entsel "\nSelect line to break: "))
(if l1 (progn
       (setq pt (cadr l1))
       (setq pt (osnap pt "nea"))
       (setq pt1 (cdr (assoc 10 (entget (car l1)))))
       (setq pt2 (cdr (assoc 11 (entget (car l1)))))
       (setq ang (angle pt1 pt2))
       (command "break"
                      pt
                     "f"
                      (polar pt ang (* dis 0.5))
                      (polar pt (+ pi ang) (* dis 0.5))
       )
       );progn
);if
)


Lee Mac

  • Seagull
  • Posts: 12923
  • London, England
Re: find a point on arc then break with known distance
« Reply #1 on: June 17, 2009, 01:57:39 PM »
Have you looked into the curve functions?

For example, to get a point on any curve, you could use:

Code: [Select]
(setq ent (entsel "\n Select Curve: "))
(setq pt (vlax-curve-getClosestPointto (car ent) (cadr ent)))
             

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: find a point on arc then break with known distance
« Reply #2 on: June 17, 2009, 01:57:56 PM »
Code: [Select]
(vlax-curve-getpointatdist curve-obj dist) 8-)

<edit: you beat me by seconds!> :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

EddieFromDc

  • Newt
  • Posts: 34
Re: find a point on arc then break with known distance
« Reply #3 on: June 17, 2009, 02:30:01 PM »
Okay..I'm able to get a point. Now I want to find two (2) other
points relative to the first point. Depending on the angle of
the curve/arc, 6 inches to the left of it and 6" to the right of it
...(or 6 inches top & botton of it).

(defun c:testforarc ()
(setq dis 12) ;break distance
(setq ent (entsel "\nSelect Curve: "))
(if ent (progn
         (setq pt (vlax-curve-getClosestPointto (car ent) (cadr ent)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        (setq pt1 (vlax-curve-getpointatdist tpt (* dis 0.5)))    ;;;;;;;;;I think I'm missing something here
        (setq pt2......)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
         (command "break"
                 pt
                 "f"
                pt1
                pt2
       )
       );progn
);if
)








CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: find a point on arc then break with known distance
« Reply #4 on: June 17, 2009, 03:55:41 PM »
You're on the right track.

FYI,

   ;; if not in WCS, always trans the entsel point to WCS
  (setq pt (vlax-curve-getclosestpointto ent (trans (cadr esel) 1 0)))

NOTE that curve-obj can be an entity name as well as a vla-object
...............
(vlax-curve-getarea curve-obj)
(vlax-curve-getclosestpointto curve-obj givenPnt [extend])
(vlax-curve-getclosestpointtoprojection curve-obj givenPnt normal [extend])
(vlax-curve-getdistatparam curve-obj param)
(vlax-curve-getdistatpoint curve-obj point)
(vlax-curve-getendparam curve-obj)
(vlax-curve-getendpoint curve-obj)
(vlax-curve-getfirstderiv curve-obj param)
(vlax-curve-getparamatdist curve-obj dist)
(vlax-curve-getparamatpoint curve-obj point)
(vlax-curve-getpointatdist curve-obj dist)
(vlax-curve-getpointatparam curve-obj param)
(vlax-curve-getsecondderiv curve-obj param)
(vlax-curve-getstartparam curve-obj)
(vlax-curve-getstartpoint curve-obj)
(vlax-curve-isClosed ent) ; true if Closed


Note that the distance along curve is from a START point and not your point.

Try this:  Note  no error checking, esp if pk point is too near the end of the arc
Code: [Select]
(defun c:breakarc (/ brkdis ent dist pkpt [t pt1 pt2)
  (setq brkdis 6)               ;break distance / 2
  (setq ent (entsel "\nSelect Curve: "))
  (if ent
    (progn
      (setq pkpt (cadr ent)
            ent  (car ent))
      (setq pt (vlax-curve-getClosestPointto ent pkpt))
      (setq dist (vlax-curve-getdistatpoint ent pt))
      (setq pt1 (vlax-curve-getpointatdist ent (+ dist brkdis)))
      (setq pt2 (vlax-curve-getpointatdist ent (- dist brkdis)))
      (command "break" "_non" pt1 "_non" pt2)
    )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: find a point on arc then break with known distance
« Reply #5 on: June 17, 2009, 03:58:25 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

EddieFromDc

  • Newt
  • Posts: 34
Re: find a point on arc then break with known distance
« Reply #6 on: June 18, 2009, 07:55:33 AM »
Cab,

Thank you very much!

T.Willey

  • Needs a day job
  • Posts: 5251
Re: find a point on arc then break with known distance
« Reply #7 on: June 18, 2009, 11:09:02 AM »
The lisp attached here ( Joe Burke's post ) might be of some help also.  IIRC, it breaks items without command calls.

[ http://www.theswamp.org/index.php?topic=28299.msg339473#msg339473 ]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Joe Burke

  • Guest
Re: find a point on arc then break with known distance
« Reply #8 on: June 19, 2009, 08:40:48 AM »
Hey Tim,

Thanks for the pointer.

I still use it often.