Arc bulge point

Arc bulge point

etilley327KA
Advocate Advocate
749 Views
4 Replies
Message 1 of 5

Arc bulge point

etilley327KA
Advocate
Advocate

Anyone have an idea of how I can check which portion of the circumference the arc is on. I have the code and can get the bulge point on either side, but cant figure out how to determine which? Although I guess there could be a problem if its a half circle. Ideas? Trying to get the bulge point from an arc.

(defun c:test (/ pnt1 pnt2 pnt3 arcent arcdata orgstartPoint orgendPoint centerPoint starang arclength endang chordcenter radius bulgepnt)
  (setq pnt1 (getpoint "\nPick point: "))
  (setq arc (entsel "\nSelect Arc: "))
  (setq arcdata (vlax-ename->vla-object (car arc)))
  (setq orgstartPoint (vlax-curve-getstartpoint arcdata))
  (setq orgendPoint (vlax-curve-getendpoint arcdata))
  (setq centerPoint (cdr (assoc 10 (entget (car arc)))))
  (setq startang (angle centerPoint orgstartPoint))
  (setq arclength (vla-get-ArcLength arcdata))
  (setq radius (vla-get-radius arcdata))
  (setq endang (angle centerPoint orgendPoint))
  (setq chordcenter (polar orgstartPoint (angle orgstartPoint orgendPoint) (/ (distance orgstartPoint orgendPoint) 2)))
    (if
      (????????)
      (setq bulgepnt (polar centerPoint (angle chordcenter centerPoint) radius));larger
      (setq bulgepnt (polar centerPoint (angle centerPoint chordcenter) radius));smaller
    )
  (command "_circle" bulgepnt 0.5"")
);defun
0 Likes
750 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

The bulge is negative if the arc is clockwise; positive, otherwise. If it's half circle the bulge may be 1.0 or -1.0.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

etilley327KA
Advocate
Advocate

I think I found a workable solution. Other than if its a half circle.

 

(defun c:test (/ pnt1 pnt2 pnt3 arcent arcdata orgstartPoint orgendPoint centerPoint starang arclength endang chordcenter radius bulgepnt halfCC)
  (setq pnt1 (getpoint "\nPick point: "))
  (setq arc (entsel "\nSelect Arc: "))
  (setq arcdata (vlax-ename->vla-object (car arc)))
  (setq orgstartPoint (vlax-curve-getstartpoint arcdata))
  (setq orgendPoint (vlax-curve-getendpoint arcdata))
  (setq centerPoint (cdr (assoc 10 (entget (car arc)))))
  (setq startang (angle centerPoint orgstartPoint))
  (setq arclength (vla-get-ArcLength arcdata))
  (setq radius (vla-get-radius arcdata))
  (setq endang (angle centerPoint orgendPoint))
  (setq chordcenter (polar orgstartPoint (angle orgstartPoint orgendPoint) (/ (distance orgstartPoint orgendPoint) 2)))
  (setq halfCC (* pi radius))
    (cond
      ((> arclength halfCC) (setq bulgepnt (polar centerPoint (angle chordcenter centerPoint) radius)));larger
      ((< arclength halfCC) (setq bulgepnt (polar centerPoint (angle centerPoint chordcenter) radius)));smaller
      ((= arclength halfCC) (setq bulgepnt centerPoint));half circle
    )
  (command "_circle" bulgepnt 0.5"")
);defun
0 Likes
Message 4 of 5

john.uhden
Mentor
Mentor

@etilley327KA ,

Adding to your new knowledge of bulges, here is one method (there may be more) to get your midpoint (I'm making this up as I go)...

;; Let's say you have already picked the bulged segment at some point.
(setq pick (entsel "\nSelect polyline arc: "))
;; then
(defun getbulgemidp (pick / obj p param midp)
  (setq obj (vlax-ename->vla-object (car pick)))
  (setq p (vlax-curve-getclosestpointto obj (cadr pick)))
  (setq param (+ (fix (vlax-curve-getparamatpoint obj p)) 0.5))
  (setq midp (vlax-curve-getpointatparam obj param))
)
;; Although you should add some code to ensure you have selected a polyline.
;| NOTE:
The supreme being, Owen Wengerd (not Lilu), has warned not to trust parameters but I and most (if not all) others have never had a problem with that.
I think it happens only in a drawing that Owen has mutated.
BTW. it will work on straight segments as well.
|;

 

John F. Uhden

0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

You are talking about an Arc entity, not an arc segment in a Polyline, right?

"Bulge" is a word associated with a Polyline arc segment.  If by "bulge point" for an Arc you just mean the midpoint of the Arc [by calculation rather than by Osnap], you don't need to calculate the start and end angles by measuring the angles from the center to the endpoints.  You don't even need the endpoints, nor the VLA-object conversion of the Arc.  Those angles, as well as the radius, are stored directly in entity data:

 

....
  (setq
    arcsel (entsel "\nSelect Arc: "); selection
    arcent (car arcsel); entitiy name
    arcdata (entget arcent); entity data list
    centerPoint (cdr (assoc 10 arcdata))
    startang (cdr (assoc 50 arcdata))
    endang (cdr (assoc 51 arcdata))
    radius (cdr (assoc 40 arcdata))
....
); setq
 
And you could just take the angle halfway between [add them together and divide by 2], and if the start angle is more than the end angle [it crosses the 0° direction], the opposite of that [add pi to it], and use that angle in (polar) from the center with the radius to find the midpoint.
 
BUT, you can also do this, with only the entity name [no VLA object conversion, no center point, no endpoints, no radius]:

(vlax-curve-getPointAtDist arcent
  (/ (vlax-curve-getDistAtPoint arcent (vlax-curve-getEndPoint arcent)) 2)
)
Kent Cooper, AIA
0 Likes