The arc line shifting on CADLWPolyline deep cloned
Moderators: SDS, support, admin
The arc line shifting on CADLWPolyline deep cloned
Hello
There is only one closed CADLWPolyLine with arcs in the polylineArc.dwg file.
After cloning the polyline one time, arc lines are shifted a little.
When I clone the polyline several times, the arc lines are shifted more.
I used the DeepCloneObject() method from viewtopic.php?f=15&t=10437#p22351. (I only changed the return type from void to CADEntity)
DeepCloneObject()
The polyline cloned one time.
The polyline cloned 29 times.
You can download all files(source and captured files) from the below link.
http://magzog.com/caddotnet/PolyLine_Arc_Problem.zip
Please check it.
Thank you.
There is only one closed CADLWPolyLine with arcs in the polylineArc.dwg file.
After cloning the polyline one time, arc lines are shifted a little.
When I clone the polyline several times, the arc lines are shifted more.
I used the DeepCloneObject() method from viewtopic.php?f=15&t=10437#p22351. (I only changed the return type from void to CADEntity)
Code: Select all
string dwgFile = "polylineArc.dwg";
CADImage cadImage = new CADImage();
cadImage = CADImage.CreateImageByExtension(dwgFile);
cadImage.LoadFromFile(dwgFile);
for (int i = 1; i < 30; i++)
{
CADLWPolyLine pl = (CADLWPolyLine)DeepCloneObject(cadImage, ConvSection.Entities, cadImage.Converter.Entities[0]);
pl.Vertexes.ForEach(en =>
{
(en as CADVertex).Point += new DPoint(300000 * i, 0, 0);
});
}
CADImport.Export.CADtoDWG.SaveAsDWG(cadImage, "plarc_29.dwg");
if (cadImage != null)
{
cadImage.ClearBuffer();
cadImage.Dispose();
cadImage = null;
GC.Collect();
}
DeepCloneObject()
Code: Select all
public static void CloneStyle(CADImage targetImage, ConvSection styleSection, CADEntity srcStyle)
{
if (srcStyle.EntName == "Standard")
{
if (srcStyle.GetType() == typeof(CADDimensionStyle))
{
CADDimensionStyle dimStyle = targetImage.Converter.DimensionStyleByName("Standard");
dimStyle.AssignEntity(srcStyle);
targetImage.Converter.Loads(dimStyle);
}
if (srcStyle.GetType() == typeof(CADStyle))
{
CADStyle style = targetImage.Converter.StyleByName("Standard");
style.AssignEntity(srcStyle);
targetImage.Converter.Loads(style);
}
}
else
{
DeepCloneObject(targetImage, styleSection, srcStyle);
}
}
public static CADEntity DeepCloneObject(CADImage targetImage, ConvSection targetSection, CADEntity source)
{
CADEntity clone = (CADEntity)Activator.CreateInstance(source.GetType());
clone.AssignEntity(source);
clone.ExtendedData.AddRange(source.ExtendedData);
targetImage.Converter.Loads(clone);
if (targetSection == ConvSection.Entities)
{
// Clone the source entity layer
DeepCloneObject(targetImage, ConvSection.Layers, source.Layer);
// Add the cloned entity onto a layout
targetImage.CurrentLayout.AddEntity(clone);
targetImage.GetExtents();
if (source.EntType == EntityType.Dimension)
{
CADDimension sourceDim = source as CADDimension;
// Clone the dimension block
DeepCloneObject(targetImage, ConvSection.Blocks, sourceDim.Block);
// Clone the dimension style
CloneStyle(targetImage, ConvSection.DimStyles, sourceDim.Style);
// Clone the dimension text style
CloneStyle(targetImage, ConvSection.Styles, sourceDim.TextStyle);
}
if ((source.EntType == EntityType.Text) || (source.EntType == EntityType.MText))
// Clone the text style
CloneStyle(targetImage, ConvSection.Styles, (source as CADText).Style);
}
else
{
if (source.GetType() == typeof(CADBlock))
{
// Assign the source block name to the clone
(clone as CADBlock).Name = (source as CADBlock).Name;
}
// Add the cloned non-visible object to a corresponding section of the target drawing
targetImage.Converter.GetSection(targetSection).AddEntity(clone);
}
return clone;
}
The polyline cloned one time.
The polyline cloned 29 times.
You can download all files(source and captured files) from the below link.
http://magzog.com/caddotnet/PolyLine_Arc_Problem.zip
Please check it.
Thank you.
- Attachments
-
- result_loop_29times_AUTOCAD2007.PNG (34.66 KiB) Viewed 2899 times
Re: The arc line shifting on CADLWPolyline deep cloned
Oh... I found what the problem was...
One of my company colleagues informed me that I could type the command "REGEN" in AutoCAD.
So now I know that it is not a problem exactly.
However, is there a way to show the correct design without the command 'REGEN' when opening the .dwg file?
One of my company colleagues informed me that I could type the command "REGEN" in AutoCAD.
So now I know that it is not a problem exactly.
However, is there a way to show the correct design without the command 'REGEN' when opening the .dwg file?