Page 1 of 1
DXFExport.net Spline vs Bezier
Posted: 26 Jun 2007, 18:28
by francoas
Hi.
Dxf files can contain any kind of spline, not only cubic bezier.
In fact I am able to import any kind of spline, any degree, provided i can read control points AND KNOTS (degree can be inferred).
Now how can i write back the same spline ?
I have in hands control points and knots, but it looks like I can provide only knots and the library supposes it is a cuibic bezier.
Is there a way to provide points, knots (and maybe degrre) that are just to be written on the dxf file as they are ?
Posted: 26 Jun 2007, 20:07
by francoas
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by francoas</i>
<br />Hi.
I have in hands control points and knots, but it looks like I can provide only knots <hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Errata corrige: I meant "it looks like I can provide only control points"
Posted: 27 Jun 2007, 11:00
by support
Hello!
Currently we support splines of the third degree only.
There are two ways of defining such splines:
<ul><li>using Knots, Controls</li>
<li>using Fits, StartTangent, EndTangent</li></ul>
These ways cubic spline is received.
<b>CADtoDXF</b> package allows further export to DXF file format. This package works together with <b>CAD Import VCL</b>.
<b>CAD Import VCL</b> is available at:
http://www.cadsofttools.com/download/cadimportvcl.zip
Respective <b>CADtoDXF</b> modules are in the ..\cadimportvcl\Delphi\CADExport\.. folder of the library.
In future we plan to add support splines of the second degree.
Sergey.
Please post questions to the forum or write to
support@cadsofttools.com
Posted: 27 Jun 2007, 11:20
by francoas
Well... as far as I know to construct a cubic bezier the control points with the degree are enough. On the contrary with control points and knots I can represent any general spline.
I DO have the control points and knots.
I just need to write them on the dxf file.
Btw: I am developing under MS VS C++
Posted: 27 Jun 2007, 14:23
by support
We have two products which support direct export to DXF (absolutely compatible with AutoCAD):
<ul><li><b>DXF Export VCL</b> - Delphi, C++ Builder.</li>
<li><b>CAD Import .NET</b> - C#, VB.</li></ul>
<ol type="1"><li>Can you please give us points and knots of any simple spline that you need to export?</li>
<li>What of our products and in what kind of project you would like to use it?</li></ol id="1">
Sergey.
Please post questions to the forum or write to
support@cadsofttools.com
Posted: 27 Jun 2007, 19:18
by francoas
1. I am using DXFExport from dxfexportnet
2. Here is an example of cp and knots
Knots:
0.0
0.0
0.0
0.0
0.1186275907147644
0.3187996616023263
0.4213989176149002
0.540601925494256
0.6592295162090204
0.7492014753808887
0.8816076402878558
1.0
1.0
1.0
1.0
Points (X, Y)
76.29665534946302
230.5634437361183
89.93587425021931
289.9018072493742
219.1689313371001
528.864012021167
88.51981092541207
-21.23607550791761
264.6368832548646
210.5197503105761
260.4701106333912
489.2168945475104
329.1245051770962
139.4610626393628
485.5546477325602
390.6707709502498
569.7305355678341
65.72600431511295
412.33411771812
70.99123870606898
351.9438825179578
77.72933758328942
Frank
Posted: 28 Jun 2007, 12:58
by support
Hello Frank,
The following code creates spline basing on data from your post and saves it into the DXF file. We used <b>CAD Import .NET</b> which contains direct export to DXF. It is very important: <b>DXF Export .NET</b> does not support this kind of export. It will be included in future versions of the library.
Thus for the moment <b>CAD Import .NET</b> includes both import and export. <b>DXF Export .NET</b> contains restricted export into DXF file format.
This code is based on <b>Viewer</b> demo from the extended version of <b>CAD Import .NET</b>.
Code: Select all
<font color="blue">private void</font id="blue"> btnAddSpline_Click(<font color="blue">object</font id="blue"> sender, System.EventArgs e)
{
<font color="blue">if</font id="blue">(cadImage == <font color="blue">null</font id="blue">)
{
CreateNewImage();
}
CADSpline poly = <font color="blue">new</font id="blue"> CADSpline();
poly.Color = Color.Red;
<font color="green">//knots</font id="green">
poly.Knots.Add(0.0f);
poly.Knots.Add(0.0f);
poly.Knots.Add(0.0f);
poly.Knots.Add(0.0f);
poly.Knots.Add(0.1186275907147644f);
poly.Knots.Add(0.1186275907147644f);
poly.Knots.Add(0.3187996616023263f);
poly.Knots.Add(0.4213989176149002f);
poly.Knots.Add(0.540601925494256f);
poly.Knots.Add(0.6592295162090204f);
poly.Knots.Add(0.7492014753808887f);
poly.Knots.Add(0.8816076402878558f);
poly.Knots.Add(1.0f);
poly.Knots.Add(1.0f);
poly.Knots.Add(1.0f);
poly.Knots.Add(1.0f);
<font color="green">//Points (X, Y)</font id="green">
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(76.29665534946302, 230.5634437361183, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(89.93587425021931, 289.9018072493742, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(219.1689313371001, 528.864012021167, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(88.51981092541207, -21.23607550791761, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(264.6368832548646, 210.5197503105761, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(260.4701106333912, 489.2168945475104, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(329.1245051770962, 139.4610626393628, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(485.5546477325602, 390.6707709502498, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(569.7305355678341, 65.72600431511295, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(412.33411771812, 70.99123870606898, 0.0));
poly.Controls.Add(<font color="blue">new</font id="blue"> DPoint(351.9438825179578, 77.72933758328942, 0.0));
<font color="green">//-----------------</font id="green">
poly.LineWeight = 0.1;
poly.Loaded(cadImage.Converter);
cadImage.CurrentLayout.Entities.Add(poly);
cadImage.Converter.OnCreate(poly);
cadImage.GetExtents();
cadImage.InvalidateSelectEntity(<font color="blue">this</font id="blue">.cadPictBox, 1);
SaveAsDXF(@"c:\Spline.dxf");
}
<font color="blue">internal void</font id="blue"> CreateNewImage()
{
<font color="blue">if</font id="blue">(cadImage != <font color="blue">null</font id="blue">)
cadImage.Dispose();
scale = 1;
prev_scale = 1;
pos = <font color="blue">new</font id="blue"> PointF();
cadImage = <font color="blue">new</font id="blue"> CADImage();
cadImage.SelectionMode = SelectionEntityMode.Enabled;
<font color="blue">this</font id="blue">.cadImage.UseBufMetafile = <font color="blue">false</font id="blue">;
<font color="blue">if</font id="blue">(cadPictBox.BackColor == Color.White)
White_Click();
<font color="blue">else</font id="blue"> Black_Click();
<font color="blue">this</font id="blue">.cadImage.InitialNewImage();
EnableButton(<font color="blue">true</font id="blue">);
<font color="blue">this</font id="blue">.trvEntity.Nodes.Clear();
<font color="blue">this</font id="blue">.DoResize();
<font color="blue">this</font id="blue">.cadPictBox.Invalidate();
ObjEntity.cadImage = cadImage; <font color="green">//for object inspector</font id="green">
ObjEntity.propGrid = <font color="blue">this</font id="blue">.propGrid; <font color="green">//for object inspector</font id="green">
cadImage.UseWinEllipse = <font color="blue">false</font id="blue">;
prtForm.Image = <font color="blue">this</font id="blue">.cadImage;
}
Sergey.
Please post questions to the forum or write to
support@cadsofttools.com
Posted: 28 Jun 2007, 13:05
by francoas
Hello Sergey
Well... for the import we are using CADImporterDll...
Anything about it ?
Franco
Posted: 28 Jun 2007, 13:49
by support
First of all we must notice that <b>CAD Import .NET</b> is much more powerful then <b>CADImporter.DLL</b>.
Secondly, <b>CAD Import .NET</b> and <b>DXF Export .NET</b> are base on the same platform.
Thirdly, direct export (which will be a part of <b>DXF Export .NET</b> in future) is already integrated into <b>CAD Import .NET</b>. Thus if you use <b>CAD Import .NET</b> you get <b>two in one</b>.
All these points allow to suggest that using <b>CAD Import .NET</b> is much more preferable then <b>CADImporter.DLL</b> plus <b>DXF Export .NET</b>.
Sergey.
Please post questions to the forum or write to
support@cadsofttools.com