Erstellen Sie ein Rechteck als Polylinien und füllen Sie es mit Schraffur
Contents
[
Hide
]Wie man ein Rechteck als Polylinien erstellt und es mit Schraffur füllt
Problem: Wie man ein Rechteck als Polylinien erstellt und es mit Schraffur füllt (CADNET-1351).
Tipps: Dazu erstellen Sie eine CadLwPolyline und fügen die Punktkoordinaten hinzu, verwenden Sie CadHatch, um mit Farben zu arbeiten, und verwenden Sie CadEdgeBoundaryPath, um zu verbinden. Verwenden Sie CadHatch, um mit Winkeln zu arbeiten, und CadHatchPatternData für das Muster.
Beispiel:
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
CadLwPolyline polyline = new CadLwPolyline(); | |
polyline.Coordinates = new List<Cad2DPoint>(); | |
polyline.Coordinates.Add(new Cad2DPoint(-5d, -5d)); | |
polyline.Coordinates.Add(new Cad2DPoint(-5d, 10d)); | |
polyline.Coordinates.Add(new Cad2DPoint(20d, 10d)); | |
polyline.Coordinates.Add(new Cad2DPoint(20d, -5d)); | |
polyline.Flag = CadLwPolylineFlag.Closed; | |
polyline.ConstantWidth = 0.1; | |
CadHatch hatch = new CadHatch(); | |
hatch.PatternName = "SOLID"; | |
hatch.ColorId = 1; // index of color: https://gohtx.com/acadcolors.php | |
hatch.HatchPatternType = 1; // 0 = User-defined; 1 = Predefined; 2 = Custom, we support only predefined now | |
hatch.BoundaryPaths = new List<CadHatchBoundaryPathContainer>(); | |
CadHatchBoundaryPathContainer container = new CadHatchBoundaryPathContainer(); | |
container.BoundaryPath = new List<ICadBoundaryPath>(); | |
CadEdgeBoundaryPath path = new CadEdgeBoundaryPath(); | |
path.Objects = new List<ICadBoundaryPathEntity>(); | |
path.Objects.Add(new CadBoundaryPathLine() { FirstPoint = new Point2D(-5, -5), SecondPoint = new Point2D(-5, 10) }); | |
path.Objects.Add(new CadBoundaryPathLine() { FirstPoint = new Point2D(-5, 10), SecondPoint = new Point2D(20, 10) }); | |
path.Objects.Add(new CadBoundaryPathLine() { FirstPoint = new Point2D(20, 10), SecondPoint = new Point2D(20, -5) }); | |
path.Objects.Add(new CadBoundaryPathLine() { FirstPoint = new Point2D(20, -5), SecondPoint = new Point2D(-5, -5) }); | |
container.BoundaryPath.Add(path); | |
hatch.BoundaryPaths.Add(container); | |
List<CadBaseEntity> entities = new List<CadBaseEntity>(); | |
entities.Add(polyline); | |
entities.Add(hatch); | |
cadImage.Entities = entities.ToArray(); | |
cadImage.UpdateSize(); | |
CadHatch hatch = new CadHatch(); | |
hatch.PatternName = "ANGLE"; // only known values are available here | |
hatch.ColorId = 1; | |
hatch.HatchPatternType = 1; // | |
hatch.BoundaryPaths = new List<CadHatchBoundaryPathContainer>(); | |
CadHatchBoundaryPathContainer container = new CadHatchBoundaryPathContainer(); | |
container.BoundaryPath = new List<ICadBoundaryPath>(); | |
CadEdgeBoundaryPath path = new CadEdgeBoundaryPath(); | |
path.Objects = new List<ICadBoundaryPathEntity>(); | |
path.Objects.Add(new CadBoundaryPathLine(){FirstPoint = new Point2D(-5, -5), SecondPoint = new Point2D(-5,10)}); | |
path.Objects.Add(new CadBoundaryPathLine() { FirstPoint = new Point2D(-5, 10), SecondPoint = new Point2D(20, 10) }); | |
path.Objects.Add(new CadBoundaryPathLine() { FirstPoint = new Point2D(20, 10), SecondPoint = new Point2D(20, -5) }); | |
path.Objects.Add(new CadBoundaryPathLine() { FirstPoint = new Point2D(20, -5), SecondPoint = new Point2D(-5, -5) }); | |
container.BoundaryPath.Add(path); | |
hatch.BoundaryPaths.Add(container); | |
hatch.PatternDefinitions = new List<CadHatchPatternData>(); | |
CadHatchPatternData data1 = new CadHatchPatternData(); | |
data1.LineBasePoint = new Cad3DPoint(); | |
data1.DashLengths = new List<double>(); | |
data1.DashLengths.Add(4); | |
data1.DashLengths.Add(1.5); | |
data1.DashLengthCount = (short)data1.DashLengths.Count; | |
data1.LineOffset = new Cad2DPoint(0d, 5.5d); | |
CadHatchPatternData data2 = new CadHatchPatternData(); | |
data2.LineBasePoint = new Cad3DPoint(); | |
data2.DashLengths = new List<double>(); | |
data2.DashLengths.Add(4); | |
data2.DashLengths.Add(-1.5); | |
data2.LineAngle = 90; | |
data2.DashLengthCount = (short)data2.DashLengths.Count; | |
data2.LineOffset = new Cad2DPoint(-5.5d, 0d); | |
hatch.PatternDefinitions.Add(data1); | |
hatch.PatternDefinitions.Add(data2); | |
hatch.NumberOfPatternDefinitions = (short)hatch.PatternDefinitions.Count; | |
List<CadBaseEntity> entities = new List<CadBaseEntity>(); | |
entities.Add(polyline); | |
entities.Add(hatch); | |
cadImage.Entities = entities.ToArray(); | |
cadImage.UpdateSize(); |