Page 1 of 1

Input spline data via script

Posted: Sun Nov 07, 2010 5:36 pm
by ov10fac
I use splines a lot to design canoes. I use tables of offsets from texts and plans then enter them into a spread sheet. Once the spread sheet is complete I export the points to a cvs file so I have a list of x,y coordinates.

I presently input each set manually, and as you can imagine I often make a mistake. I have looked at the inputxy.ps script and it seems to be close to what I need, but not really.

What I need is a script that I can call to enter the points after I have selected the spline tool. As you know the command line first asks for an origin, then the points in succession.

If anyone has a script or can give me some pointers it would be much appreciated.

Just an FYI, I have over 20 years programming experience in C, C++ and a few other languages.

Many thanks in advance.

Posted: Tue Nov 09, 2010 10:13 am
by andrew
At this point (QCAD 2) I would recommend to produce a DXF file on your end and load it with QCAD. DXF is fairly readable (plain text) and a DXF file with a single spline in it should be quite easy to produce if you already have the control points.

Here's a minimalistic DXF file which contains one simple, open, 3rd degree spline with four control points at (0,0), (20,30), (40,30) and (60,0):

Code: Select all

  0
SECTION
  2
ENTITIES
  0
SPLINE
  5
43
  8
0
 62
256
370
-1
  6
ByLayer
100
AcDbEntity
100
AcDbSpline
 70
8
 71
3
 72
8
 73
4
 74
0
 40
0.0
 40
0.0
 40
0.0
 40
0.0
 40
1.0
 40
1.0
 40
1.0
 40
1.0
 10
0.0
 20
0.0
 30
0.0
 10
20.0
 20
30.0
 30
0.0
 10
40.0
 20
30.0
 30
0.0
 10
60.0
 20
0.0
 30
0.0
  0
ENDSEC
  0
EOF
Some explanation: DXF files are organized in two-liners. The first line always contains a group-code about what to expect on the next line. The second line contains the actual data.

E.g. the degree of the spline is stored as:

Code: Select all

 71
3
The group code "71" indicates that the next line contains the degree of the spline. "3" is the degree (2 or 3).

Group codes 10, 20 and 30 announce the x,y,z coordinates of a point. E.g. the second control point of the spline is:

Code: Select all

 10
20.0
 20
30.0
 30
0.0
I.e. (x,y,z): (20.0,30.0,0.0)

Complete DXF spec with all spline group codes explained: http://images.autodesk.com/adsk/files/acad_dxf2.pdf

Hope that helps.

Thanks

Posted: Tue Nov 09, 2010 1:53 pm
by ov10fac
Andrew,

Many thanks. I think that might just be what I'm looking for.