Converting dwg to directx using C#
Moderators: SDS, support, admin
Re: Converting dwg to directx using C#
Hello Chris,
We have received your e-mails. We'll keep you informed.
Sergey.
We have received your e-mails. We'll keep you informed.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Converting dwg to directx using C#
Again, Thank you Sergey,
One note on the Arc class I think I forgot to mention.
Only specify a number of sides for Polygons. For the Arc, Circle, and Ellipse, the sides can be set to 0(zero) and the engine will optimize the correct number of sides to use.
~Chris
One note on the Arc class I think I forgot to mention.
Only specify a number of sides for Polygons. For the Arc, Circle, and Ellipse, the sides can be set to 0(zero) and the engine will optimize the correct number of sides to use.
~Chris
Re: Converting dwg to directx using C#
Hello!
Sergey.
We tested your file and found no arcs with Extrusion = -34.Cab you please send us example file for testing to support@cadsofttols.com? If possible, please make it clear of other, superfluous entities.I have seen values such as 1, -1, -34; I would assume the -34 would mean something different from -1?
Accordingly to the Extrusion question for Arcs, Circles and Ellipses we recommend to use methods DottedSingPts or PolyPoints. They return CADImport.CADDPointCollection objects which are lists of points that form a shape of the entity. DottedSingPts contains points which take into account line type of the entity.One note on the Arc class I think I forgot to mention.
Only specify a number of sides for Polygons. For the Arc, Circle, and Ellipse, the sides can be set to 0(zero) and the engine will optimize the correct number of sides to use.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Converting dwg to directx using C#
Thank you Sergey,
This method works fine for getting past our immediate deadline needs. I would like to continue working on a method of having these entity types converted into proper FVV_Arc format as soon as possible.
~Chris
This method works fine for getting past our immediate deadline needs. I would like to continue working on a method of having these entity types converted into proper FVV_Arc format as soon as possible.
~Chris
Re: Converting dwg to directx using C#
Hi Chris,
The reason why we recommend to use DottedSingPts or PolyPoints lists is that Extrusion may have non-standard values - (0.577, 0.577, 0.577). In such cases addind constant values to angles may give nothing.
Sergey.
The reason why we recommend to use DottedSingPts or PolyPoints lists is that Extrusion may have non-standard values - (0.577, 0.577, 0.577). In such cases addind constant values to angles may give nothing.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Converting dwg to directx using C#
Sergey,
If there is a way to isolate which Arc, Circles, and Ellipse can be translated properly from those that can not, then I could at least get a conversion on those cases. Is it safe to say that if the extrusions are not 1.0, then use the point list fallback method? That way I still have a 100% conversion accuracy appearance, and the majority of the entities are in the proper format. Once this isolation is fully understood, we can start knocking down the exceptions one by one until everything is lined up.
I have a number of powerful tools designed around the FVV_Arc format that can not be used on what is essentially a polyline.
I would like to take this time to also say that I am very happy with your conversion tools speed and performance.
~Chris
If there is a way to isolate which Arc, Circles, and Ellipse can be translated properly from those that can not, then I could at least get a conversion on those cases. Is it safe to say that if the extrusions are not 1.0, then use the point list fallback method? That way I still have a 100% conversion accuracy appearance, and the majority of the entities are in the proper format. Once this isolation is fully understood, we can start knocking down the exceptions one by one until everything is lined up.
I have a number of powerful tools designed around the FVV_Arc format that can not be used on what is essentially a polyline.
I would like to take this time to also say that I am very happy with your conversion tools speed and performance.
~Chris
Re: Converting dwg to directx using C#
Hello Chris,
Let's start from the very beginning. Can you please specify what exactly data you need to receive for Arc, Circle and Ellipse?
Sergey.
Let's start from the very beginning. Can you please specify what exactly data you need to receive for Arc, Circle and Ellipse?
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Converting dwg to directx using C#
Sergey,
Arc, Circle, Ellipse, and Polygons can all be solved when the following variables are set.
CenterPoint (x,y,z)
Radius == XAxisLength (all arc are generated on this axis, and then rotated afterwards)
Ratio == YAxisLength/XAxisLength
StartAngle(radians) == must be < StopAngle
StopAngle(radians) == must be > StartAngle
Sides(int) == 0(automatic) or >= 3(exact)
Rotation == All angles are based off of 0 == +X CCW, the rotation is applied after all other calculations.
Height == Z thickness of the lines
Width == 2D line width
Inherit(bool) == use groups color?
Diffuse(int32) == use this color if !Inherit (only set if needed)
Most of the entities are drawn exactly. Those in Error seem to occur with reflected/mirrored entities.
I can expand on the shorthand if needed, Thanks Sergey.
~Chris
Arc, Circle, Ellipse, and Polygons can all be solved when the following variables are set.
CenterPoint (x,y,z)
Radius == XAxisLength (all arc are generated on this axis, and then rotated afterwards)
Ratio == YAxisLength/XAxisLength
StartAngle(radians) == must be < StopAngle
StopAngle(radians) == must be > StartAngle
Sides(int) == 0(automatic) or >= 3(exact)
Rotation == All angles are based off of 0 == +X CCW, the rotation is applied after all other calculations.
Height == Z thickness of the lines
Width == 2D line width
Inherit(bool) == use groups color?
Diffuse(int32) == use this color if !Inherit (only set if needed)
Most of the entities are drawn exactly. Those in Error seem to occur with reflected/mirrored entities.
I can expand on the shorthand if needed, Thanks Sergey.
~Chris
Re: Converting dwg to directx using C#
CADCircle:
CenterPoint - CADCircle.Point (Center point (in OCS))
Radius - CADCircle.Radius
Extrusion - CADCircle.Extrusion (Extrusion direction (optional; default = 0, 0, 1))
CADCircle.LineWeight - Width == 2D line width
CADCircle.Pen.ZThick - Height == Z thickness of the lines - has no such parameter
CADArc (circle arc):
CenterPoint - CADArc.Point (Center point (in OCS))
Radius - CADArc.Radius
StartAngle - CADArc.StartAngle (Start angle)
EndAngle - CADArc.EndAngle (End angle)
Extrusion - CADArc.Extrusion (Extrusion direction (optional; default = 0, 0, 1))
CADArc.LineWeight - Width == 2D line width
CADArc.Pen.ZThick - Height == Z thickness of the lines - has no such parameter
CADEllipse (or elliptic arc):
CenterPoint - CADEllipse.Point (Center point (in OCS))
Radius - CADEllipse.Radius (major axis)
StartAngle - CADEllipse.StartAngle (Start parameter (this value is 0.0 for a full ellipse))
EndAngle - CADEllipse.EndAngle (End parameter (this value is 2pi for a full ellipse))
Ratio - CADEllipse.Ratio of minor axis to major axis
Extrusion - CADEllipse.Extrusion (Extrusion direction (optional; default = 0, 0, 1))
CADEllipse.LineWeight - Width == 2D line width
CADEllipse.Pen.ZThick - Height == Z thickness of the lines - has no such parameter
Polygon - CADLWPolyLine:
CADLWPolyLine.Entities - list of vertexes
CADLWPolyLine.Count - number of vertexes
Sides(int) == 0(automatic) or >= 3(exact) - if CADLWPolyLine.Closed is true the Sides is CADLWPolyLine.Count
CADLWPolyLine.LineWeight - Width == 2D line width
CADLWPolyLine.Pen.ZThick - Height == Z thickness of the lines
Sergey.
CenterPoint - CADCircle.Point (Center point (in OCS))
Radius - CADCircle.Radius
Extrusion - CADCircle.Extrusion (Extrusion direction (optional; default = 0, 0, 1))
CADCircle.LineWeight - Width == 2D line width
CADCircle.Pen.ZThick - Height == Z thickness of the lines - has no such parameter
CADArc (circle arc):
CenterPoint - CADArc.Point (Center point (in OCS))
Radius - CADArc.Radius
StartAngle - CADArc.StartAngle (Start angle)
EndAngle - CADArc.EndAngle (End angle)
Extrusion - CADArc.Extrusion (Extrusion direction (optional; default = 0, 0, 1))
CADArc.LineWeight - Width == 2D line width
CADArc.Pen.ZThick - Height == Z thickness of the lines - has no such parameter
CADEllipse (or elliptic arc):
CenterPoint - CADEllipse.Point (Center point (in OCS))
Radius - CADEllipse.Radius (major axis)
StartAngle - CADEllipse.StartAngle (Start parameter (this value is 0.0 for a full ellipse))
EndAngle - CADEllipse.EndAngle (End parameter (this value is 2pi for a full ellipse))
Ratio - CADEllipse.Ratio of minor axis to major axis
Extrusion - CADEllipse.Extrusion (Extrusion direction (optional; default = 0, 0, 1))
CADEllipse.LineWeight - Width == 2D line width
CADEllipse.Pen.ZThick - Height == Z thickness of the lines - has no such parameter
Polygon - CADLWPolyLine:
CADLWPolyLine.Entities - list of vertexes
CADLWPolyLine.Count - number of vertexes
Sides(int) == 0(automatic) or >= 3(exact) - if CADLWPolyLine.Closed is true the Sides is CADLWPolyLine.Count
CADLWPolyLine.LineWeight - Width == 2D line width
CADLWPolyLine.Pen.ZThick - Height == Z thickness of the lines
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Converting dwg to directx using C#
I have attempted to isolate the cadParams.xScale value in order to verify that it has no effect.support wrote:xScale - Represents a text width scalingEDIT: cadParams.xScale and cadParams.yScale ... are these already accounted for in the position data? the radius data? is it just parenthetical information or do I need to apply this in some fashion?
yScale - Represents a text height scaling
Sergey.
Only arc objects that have 0,0,1 Extrusion, 1 yscale, and (1 OR -1 xscale) are drawn using the FVV_Arc method.
everything with an xscale of -1 appears to be reflected through the origin. The value is not calculated by myself in any way, just observed.
I appologize but I must ask, are you sure these values only affect text?

EDIT: I applied a reflection over the Y-Axis whenever xscale = -1. It ends up fixing some of them, but it also breaks others.

Re: Converting dwg to directx using C#
Hello Chris,
Can you please send us your file for testing to support@cadsofttools.com?
Also we need to know what exactly parameters you pass in to the FVV_Arc method.
Sergey.
Can you please send us your file for testing to support@cadsofttools.com?
Also we need to know what exactly parameters you pass in to the FVV_Arc method.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Converting dwg to directx using C#
Sergey,
the code for reflecting over the Y axis when xScale = -1 is in quotes. The logic statement does not pass -1 values to the 'proper' code sections, but when you do, you get the second image resulting above. If you removed the reflection code and still allow -1 to be passed, then you get the first image above.
with this code exactly, it translates the majority of the files into proper format and correctly draws everything. the issue is that the CatchAll method does not allow the end user to use the huge library of arc tools I have built, nor does it optimize its rendering, and it can be confusing when two visual arcs sitting side by side are handled differently; One as an Arc object, and the other as a series of lines.
The more entities that can be moved out of the CatchAll method the better. Something somewhere, some combination of things, says that the value should be reflected over the Y-axis. It is not the xScale -1 value, and I have had no luck figuring it out.
The CAD file is the same I sent you before in Email. These images are from the second floor bathrooms, which are identical to the first floor bathrooms. Filename: GenericSource.dwg
Thanks,
~Chris
Code: Select all
private void ImportEllipse(CADEllipse sender)
{
DPoint p;
if (sender.Extrusion.X != 0 || sender.Extrusion.Y != 0 || sender.Extrusion.Z != 1 || cadParams.xScale != 1 || cadParams.yScale != 1)
{
#region CatchAll
for (int i = 0; i < sender.DottedSingPts.Count - 1; i += 8)
{
FVV.FVV_Line TempLine = new FVV.FVV_Line();
p = cadParams.matrix.PtXMat(sender.DottedSingPts[i]);
//textFile.Add(string.Format("P{0}: X = {1} Y = {2} Z = {3}", i + 1, p.X, p.Y, p.Z));
TempLine.FVV_point_one = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
if (sender.DottedSingPts.Count - 1 > i + 8)
{
p = cadParams.matrix.PtXMat(sender.DottedSingPts[i + 8]);
TempLine.FVV_point_two = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
}
else
{
p = cadParams.matrix.PtXMat(sender.DottedSingPts[sender.DottedSingPts.Count - 1]);
TempLine.FVV_point_two = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
}
TempLine.Base.FVV_GroupID = LayerDefaultGroupID;
TempLine.Base.MyLayersIndex = LayerIndex;
TempLine.Base.MyGroupsIndex = GroupIndex;
TempLine.Base.FVV_Inherit = true;
TempFVVLines.Add(TempLine);
FVV_Lines_ID.Add(2);
TempFlags.CountPolyLines += 1;
TempFVVGroups[GroupIndex].FootPrint += 1;
TempFVVLayers[LayerIndex].FootPrint += 1;
}
if (sender.Closed)
{
FVV.FVV_Line TempLine = new FVV.FVV_Line();
p = cadParams.matrix.PtXMat(sender.DottedSingPts[0]);
//textFile.Add(string.Format("P{0}: X = {1} Y = {2} Z = {3}", i + 1, p.X, p.Y, p.Z));
TempLine.FVV_point_one = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
p = cadParams.matrix.PtXMat(sender.DottedSingPts[sender.DottedSingPts.Count - 1]);
TempLine.FVV_point_two = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
TempLine.Base.FVV_GroupID = LayerDefaultGroupID;
TempLine.Base.MyLayersIndex = LayerIndex;
TempLine.Base.MyGroupsIndex = GroupIndex;
TempLine.Base.FVV_Inherit = true;
TempFVVLines.Add(TempLine);
FVV_Lines_ID.Add(2);
TempFlags.CountPolyLines += 1;
TempFVVGroups[GroupIndex].FootPrint += 1;
TempFVVLayers[LayerIndex].FootPrint += 1;
}
#endregion CatchAll
}
else // proper ellipse
{
if (sender.StartAngle == 360)
sender.StartAngle = 0;
if (sender.EndAngle == 0)
sender.EndAngle = 360;
if (sender.StartAngle > sender.EndAngle)
sender.EndAngle += 360.0;
[quote] if (cadParams.xScale == -1)
{
double Swap = sender.StartAngle;
sender.StartAngle = 360.0 - sender.EndAngle;
sender.EndAngle = 360.0 - Swap;
}[/quote]
FVV.FVV_Arc TempArc = new FVV.FVV_Arc();
p = cadParams.matrix.PtXMat(sender.Point);
//textFile.Add(string.Format("Center of Ellipse: X = {0} Y = {1} Z = {2}", p.X, p.Y, p.Z));
TempArc.FVV_Center_Point = new DX.Vector3((float)p.X, (float)p.Y, (float)p.Z);
//textFile.Add(string.Format("Start Angle: {0}", sender.StartAngle));
TempArc.FVV_Start_Angle = (float)(sender.StartAngle * 0.0174532925);
//textFile.Add(string.Format("End Angle: {0}", sender.EndAngle));
TempArc.FVV_Stop_Angle = (float)(sender.EndAngle * 0.0174532925);
//textFile.Add(string.Format("Rx: {0}", sender.Radius));
TempArc.FVV_Radius = (float)sender.Radius;
//textFile.Add(string.Format("Ry: {0}", sender.Radius * sender.Ratio));
TempArc.FVV_Ratio = (float)sender.Ratio;
TempArc.FVV_Rotation = (float)sender.Angle;
if (TempArc.FVV_Rotation < 0.0f) // positive coterminals
{
TempArc.FVV_Rotation += (float)(Math.PI * 2.0);
}
TempArc.Base.FVV_GroupID = LayerDefaultGroupID;
TempArc.Base.MyLayersIndex = LayerIndex;
TempArc.Base.MyGroupsIndex = GroupIndex;
TempArc.Base.FVV_Inherit = true;
TempFVVArc.Add(TempArc);
FVV_Arcs_ID.Add(3);
TempFlags.CountEllipse += 24;
TempFVVGroups[GroupIndex].FootPrint += 24;
TempFVVLayers[LayerIndex].FootPrint += 24;
}
}
Code: Select all
private void ImportArc(CADArc sender)
{
DPoint p;
if (sender.Extrusion.X != 0 || sender.Extrusion.Y != 0 || sender.Extrusion.Z != 1 || cadParams.xScale != 1 || cadParams.yScale != 1)
{
#region CatchAll
//textFile.Add("Points of PolyLine: ");
for (int i = 0; i < sender.DottedSingPts.Count - 1; i += 4)
{
FVV.FVV_Line TempLine = new FVV.FVV_Line();
p = cadParams.matrix.PtXMat(sender.DottedSingPts[i]);
//textFile.Add(string.Format("P{0}: X = {1} Y = {2} Z = {3}", i + 1, p.X, p.Y, p.Z));
TempLine.FVV_point_one = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
if (sender.DottedSingPts.Count - 1 > i + 4)
{
p = cadParams.matrix.PtXMat(sender.DottedSingPts[i + 4]);
TempLine.FVV_point_two = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
}
else
{
p = cadParams.matrix.PtXMat(sender.DottedSingPts[sender.DottedSingPts.Count - 1]);
TempLine.FVV_point_two = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
}
TempLine.Base.FVV_GroupID = LayerDefaultGroupID;
TempLine.Base.MyLayersIndex = LayerIndex;
TempLine.Base.MyGroupsIndex = GroupIndex;
TempLine.Base.FVV_Inherit = true;
TempFVVLines.Add(TempLine);
FVV_Lines_ID.Add(2);
TempFlags.CountPolyLines += 1;
TempFVVGroups[GroupIndex].FootPrint += 1;
TempFVVLayers[LayerIndex].FootPrint += 1;
}
if (sender.Closed)
{
FVV.FVV_Line TempLine = new FVV.FVV_Line();
p = cadParams.matrix.PtXMat(sender.DottedSingPts[0]);
//textFile.Add(string.Format("P{0}: X = {1} Y = {2} Z = {3}", i + 1, p.X, p.Y, p.Z));
TempLine.FVV_point_one = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
p = cadParams.matrix.PtXMat(sender.DottedSingPts[sender.DottedSingPts.Count - 1]);
TempLine.FVV_point_two = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
TempLine.Base.FVV_GroupID = LayerDefaultGroupID;
TempLine.Base.MyLayersIndex = LayerIndex;
TempLine.Base.MyGroupsIndex = GroupIndex;
TempLine.Base.FVV_Inherit = true;
TempFVVLines.Add(TempLine);
FVV_Lines_ID.Add(2);
TempFlags.CountPolyLines += 1;
TempFVVGroups[GroupIndex].FootPrint += 1;
TempFVVLayers[LayerIndex].FootPrint += 1;
}
#endregion CatchAll
}
else // proper arc
{
if (sender.StartAngle == 360.0)
sender.StartAngle = 0;
if (sender.EndAngle == 0)
sender.EndAngle = 360.0;
if (sender.StartAngle > sender.EndAngle)
sender.EndAngle += 360.0;
[quote] if (cadParams.xScale == -1)
{
double Swap = sender.StartAngle;
sender.StartAngle = 360.0 - sender.EndAngle;
sender.EndAngle = 360.0 - Swap;
}[/quote]
FVV.FVV_Arc TempArc = new FVV.FVV_Arc();
p = cadParams.matrix.PtXMat(sender.Point);
//textFile.Add(string.Format("Center of RoundArc: X = {0} Y = {1} Z = {2}", p.X, p.Y, p.Z));
TempArc.FVV_Center_Point = new DX.Vector3((float)p.X, (float)p.Y, (float)p.Z);
//textFile.Add(string.Format("Start Angle: {0}", sender.StartAngle));
TempArc.FVV_Start_Angle = (float)(sender.StartAngle * 0.0174532925);
//textFile.Add(string.Format("End Angle: {0}", sender.EndAngle));
TempArc.FVV_Stop_Angle = (float)(sender.EndAngle * 0.0174532925);
//textFile.Add(string.Format("Rx: {0}", sender.Radius));
TempArc.FVV_Radius = (float)sender.Radius;
TempArc.FVV_Ratio = 1.0f;
TempArc.FVV_Rotation = (float)((cadParams.angle) * 0.0174532925);
if (TempArc.FVV_Rotation < 0.0) // positive coterminals
TempArc.FVV_Rotation += (float)(Math.PI * 2.0);
TempArc.Base.FVV_GroupID = LayerDefaultGroupID;
TempArc.Base.MyLayersIndex = LayerIndex;
TempArc.Base.MyGroupsIndex = GroupIndex;
TempArc.Base.FVV_Inherit = true;
TempFVVArc.Add(TempArc);
FVV_Arcs_ID.Add(1);
TempFlags.CountArc += 8;
TempFVVGroups[GroupIndex].FootPrint += 8;
TempFVVLayers[LayerIndex].FootPrint += 8;
}
}
Code: Select all
private void ImportCircle(CADCircle sender)
{
DPoint p;
if (sender.Extrusion.X != 0 || sender.Extrusion.Y != 0 || sender.Extrusion.Z != 1 || cadParams.xScale != 1 || cadParams.yScale != 1)
{
#region CatchAll
//textFile.Add("Points of PolyLine: ");
for (int i = 0; i < sender.DottedSingPts.Count - 1; i += 8)
{
FVV.FVV_Line TempLine = new FVV.FVV_Line();
p = cadParams.matrix.PtXMat(sender.DottedSingPts[i]);
//textFile.Add(string.Format("P{0}: X = {1} Y = {2} Z = {3}", i + 1, p.X, p.Y, p.Z));
TempLine.FVV_point_one = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
if (sender.DottedSingPts.Count - 1 > i + 8)
{
p = cadParams.matrix.PtXMat(sender.DottedSingPts[i + 8]);
TempLine.FVV_point_two = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
}
else
{
p = cadParams.matrix.PtXMat(sender.DottedSingPts[sender.DottedSingPts.Count - 1]);
TempLine.FVV_point_two = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
}
TempLine.Base.FVV_GroupID = LayerDefaultGroupID;
TempLine.Base.MyLayersIndex = LayerIndex;
TempLine.Base.MyGroupsIndex = GroupIndex;
TempLine.Base.FVV_Inherit = true;
TempFVVLines.Add(TempLine);
FVV_Lines_ID.Add(2);
TempFlags.CountPolyLines += 1;
TempFVVGroups[GroupIndex].FootPrint += 1;
TempFVVLayers[LayerIndex].FootPrint += 1;
}
if (sender.Closed)
{
FVV.FVV_Line TempLine = new FVV.FVV_Line();
p = cadParams.matrix.PtXMat(sender.DottedSingPts[0]);
//textFile.Add(string.Format("P{0}: X = {1} Y = {2} Z = {3}", i + 1, p.X, p.Y, p.Z));
TempLine.FVV_point_one = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
p = cadParams.matrix.PtXMat(sender.DottedSingPts[sender.DottedSingPts.Count - 1]);
TempLine.FVV_point_two = new DX.Vector3((float)p.X, (float)p.Y, -(float)p.Z);
TempLine.Base.FVV_GroupID = LayerDefaultGroupID;
TempLine.Base.MyLayersIndex = LayerIndex;
TempLine.Base.MyGroupsIndex = GroupIndex;
TempLine.Base.FVV_Inherit = true;
TempFVVLines.Add(TempLine);
FVV_Lines_ID.Add(2);
TempFlags.CountPolyLines += 1;
TempFVVGroups[GroupIndex].FootPrint += 1;
TempFVVLayers[LayerIndex].FootPrint += 1;
}
#endregion CatchAll
}
else // proper circle
{
[quote] if (cadParams.xScale == -1)
{
// should not matter, it's a circle
}[/quote]
FVV.FVV_Arc TempArc = new FVV.FVV_Arc();
p = cadParams.matrix.PtXMat(sender.Point);
//textFile.Add(string.Format("Center of Circle: X = {0} Y = {1} Z = {2}", p.X, p.Y, p.Z));
TempArc.FVV_Center_Point = new DX.Vector3((float)p.X, (float)p.Y, (float)p.Z);
//textFile.Add(string.Format("Rx: {0}", sender.Radius));
TempArc.FVV_Radius = (float)sender.Radius;
TempArc.FVV_Ratio = 1.0f;
TempArc.Base.FVV_GroupID = LayerDefaultGroupID;
TempArc.Base.MyLayersIndex = LayerIndex;
TempArc.Base.MyGroupsIndex = GroupIndex;
TempArc.Base.FVV_Inherit = true;
TempFVVArc.Add(TempArc);
FVV_Arcs_ID.Add(2);
TempFlags.CountCircle += 24;
TempFVVGroups[GroupIndex].FootPrint += 24;
TempFVVLayers[LayerIndex].FootPrint += 24;
}
}
the code for reflecting over the Y axis when xScale = -1 is in quotes. The logic statement does not pass -1 values to the 'proper' code sections, but when you do, you get the second image resulting above. If you removed the reflection code and still allow -1 to be passed, then you get the first image above.
with this code exactly, it translates the majority of the files into proper format and correctly draws everything. the issue is that the CatchAll method does not allow the end user to use the huge library of arc tools I have built, nor does it optimize its rendering, and it can be confusing when two visual arcs sitting side by side are handled differently; One as an Arc object, and the other as a series of lines.
The more entities that can be moved out of the CatchAll method the better. Something somewhere, some combination of things, says that the value should be reflected over the Y-axis. It is not the xScale -1 value, and I have had no luck figuring it out.
The CAD file is the same I sent you before in Email. These images are from the second floor bathrooms, which are identical to the first floor bathrooms. Filename: GenericSource.dwg
Thanks,
~Chris
Re: Converting dwg to directx using C#
Hello Chris,
- As we can see you don't use RadPt parameter. RadPt gets an initial end point of the major axis relative to the ellipse center point.
- It is forbidden to change anyhow cadParams. It must be used only as incoming data.
- When using DottedSingPts it is unnecessary to use any additional transformations. DottedSingPts list contains already prepared points accordingly to a place of ellipse (arc or elliptic ars) in CAD 3D space.
- If you need to make additional rotations for DirectX space, it is necessary to use addtional transformation matrix to convert every point of DottedSingPts.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Converting dwg to directx using C#
I assumed that RadPt was already accounted for in the CADParams Angle, or some other angle such as start and end. I can make a quick sin evaluation of the RadPt angle to determine if it should be an X or Y major axis and abstract the correct 3D math values from there for conversion. For reference, all of my arc are based on the +X axis. A major Y axis is purely a major X axis calculation rotated 1/2 Pi.
I am not changing the CADParams. If they have no affect or overloaded impact on the object data provided per entity, then I would rather ignore them all together. What I do know is that when they are not the default values, the entities data is no longer accurate in an unknown quantity of reasons. I do get perfect conversions with the default values. Without these perfect values, I see entities that should have been reflected over the Y axis to correct their errors.
The DottedSinglePts transformations I have applied are to convert from the CAD coordinate system to my DirectX coordinate system, I have no issues with drawing the lines using the DottedSinglePts method. You would notice the same transformations applied to all of the other entity objects during conversion if I had included that code.
Their are a number of reasons why the Arc tools are so powerful. When an entity is put into 3D, it has 6 sides per line which is essentially 12 triangles. When there are hundreds of thousands of entities in 3D space, there is not enough recursive logic time to evaluate the positional relationships of these lines with each other. However when you can predict that a specific relationship will exist between segments of lines, you can optimize them in a number of ways that reduce the overall demands on the system. In the case of Arc, the Rendering engine can operate under the understanding that all of the segments within this logic pass will effectively cover their endcaps, and thus the endcaps of the 3D line are no longer needed. These endcaps account for 4 of the 12 triangles which results in a 33% performance increase. The calculations required to perfectly match up both ends of a line segment in 3D space takes roughly 25 moderate calculations each. These 25 calculations multiplied by a half million entities will essentially cripple modern day processors. However an amount of fuzzy logic can be applied to replace these calculations for considerably more speed. This fuzzy logic requires an understanding of how much deflection occurs between subsequent entity segments so that it can approximate the linear shift required to match up with the previous and following segments. That is just an introduction to the iceberg of techniques I use. The second you take the Arc away and replace it with DottedSinglePts, it can no longer dynamically adjust for the optimum number of sides needed to simulate the Arc shape per zoom level, nor gain the effeciency derived by optimizing the sequence of segments. It is the difference between 200,000 entites and 400,000 entities being displayed at the same time on the exact same computer system in real time 3D, not to mention the consistancy for the user between interacting with objects created with my editor versus the objects imported via CAD.
I will look into this RadPt parameter and report back with my findings as time permits.
Thanks,
~Chris
I am not changing the CADParams. If they have no affect or overloaded impact on the object data provided per entity, then I would rather ignore them all together. What I do know is that when they are not the default values, the entities data is no longer accurate in an unknown quantity of reasons. I do get perfect conversions with the default values. Without these perfect values, I see entities that should have been reflected over the Y axis to correct their errors.
The DottedSinglePts transformations I have applied are to convert from the CAD coordinate system to my DirectX coordinate system, I have no issues with drawing the lines using the DottedSinglePts method. You would notice the same transformations applied to all of the other entity objects during conversion if I had included that code.
Their are a number of reasons why the Arc tools are so powerful. When an entity is put into 3D, it has 6 sides per line which is essentially 12 triangles. When there are hundreds of thousands of entities in 3D space, there is not enough recursive logic time to evaluate the positional relationships of these lines with each other. However when you can predict that a specific relationship will exist between segments of lines, you can optimize them in a number of ways that reduce the overall demands on the system. In the case of Arc, the Rendering engine can operate under the understanding that all of the segments within this logic pass will effectively cover their endcaps, and thus the endcaps of the 3D line are no longer needed. These endcaps account for 4 of the 12 triangles which results in a 33% performance increase. The calculations required to perfectly match up both ends of a line segment in 3D space takes roughly 25 moderate calculations each. These 25 calculations multiplied by a half million entities will essentially cripple modern day processors. However an amount of fuzzy logic can be applied to replace these calculations for considerably more speed. This fuzzy logic requires an understanding of how much deflection occurs between subsequent entity segments so that it can approximate the linear shift required to match up with the previous and following segments. That is just an introduction to the iceberg of techniques I use. The second you take the Arc away and replace it with DottedSinglePts, it can no longer dynamically adjust for the optimum number of sides needed to simulate the Arc shape per zoom level, nor gain the effeciency derived by optimizing the sequence of segments. It is the difference between 200,000 entites and 400,000 entities being displayed at the same time on the exact same computer system in real time 3D, not to mention the consistancy for the user between interacting with objects created with my editor versus the objects imported via CAD.
I will look into this RadPt parameter and report back with my findings as time permits.
Thanks,
~Chris
Re: Converting dwg to directx using C#
Sergey,
In the following code, I am applying a Y axis conversion when sender.Extrusion.Z < 0, and applying a X axis conversion when cadParams.xscale < 0.
This is getting me for what I can tell, a 100% conversion of all CADArc where cadParams.xScale = 1 or -1.
when xScale and yScale are other values, it appears that the OCS is affected by some order of magnitude. The Arc segments are essentially shifted. I will continue working on that.
Below is a screenshot of this successful conversion as well as the code snippet required to convert CADArc into my FVV_Arc format. This is coming together very nicely.

Note: I have to apply the X-axis reflection after pulling values from your dll, and the Y-axis reflection before pulling values from your dll. It appears that there is some sort of internal recursive logic that negates an X-axis reflection in 'some' conditions, which is what resulted in unpredictable behavior.
Thanks,
~Chris
In the following code, I am applying a Y axis conversion when sender.Extrusion.Z < 0, and applying a X axis conversion when cadParams.xscale < 0.
This is getting me for what I can tell, a 100% conversion of all CADArc where cadParams.xScale = 1 or -1.
when xScale and yScale are other values, it appears that the OCS is affected by some order of magnitude. The Arc segments are essentially shifted. I will continue working on that.
Below is a screenshot of this successful conversion as well as the code snippet required to convert CADArc into my FVV_Arc format. This is coming together very nicely.

Code: Select all
private void ImportArc(CADArc sender)
{
DPoint p;
if (cadParams.xScale != 1 && cadParams.xScale != -1)
{
}
else // proper arc
{
if (sender.Extrusion.Z < 0) // reflect over the Y axis
{
// reflect center point
sender.Point = new DPoint(-sender.Point.X, sender.Point.Y, sender.Point.Z);
// reflect angles
double Swap = sender.StartAngle;
sender.StartAngle = 180 - sender.EndAngle;
sender.EndAngle = 180 - Swap;
// positive coterminals
if (sender.StartAngle < 0.0)
sender.StartAngle += 360.0;
if (sender.EndAngle < 0.0)
sender.EndAngle += 360.0;
}
// start angle should come before end angle
if (sender.StartAngle == 360.0)
sender.StartAngle = 0;
if (sender.EndAngle == 0)
sender.EndAngle = 360.0;
if (sender.StartAngle > sender.EndAngle)
sender.EndAngle += 360.0;
FVV.FVV_Arc TempArc = new FVV.FVV_Arc();
// convert OCS to WCS
p = cadParams.matrix.PtXMat(sender.Point);
TempArc.FVV_Center_Point = new DX.Vector3((float)p.X, (float)p.Y, 0);
TempArc.Base.FVV_height = 0;
if (cadParams.xScale < 0) // reflect over the X axis and reverse their order.
{
TempArc.FVV_Start_Angle = (float)((360 - sender.EndAngle) * 0.0174532925);
TempArc.FVV_Stop_Angle = (float)((360 - sender.StartAngle) * 0.0174532925);
}
else
{
TempArc.FVV_Start_Angle = (float)(sender.StartAngle * 0.0174532925);
TempArc.FVV_Stop_Angle = (float)(sender.EndAngle * 0.0174532925);
}
TempArc.FVV_Radius = (float)sender.Radius;
TempArc.FVV_Ratio = 1.0f;
TempArc.FVV_Rotation = (float)((cadParams.angle) * 0.0174532925);
if (TempArc.FVV_Rotation < 0.0) // positive coterminals
TempArc.FVV_Rotation += (float)(Math.PI * 2.0);
TempArc.Base.FVV_GroupID = LayerDefaultGroupID;
TempArc.Base.MyLayersIndex = LayerIndex;
TempArc.Base.MyGroupsIndex = GroupIndex;
TempArc.Base.FVV_Inherit = true;
TempFVVArc.Add(TempArc);
FVV_Arcs_ID.Add(1);
TempFlags.CountArc += 8;
TempFVVGroups[GroupIndex].FootPrint += 8;
TempFVVLayers[LayerIndex].FootPrint += 8;
}
}
Thanks,
~Chris