
how to write out dxf spline data from excel
So I have a routine in excel to calculate some curves for some sliding surfaces and have the export to a dxf file working but want to clean the last thing up which is to take all these points and make a spline (right now I have a bunch of line segments from each of the points, works but not smooth). I have the dxf reference manual but let's just say the documentation is not the easiest to use for splines. I have tried to export a simple spline from my cad system to a dxf file but again things just don't seem to make sense. I have read in other places that splines can be built via knots and controls points (what my cad exports) or via fits and start & end tangents. What I have is all the points that the spline must go thru and the beginning and ending points. I'm looking for help in writing the exact formatting in VBA to write out a valid DXF spline. Since this is a complete program, I'm not interested in cut and paste options, need to write out the dxf file so it can be shared with other nonautocad systems.
thanks,
Michael


So you want your spreadsheet to export/create a dxf file with the splines? Well you need to know all about knots & control points etc. I don't envy you in this exercise.
I'd let AutoCAD create the dxf, I think. Use your line segments created in Excel to create a segmented polyline in CAD. PEDIT>>Spline Fit it. Convert it to a true spline with the SPLINEcommand. Now create the dxf from that.


yes that would be easier but time consuming each time I run the excel sheet which I do a lot. so finding the right way to do the spline would be benefical.
know of any good sources for more detailed info on the dxf spline formatting?
thanks,
Michael


I don't know if these are "good" sources but look like a good start:
http://en.wikipedia.org/wiki/NURBS
http://findarticles.com/p/articles/m...65/ai_12526208
http://www.cl.cam.ac.uk/teaching/200...CI/AG/p3c.html
And dxf format, from a dxf reference:
SPLINE
The following group codes apply to spline entities. In addition to the group
codes described here, see “Common Group Codes for Entities” on page 53.
For information about abbreviations and formatting used in this table, see
“Formatting Conventions in This Reference” on page 2.
Spline group codes
Group code Description
100 Subclass marker (AcDbSpline)
210 Normal vector (omitted if the spline is nonplanar)
DXF: X value; APP: 3D vector
220, 230 DXF: Y and Z values of normal vector (optional)
70 Spline flag (bit coded):
1 = Closed spline
2 = Periodic spline
4 = Rational spline
8 = Planar
16 = Linear (planar bit is also set)
71 Degree of the spline curve
72 Number of knots
73 Number of control points
74 Number of fit points (if any)
42 Knot tolerance (default = 0.0000001)
43 Controlpoint tolerance (default = 0.0000001)
44 Fit tolerance (default = 0.0000000001)
12 Start tangent—may be omitted (in WCS)
DXF: X value; APP: 3D point
22, 32 DXF: Y and Z values of start tangent—may be omitted (in WCS)
13 End tangent—may be omitted (in WCS)
DXF: X value; APP: 3D point
23, 33 DXF: Y and Z values of end tangent—may be omitted (in WCS)
40 Knot value (one entry per knot)
41 Weight (if not 1); with multiple group pairs, they are present if all are not 1
10 Control points (in WCS); one entry per control point
DXF: X value; APP: 3D point
20, 30 DXF: Y and Z values of control points (in WCS); one entry per control point
11 Fit points (in WCS); one entry per fit point
DXF: X value; APP: 3D point
21, 31 DXF: Y and Z values of fit points (in WCS); one entry per fit point


Thanks Carl, had seen some of that already but so far doesn't help me doing the coding. Have you heard if the using only fit points and start & end tangents work? that would be easy and more like what I have done with other cad systems.
thanks


You're welcome, but sorry don't know any more about specific dxf requirements. It apears (from dxf reference) that tangents could be omitted but not much else.
It you want to consider my first suggestion I could help on the import/paste coordinates to create a polyline or spline, etc. that would speed up the manual process.

Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules