DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Adjustable point density on curves

Started by bdeck, April 19, 2008, 12:51:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bdeck

Jerry,

Prior to sending a cut file to a cnc shop, I sometimes convert the curves to lines to avoid possible file conversion errors.

The goal, of course, is to
1) draw with very low point density so that the curves can be edited with ease.
2) replace the curve with a high density polyline that is reasonably true to the original curve, and retains the original points.


Vector convert is not reliable, as it does not preserve the original points in the curve. (see example below)

My solution was to use the ParallelByDistance command (F2) with a distance setting of 0, and then delete the original curve. That works fine in V 15, but in 17 and 18 it brings up the out of range dialog, unless I use a small number like .00001. (Edit: Oops... Parallel command (=) allows true zero distance parallels without the numeric input dialog. See subsequent post. )

That's ok, but worse still, there seems to be no way to set the desired point density on the resulting line.

When the interpolation bugs are fixed, a way to adjust the point density without losing the original control points would be helpful.

Thanks,

BD



support

I am not sure if it would help but if you draw a curve and then duplicate that curve placing it in the same location but on another layer,
then hide that layer and the copied curve,
then using the point select mode you can cut that curve and if you do so more than once each piece of the curve will break into many small segments,
you then could use the smooth commands and reduce the number of points till you have something close to what you want in a point count,
then make that copy visible and adjust the point nodes on the original curve to match.
After wards you can delete the copy.

I know this sounds convoluted but it might get you want you are after. Controlling point density and maintaining original points and curvature is the biggest hurdle and hardest to pull off in this kind of process.

Dr PR

Jerry,

If you ever do attempt to control point density with respect to curvature, provide a user setting, like the "degree of fitness" in "Extrude along a curve."

One place this would be very useful is for creating the curves that are to be used as the "frame" for surfaces generated with "Surface Connect." Surface Connect can generate huge numbers of facets, with many of them in flat parts of the surface. All that is really needed are lots of small facets in the curved areas and a few large facets in the flat areas. It would reduce drawing size, increase speed, etc.
DesignCAD user since 1987

prl

#3
Hi Bd, you could probably code this yourself.  Here's an outline.

1.  Store the current sys(9). Set a point on the curve.  Select and make a duplicate of this curve at some dx offset in empty space.

2.  With the copy, use the segment command to segment the curve.  The point density is controlled by the number of segments you specify.  As the number of segments is increased, the curve fitting gets closer and closer to the original curve. 

3.  With curves note the segment command will create equal length polyline segments (may have more than 2 points), so cycle all the new polylines and read and store the first and last points of segment 1 and the last point of all remaining segments.   

4.  Using the stored points, draw a new vector.  You can use the negative offset value to have it draw on top of the original curve.

If you do code it , let me know if you run into roadblocks.




bdeck

Hello all,

Thanks Jerry, your Section Cut suggestion worked better than F2, and got me to experiment a little more.

In Version 18 the only applicable commands I have found that also preserve the original control points of a curve are Section Cutoff, Section Cut by Line, Trim, and Parallel ( = ).

Parallel (=)  works just fine. Just gravity snap twice to the same curve.  No need to plug in a number as in F2. (dunno why I didnt try it sooner)

All of the above commands generate identical point sets EXCEPT Trim.

The pointset generated by Trim is weaker around sharp radii than the others, but all commands use the original control points and locate new  intermediate points accurately.  (So fixing the interpolation errors in trim, slice, etc, should not be impossible)

The Section Cut and Cutoff commands actually do an automatic vector convert as well.

Vector Convert and Segment commands do not use the original control points, so they are inherently error prone when working with curves.

If the point density created by the the Parallel or Section Cut commands is insufficient for the task at hand, the only recourse is to repeat the command. But the second generation does not interpolate from the original spline, it interpolates from the first generation, better than linear interpolation, but not as good as would result from a user selectable point density. And where the first generation may be too sparse, the second generation may be too dense.

For the time being, a point reduction macro that works on a second generation parallel curve will be a fair substitute, but a point density command that meets the first 2 requirements would be much better.


Many Thanks,

BD

prl

Too bad, another bug I didn't know of,  as Bd's attached file easily demonstrates, the Segment command doesn't correctly segment curves.

prl

#6
Well after studying this a bit more I'm discouraged.  It turns out no command in DesignCAD correctly finds a point on a curve between control points.  You can not accurately line snap to a curve, intersect a line with a curve, trim to a curve etc between control points.  All the math routines will miss the curve. Seems where DesignCAD draws a curve on the screen and where it thinks it exists internally are in two different locations, see the attached file. You'll need to superimpose the red version onto the blue.

All this makes me wonder if the curve routine is visually drawing itself wrong, or the equation of the spline curve is wrong, or ALL the other routines are wrong.

bdeck



Quote from: prl on April 22, 2008, 04:12:53 AM
It turns out no command in DesignCAD correctly finds a point on a curve between control points.

Hi Prl,

To put this in perspective, in pre-CAD naval architecture, a drawing error the thickness of a fine pencil line would generate an unacceptable error.

A 1/16" error in a car body surface would be noticeable from a distance.

I am hopeful that DC's interpolation routines will be corrected soon to yield a useful, if not floating point, precision.

Quote
All this makes me wonder if the curve routine is visually drawing itself wrong, or the equation of the spline curve is wrong, or ALL the other routines are wrong.

Its hard to tell, but I suspect it is not just a rendering error, because the parallel and trim commands generate  new splines with points that fall exactly on the original spline (no matter how far you zoom in).



Regards,

BD

prl

#8
Quote from: bdeck on April 22, 2008, 08:11:43 AM
I am hopeful that DC's interpolation routines will be corrected soon to yield a useful, if not floating point, precision.

I've come to the conclusion the rendering is correct using a cubic B-spline, so the interpolation of the intercepts between control points is poor.  Granted the intercepts will always be an approximation, but what we have occurring now is very coarse.  The vector convert example you posted shows about a  7/8" error (at the bottom) on a roughly 6'x16' curved outline. 


Edit:

Came up with a trick that may be useful until they fix all this. Exporting the curve to an autocad 12 dwg format forces a different internal conversion routine. Then reimporting that dwg yields a better vector converted curve in my view then the native vector convert. Note the below code requires DC 18.


Edit again:  noticed the dwg import always overrides the base unit and sets it to "in".  Added some code to put things back.


'Program: curve2line  (a vector convert trick using autocad export and reimport)
'
'use version 18.2 only

if sys(80)=0 then
  Message "Nothing selected. . . press any key to continue"
  END
end if

sys1100 = sys(1100) 'store current base drawing unit

d$="c:\curve"
>DwgOut
{
<Filename [d$]
<type 0  'AutoCAD 12 in version 18
<2PointLine 0
<SelectOnly 1
}

>DwgIn
{
<Filename [d$]
<ExplodeBlocks 0
<SkipHatch 1
}

'you could have it reform a new curve using the vectorized line, if
'you want that, uncomment the below
'>linetocurve
'{
'}

sys(1100) = sys1100 'restore current base drawing unit

End

bdeck

#9
Hi Prl,

Very nice trick.

For higher point density, your macro plus CurveToLine, and then Parallel (0 distance) gives better results than 2 consecutive parallel commands.

Thanks,

BD


PS:  DWG 12 seems to be fussier about how endpoints in closed curves are treated than are later versions. So to avoid errors, 12 appears also to be the safest version with which to ship files with intact splines.


prl

#10
Quote from: bdeck on April 22, 2008, 06:34:20 PM
PS:  DWG 12 seems to be fussier about how endpoints in closed curves are treated than are later versions. So to avoid errors, 12 appears also to be the safest version with which to ship files with intact splines.

Bd, glad the trick is useful.

Did you mean the above as you wrote it?  You actually can't send files with intact splines in AutoCAD version 12 format.  The reason this trick works is because the spline was first introduced with AutoCAD 13.  So for backwards compatibility, I'm guessing the opendwg folks wrote the nice routine to segment the spline into a polyline.

Edit:  regarding the higher point density, I suppose you can repeatedly run the "trick" if you uncomment the >linetocurve portion. 

bdeck

#11
QuoteDid you mean the above as you wrote it?

I stand corrected.

I've been having problems with a vendor corrupting splines in my dwg V14 files during conversion to his cutting format.

My solution was to send polylines instead, which are incorruptible.

The real problem was errors in my source spline point list (generated in v 15.3). Elimating the spline eliminated the error.

Thanks again.

BD