نقل نقطة أصل الفتحة أقرب إلى حدود الفتحة لتحسين الأداء
Contents
[
Hide
]كيفية نقل نقطة أصل الفتحة أقرب إلى حدود الفتحة لتحسين الأداء
المشكلة: كيفية نقل نقطة أصل الفتحة أقرب إلى حدود الفتحة لتحسين الأداء (CADNET-1340).
نصائح: للقيام بذلك، احصل على كائنات CadHatch من الرسم، قم بتعيين النقاط المطلوبة باستخدام Point2D، حساب المسافة وفي CadHatchPatternData قم بتعيين LineBasePoint لـ X و Y.
مثال:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (CadBaseEntity entity in cadImage.Entities) | |
{ | |
if (entity.TypeName == CadEntityTypeName.HATCH) | |
{ | |
CadHatch hatch = (CadHatch)entity; | |
if (hatch.PatternDefinitions.Count > 0) | |
{ | |
Point2D firstPoint = new Point2D(hatch.PatternDefinitions[0].LineBasePoint.X, hatch.PatternDefinitions[0].LineBasePoint.Y); | |
if (hatch.BoundaryPaths[0].BoundaryPath[0].GetType() == typeof(CadPolylineBoundaryPath)) | |
{ | |
CadPolylineBoundaryPath polyline = (CadPolylineBoundaryPath)(hatch.BoundaryPaths[0].BoundaryPath[0]); | |
firstPoint = polyline.Vertices[0]; | |
} | |
else | |
{ | |
CadEdgeBoundaryPath edgePath = (CadEdgeBoundaryPath)(hatch.BoundaryPaths[0].BoundaryPath[0]); | |
if (edgePath.Objects[0].GetType() == typeof(CadBoundaryPathLine)) | |
{ | |
CadBoundaryPathLine line = (CadBoundaryPathLine)edgePath.Objects[0]; | |
firstPoint = line.FirstPoint; | |
} | |
if (edgePath.Objects[0].GetType() == typeof(CadBoundaryPathCircularArc)) | |
{ | |
// TODO | |
} | |
if (edgePath.Objects[0].GetType() == typeof(CadBoundaryPathCircularEllipse)) | |
{ | |
// TODO | |
} | |
if (edgePath.Objects[0].GetType() == typeof(CadBoundaryPathSpline)) | |
{ | |
// TODO | |
} | |
} | |
bool requiresShift = false; | |
double distanceX = 0, distanceY = 0; | |
if (Math.Abs(hatch.PatternDefinitions[0].LineBasePoint.X - firstPoint.X) > 20000 | |
|| Math.Abs(hatch.PatternDefinitions[0].LineBasePoint.Y - firstPoint.Y) > 20000) | |
{ | |
requiresShift = true; | |
distanceX = hatch.PatternDefinitions[0].LineBasePoint.X - firstPoint.X; | |
distanceY = hatch.PatternDefinitions[0].LineBasePoint.Y - firstPoint.Y; | |
} | |
if (requiresShift) | |
{ | |
foreach (CadHatchPatternData d in hatch.PatternDefinitions) | |
{ | |
d.LineBasePoint.X -= distanceX; | |
d.LineBasePoint.Y -= distanceY; | |
} | |
} | |
} | |
} | |
} |