The Acad Offset Function, And A Couple Of Vegetables

The Acad Offset Function, And A Couple Of Vegetables

Anonymous
Not applicable
546 Views
12 Replies
Message 1 of 13

The Acad Offset Function, And A Couple Of Vegetables

Anonymous
Not applicable
I am currently working on a certain AutoCad VBA task -

Given a couple of closed Polylines (One is inside of the other) , I need to find another polyline which keeps a certain condition.

This condition is the following - for every point on the new polyline, if I create perpendiculars to the old polylines, the distance (meaning the length of the perpendiculars) will be the same in both directions. (The solution may be discreet)

It's almost like finding the average between to polylines.

First of all I would be glad to receive any kind of advice but my main question is about the AutoCad implementation of the offset function. How does it work? What are the mathematical caculations behind it?

Anyway, I would be highly grateful for any kind of help.
Thank you 🙂
Elizabeth
0 Likes
547 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable
"FrozenLips" wrote in message news:26050158.1107532813756.JavaMail.jive@jiveforum1.autodesk.com... >I am currently working on a certain AutoCad VBA task - > > Given a couple of closed Polylines (One is inside of the other) , I need > to find another polyline which keeps a certain condition. > > This condition is the following - for every point on the new polyline, if > I create perpendiculars to the old polylines, the distance (meaning the > length of the perpendiculars) will be the same in both directions. (The > solution may be discreet) > > It's almost like finding the average between to polylines. > > First of all I would be glad to receive any kind of advice but my main > question is about the AutoCad implementation of the offset function. How > does it work? What are the mathematical caculations behind it? I can't offer you any detailed math help, but if you happen to have land desktop, set one pline to an elevation, the other to a different elevation. Create a surface from those two. Then create contours, specifying only the elevation midway between the others you used. I don't know if that's accurate enough, but works for the situations I need something like that. (To my knowledge, there is nothing built-in that will handle that.)
0 Likes
Message 3 of 13

Anonymous
Not applicable
I'm still trying to figure out where the vegetables come into play. :-S -- I support two teams: The Red Sox and whoever beats the Yankees.
0 Likes
Message 4 of 13

Anonymous
Not applicable
Hey Tom. thanks a lot for the advice, it just might help with a couple of new ideas offered to me at the office.

And the vegetables? Wherever you'd like them to 😉

Tata,
Elizabeth
0 Likes
Message 5 of 13

Anonymous
Not applicable
> First of all I would be glad to receive any kind of advice but my main > question is about the AutoCad implementation of the offset function. How > does it work? What are the mathematical caculations behind it? sample in dev help "FrozenLips" wrote in message news:26050158.1107532813756.JavaMail.jive@jiveforum1.autodesk.com... >I am currently working on a certain AutoCad VBA task - > > Given a couple of closed Polylines (One is inside of the other) , I need > to find another polyline which keeps a certain condition. > > This condition is the following - for every point on the new polyline, if > I create perpendiculars to the old polylines, the distance (meaning the > length of the perpendiculars) will be the same in both directions. (The > solution may be discreet) > > It's almost like finding the average between to polylines. > > First of all I would be glad to receive any kind of advice but my main > question is about the AutoCad implementation of the offset function. How > does it work? What are the mathematical caculations behind it? > > Anyway, I would be highly grateful for any kind of help. > Thank you :) > Elizabeth
0 Likes
Message 6 of 13

Anonymous
Not applicable
"sample in dev help"

What do you mean by that (I;m new in here so....)


Elizabeth
0 Likes
Message 7 of 13

Anonymous
Not applicable
If you open the Developer Help menu in AutoCad and do a search for Offset there are fully functional examples you can paste right into a code page. gl Paul "Paul Richardson" wrote in message news:4205314c_2@newsprd01... >> First of all I would be glad to receive any kind of advice but my main >> question is about the AutoCad implementation of the offset function. How >> does it work? What are the mathematical caculations behind it? > > sample in dev help > "FrozenLips" wrote in message > news:26050158.1107532813756.JavaMail.jive@jiveforum1.autodesk.com... >>I am currently working on a certain AutoCad VBA task - >> >> Given a couple of closed Polylines (One is inside of the other) , I need >> to find another polyline which keeps a certain condition. >> >> This condition is the following - for every point on the new polyline, if >> I create perpendiculars to the old polylines, the distance (meaning the >> length of the perpendiculars) will be the same in both directions. (The >> solution may be discreet) >> >> It's almost like finding the average between to polylines. >> >> First of all I would be glad to receive any kind of advice but my main >> question is about the AutoCad implementation of the offset function. How >> does it work? What are the mathematical caculations behind it? >> >> Anyway, I would be highly grateful for any kind of help. >> Thank you :) >> Elizabeth > >
0 Likes
Message 8 of 13

Anonymous
Not applicable
"FrozenLips" wrote in message news:6613408.1107633098916.JavaMail.jive@jiveforum1.autodesk.com... > And the vegetables? Wherever you'd like them to ;) Ouch! 😮
0 Likes
Message 9 of 13

Anonymous
Not applicable
I think what elizabeth is looking for is the actual mathematical algorithm (not VBA code) that AutoCAD uses to determine in space what the new offsetted object will look like. Things like lines and circles are easy, but mis-shapen closed polylines offsetted can often form shapes somewhat different than the original - but of course at all times maintaining the minimum specified offset distance.

Excellent question, but I'm afraid I do not know the answer. I've thought about it for a few minutes, and can't even muster up a rough logic flow chart for how it could work...

Must be some vector algebra trickery to determine it - then perhaps merging of items.

sorry 😞

DRW
0 Likes
Message 10 of 13

Anonymous
Not applicable
Yup, you got it right.

The only reasonable mathematical solution I had found for it was the following:
(Though it IS discreet)

- find the center of the mass of the inner polyline using integrals
- from it build a polar array of rays
- using the intersections of the rays and the polylines, some approximation of the needed polyline can be created.

Ofcourse, the more rays we send, the more approximate we get.

And yet this solution may not work well with complex topographies...... (Think about a U shaped inner polyline inside of a circle shaped polyline)

Anyhoops, this is the best I cold think about (Without getting down to linear Algebra stuff 🙂

tata,
lata,
Elizabeth
0 Likes
Message 11 of 13

Anonymous
Not applicable
ah..;0 "DRW1975" wrote in message news:26457796.1107806706163.JavaMail.jive@jiveforum2.autodesk.com... >I think what elizabeth is looking for is the actual mathematical algorithm >(not VBA code) that AutoCAD uses to determine in space what the new >offsetted object will look like. Things like lines and circles are easy, >but mis-shapen closed polylines offsetted can often form shapes somewhat >different than the original - but of course at all times maintaining the >minimum specified offset distance. > > Excellent question, but I'm afraid I do not know the answer. I've thought > about it for a few minutes, and can't even muster up a rough logic flow > chart for how it could work... > > Must be some vector algebra trickery to determine it - then perhaps > merging of items. > > sorry :( > > DRW
0 Likes
Message 12 of 13

Anonymous
Not applicable
One way of doing it is using Voronoi diagrams. Coding this stuff is pretty complicated. If you're looking for something simpler maybe using (vlax-curve-getSecondDeriv curve-obj param) at each vertex to get the tangent vector and then running a perpendicular vector from the tangent with the desired distance you'll get the points to draw the offset polyline. I believe your "ray" approach will not work cause rays from the mass center to the polyline are not perpendicular to the polyline at all points. The offset polyline is the intersection of a plane at your offset distance, and a solid extruded from your original polyline at a 45 degree angle. -- Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica "FrozenLips" wrote in message news:23893267.1107812450086.JavaMail.jive@jiveforum1.autodesk.com... > Yup, you got it right. > > The only reasonable mathematical solution I had found for it was the > following: > (Though it IS discreet) > > - find the center of the mass of the inner polyline using integrals > - from it build a polar array of rays > - using the intersections of the rays and the polylines, some > approximation of the needed polyline can be created. > > Ofcourse, the more rays we send, the more approximate we get. > > And yet this solution may not work well with complex topographies...... > (Think about a U shaped inner polyline inside of a circle shaped polyline) > > Anyhoops, this is the best I cold think about (Without getting down to > linear Algebra stuff :) > > tata, > lata, > Elizabeth
0 Likes
Message 13 of 13

Anonymous
Not applicable
So it seems as though you are trying to generate an intermediate contour line from two existing ones, perhaps there is a better way to interpolate between the two... This business of using perpendicular distances being equal between plines may be a bit more complicated than is required... (the offset routine is only for a constant distance, your problem will have variable distances, and even if you were to figure it out, it may be useless)

Perhaps you want a routine that does the following:

compare pline1 & pline2 for the number of points that form them individually.

match up control points that form pline1 and pline2 by some method (say shortest distance, or say numerical order on the actual pline) <- this is the trickiest part depending on how your plines are created in the begining.

interpolate between these two points to form a new midpoint

connect all the midpoints - and hence your new pline


does that sound reasonable?


DRW
0 Likes