What does (vla-getBulge) returned value represent?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anyone explain the actual meaning of the value returned by (vla-getBulge) at a parameter value on a LWPolyline, particularly on an arc segment? I was assuming it would return the bulge factor of the segment, i.e. the (cdr (assoc 42 entitydata)) value associated with the vertex at the beginning of that segment. But take a look at this:
The green is a simple LWPolyline of two equal arc segments. They have the same bulge factors except for the sign [cyan at the top]. The red are the Parameter values along the Polyline. Notice that the yellow values returned by (vla-getBulge) represent that entity-data bulge factor up to the midpoint of the first segment, but then the sign switches to negative before it gets 3/4 of the way along that segment. [It actually changes immediately after half-way -- using parameter 0.501 returns -0.5.] Then it stays the same across the vertex where the direction of curvature reverses. And the -0.867... [I lopped off a few decimal places] happens to be the (assoc 42) value associated with the final vertex, whatever that may mean when there's no segment leading from it [it's not what it would be to close the Polyline -- that's -2.0].
The reason I want to know is that I was hoping to use (vla-getBulge) to determine, for a calculated [not User-picked] location that might fall anywhere along a LWPolyline, whether it's curved there, and if it is, whether the local direction of curvature is CW or CCW. I don't need to know the degree of curvature [the radius], just the direction, and at any location along the segment. But it appears that's not something that can be determined by the sign of the returned value, as I was expecting. Either or both of the numerical value and/or the sign can apparently change within a single segment.
Also, I experimented with changing the first segment to a line [not shown], and even then, parameter values up to 0.5 return 0.0 as expected, but parameter 0.501 just past the midpoint of that segment returns -0.5 just as when it's an arc segment. Searching for an answer in the Forums, I encountered routines that check whether (vla-getBulge) returns 0, on the assumption that a 0 return means you're on a line segment, but that is apparently not valid.
It looks like if you're within the first half of a segment, it returns the bulge factor for that segment, and if you're within the second half, it returns the bulge factor for the next segment, as illogical as that seems. [The latter seems rather pointless on the final segment of an open Polyline.] Does anyone know whether that's always the case? [Might it not be in a more complex Polyline than in the image?] If not, what does the returned value really represent?
If that is a reliable standard, I suspect one could check whether a parameter value is in the upper half of the range between integer values [within the second half of a segment], and if so, back it off by 0.5 and check (vla-getBulge) for that backed-off parameter value. Does that seem valid? I already have found that it's not quite right for parameter 1.5 in the image -- by that standard, that location ought to still return -0.5. Parameter 1.499 does, but it switches at the halfway point in that segment, unlike what happens in the first segment, where it doesn't switch until just after the midpoint. Could that difference be related to its being the last segment?
[All this ignores the possibility of a "quirky Polyline" -- Search for that phrase for discussions of quirky circumstances in which integer parameter values may not fall at vertices.]
Any insights would be appreciated.