3D entity filled

If you have any comments or questions about our developing tools, please do not hesitate to contact us at this forum

Moderators: admin, SDS, support

3D entity filled

Postby Peddy » 29 Jun 2009, 15:34

-I need to fill 3D entity, how can i do? for example cube or square with the vertexes on different plans

-Can I fill the thickness?
Peddy
 
Posts: 3
Joined: 21 May 2009, 10:38

Re: 3D entity filled

Postby support » 30 Jun 2009, 13:55

Hello.
You can fill 3D entity but with some restrictions. CADHatch object that represents filling in CADImage is a 2D object. Because of this you can fill only 2D planes. For example, to fill cube you will need to create 6 CAD3DFace (or just 3D closed PolyLine) objects and fill every of them separately. If you want to fill rectangle that has vertexes on different planes, it must belong to 2D plane. CADHatch.Extrusion property specifies 3D orientation of the Hatch.

CADHatch.LineWeight specifies thickness of the hatch lines.

Alexander.
Please post questions to the forum or write to support@cadsofttools.com
support
 
Posts: 2226
Joined: 30 Mar 2005, 08:36
Location: Russia

Re: 3D entity filled

Postby Peddy » 21 Jul 2009, 10:37

tank you.
new question: i have created a Hatch e with CADHatch.Extrusion i have specified 3d orientation of the hatch, but when i save us dxf no file is created
Peddy
 
Posts: 3
Joined: 21 May 2009, 10:38

Re: 3D entity filled

Postby support » 27 Jul 2009, 12:33

Please pay attention. You need to create object that encloses your hatch. If you created such object and hatch within it and don't receive file when saving to dxf, then please post your code with your next question.

Alexander.
Please post questions to the forum or write to support@cadsofttools.com
support
 
Posts: 2226
Joined: 30 Mar 2005, 08:36
Location: Russia

Re: 3D entity filled

Postby Peddy » 03 Aug 2009, 13:56

this is the function to create hatch on line :

private void AddHatchLinea(object sender, EventArgs e)
{

if (this.cadImage == null)
{
this.cadImage = new CADImage();
this.cadImage.InitialNewImage();
this.cadImage.UseDoubleBuffering = false;
}
this.cadImage.UseDoubleBuffering = false;
int entCount = this.cadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);

for (int i = 0; i < entCount; i++)
{
if (this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i] is
CADLine)
{
CADLine entLine =
(CADLine)this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];

CADCurvePolygon Hatch = new CADCurvePolygon();

Hatch.Color = Color.Blue;

CAD2DBoundaryList Lista = new CAD2DBoundaryList();
Lista.BoundaryType = 7;// Polyline type
Hatch.BoundaryData.Add(Lista);
CAD2DPolyline Poly = new CAD2DPolyline();
Lista.Add(Poly);

CAD2DPoint ent2DPoint;
double l,h,v,cos,acos;
DPoint A,B,C;


B = (DPoint)entLine.Point;
A = (DPoint)entLine.Point1;
C.X = 0;
C.Y = 0;

acos = (Math.PI) / 2 + (Math.PI) / 4;
l = Math.Sqrt(Math.Pow(A.X - B.X,2) + Math.Pow(A.Y - B.Y,2));
h = 30;

//Primo caso
if (B.X > A.X && B.Y > A.Y)
{
cos = (B.X-A.X) / l;
acos = (Math.PI)/2 + Math.Acos(cos);
C.X = B.X;
C.Y = B.Y;
}
//Secondo caso
if (B.X > A.X && A.Y > B.Y)
{
cos = (B.X - A.X) / l;
acos = (Math.PI)/2 - Math.Acos(cos);
C.X = B.X;
C.Y = B.Y;
}
//Terzo caso
if (A.X > B.X && A.Y > B.Y)
{
cos = (A.X - B.X) / l;
acos = (Math.PI)/2 + Math.Acos(cos) + Math.PI;
C.X = B.X;
C.Y = B.Y;
}
//Quarto caso
if (A.X > B.X && B.Y > A.Y)
{
cos = (A.X - B.X) / l;
acos = (Math.PI)/2- Math.Acos(cos);
C.X = A.X;
C.Y = A.Y;
}
//Quinto caso
if (A.X == B.X && A.Y != B.Y)
{
acos = 0;
if (A.Y > B.Y)
{
C.X = B.X;
C.Y = B.Y;
}
else
{
C.X = A.X;
C.Y = A.Y;
}

}
//Sesto caso
if (A.Y == B.Y && A.X != B.X)
{
acos = (Math.PI)/2;
if (A.X > B.X)
{
C.X = A.X;
C.Y = A.Y;
}
else
{
C.X = B.X;
C.Y = B.Y;
}
}
if (A.Y == B.Y && A.X == B.X)
{
return;
}

v = Math.Sqrt(Math.Pow(Math.Cos(acos),2) + Math.Pow(Math.Sin(acos), 2));

ent2DPoint = new CAD2DPoint(0, 0);
Poly.Vertexes.Add(ent2DPoint);
ent2DPoint = new CAD2DPoint(l, 0);
Poly.Vertexes.Add(ent2DPoint);
ent2DPoint = new CAD2DPoint(l, h);
Poly.Vertexes.Add(ent2DPoint);
ent2DPoint = new CAD2DPoint(0, h);
Poly.Vertexes.Add(ent2DPoint);
ent2DPoint = new CAD2DPoint(0, 0);
Poly.Vertexes.Add(ent2DPoint);
Poly.Closed = true;

Hatch.Elevation = new DPoint((C.Y * Math.Cos(acos) - C.X * Math.Sin(acos)) * v, 0, (C.Y * Math.Sin(acos) + C.X * Math.Cos(acos)) * v);
Hatch.Extrusion = new DPoint(Math.Cos(acos), Math.Sin(acos), 0);
Hatch.Loaded(this.cadImage.Converter);
this.cadImage.CurrentLayout.Entities.Add(Hatch);
this.cadImage.Converter.OnCreate(Hatch);
}

}
CADImportFace.LoadTreeNodes(trvEntity.Nodes, cadImage);
SetCADImageOptions();
this.ResizeLayout();
}

this is the function to save us dxf :

private void miSaveAsDXF_Click(object sender, System.EventArgs e)
{
if (this.cadImage == null)
return;
if (this.saveDXFDlg.ShowDialog() != DialogResult.OK)
return;
SaveAsDXF(this.saveDXFDlg.FileName);
}

private void SaveAsDXF(string fName)
{

if(cadImage == null) return;
if(cadImage is CADRasterImage)
{
return;
}
this.cadImage.GetExtents();
this.DoResize();
CADImport.Export.DirectCADtoDXF.CADtoDXF vExp = new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadImage);
vExp.SaveToFile(fName);

}
Peddy
 
Posts: 3
Joined: 21 May 2009, 10:38

Re: 3D entity filled

Postby support » 21 Aug 2009, 10:33

Hello.
I checked saving to DXF - it works correctly.
You can try following code - it's a simple example of creating 3D oriented hatch enclosed by a circle and saving into DXF file:
Code: Select all
            if (this.cadImage == null)
            {
                this.cadImage = new CADImage();
                this.cadImage.InitialNewImage();
            }
            this.cadImage.UseDoubleBuffering = false;

            CADHatch hatch = new CADHatch();
            CAD2DBoundaryList v2DBList = new CAD2DBoundaryList();
            hatch.BoundaryData.Add(v2DBList);
            HatchPatternData vHPData;

            v2DBList.BoundaryType = 1;
            CAD2DArc vCircle = new CAD2DArc();
            vCircle.CenterPoint = new CAD2DPoint(10, 10);
            vCircle.Radius = 20;
            vCircle.StartParam = 0;
            vCircle.EndParam = 360;
            vCircle.CounterClockWise = true;
            v2DBList.Add(vCircle);

            ((CADHatch)hatch).HatchName = "USER";
            vHPData = new HatchPatternData();
            vHPData.baseP = new DPoint(0, 0, 0);
            vHPData.offset = new DPoint(1, 1, 0);
            vHPData.lineAngle = 10.0f;
            vHPData.isDash = false;
            vHPData.lines = null;
            vHPData.dashNum = 1;
            ((CADHatch)hatch).HatchPatternData.Add(vHPData);

            hatch.Color = Color.Red;
            hatch.Extrusion = new DPoint(10, 20, 15);
            hatch.Loaded(this.cadImage.Converter);
            this.AddEnt(hatch);

            this.DoResize();
            this.cadPictBox.Invalidate();

// this is saving method lightly modified for adding to creation method

            if (this.cadImage == null)
                return;
            if (this.dlgSaveDXF.ShowDialog() != DialogResult.OK)
                return;
            if (cadImage is CADRasterImage)
            {
                return;
            }
            this.cadImage.GetExtents();
            this.DoResize();
            CADImport.Export.DirectCADtoDXF.CADtoDXF vExp = new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadImage);
            vExp.SaveToFile(this.dlgSaveDXF.FileName);

Alexander.
Please post questions to the forum or write to support@cadsofttools.com
support
 
Posts: 2226
Joined: 30 Mar 2005, 08:36
Location: Russia


Return to CADImport.NET + DXFExport.NET

Who is online

Users browsing this forum: No registered users and 0 guests

cron