Hello,
Since we didn’t manage to linearize text from an existing DXF, we tried to create a new DXF, from scratch and create polylines with 2D and 3D points.
We used the documentation avaiable here Add a polyline|Documentation, our only change in order to compile was to replace CadBaseEntity with CadEntityBase.
The final DXF seems to be corrupted and cannot be open in any CAD editor. We get:
undefined group code 90 for object
invalid or incomplete DXF input – drawing discarded
Could you please have a look at code we used and provide an advice? It’s available below.
Thank you,
Andrei
public static void Test3D(string outputDxfFile)
{
var cadImage = new CadImage();
CadPolyline polyline = new CadPolyline();
polyline.ChildObjects.Add(new Cad3DVertex() { LocationPoint = new Cad3DPoint(-5, -5, 0) });
polyline.ChildObjects.Add(new Cad3DVertex() { LocationPoint = new Cad3DPoint(-5, 10, 0) });
polyline.ChildObjects.Add(new Cad3DVertex() { LocationPoint = new Cad3DPoint(20, 10, 0) });
polyline.ChildObjects.Add(new Cad3DVertex() { LocationPoint = new Cad3DPoint(20, -5, 0) });
polyline.Flag = CadPolylineFlag.CLOSED_POLY;
List<CadEntityBase> entities = new List<CadEntityBase>();
entities.Add(polyline);
cadImage.Entities = entities.ToArray();
cadImage.UpdateSize();
cadImage.Save(outputDxfFile, new DxfOptions
{
VectorRasterizationOptions = new CadRasterizationOptions
{
PageWidth = 1000,
PageHeight = 1000
}
});
}
public static void Test2D(string outputDxfFile)
{
var cadImage = new CadImage();
CadLwPolyline cadLwPolyline = new CadLwPolyline();
cadLwPolyline.Coordinates = new List<Cad2DPoint>();
cadLwPolyline.Coordinates.Add(new Cad2DPoint(-5d, -5d));
cadLwPolyline.Coordinates.Add(new Cad2DPoint(-5d, 10d));
cadLwPolyline.Coordinates.Add(new Cad2DPoint(20d, 10d));
cadLwPolyline.Coordinates.Add(new Cad2DPoint(20d, -5d));
cadLwPolyline.Flag = CadLwPolylineFlag.Closed;
cadLwPolyline.ConstantWidth = 0.1;
List<CadEntityBase> entities = new List<CadEntityBase>();
entities.Add(cadLwPolyline);
cadImage.Entities = entities.ToArray();
cadImage.UpdateSize();
cadImage.Save(outputDxfFile, new DxfOptions
{
VectorRasterizationOptions = new CadRasterizationOptions
{
PageWidth = 1000,
PageHeight = 1000
}
});
}