public static XElement ToXElement(this DxfHatch hatch) { List <SvgPathSegment> segments = new List <SvgPathSegment>(); // TODO: support/check all HatchStyle if (hatch.HatchStyle == DxfHatchStyle.OddParity) { return(null); } foreach (var bp in hatch.BoundaryPaths) { var s = GetSvgPathSegments(bp); if (s != null) { segments.AddRange(s); } } var path = new SvgPath(segments); return(new XElement(DxfToSvgConverter.Xmlns + "path", new XAttribute("d", path.ToString()), new XAttribute("fill-opacity", hatch.Transparency < 100 ? 100 - hatch.Transparency: 100), new XAttribute("fill", hatch.Color.ToRGBString())) .AddVectorEffect()); }
public override void ResolveReferences(Class374 modelBuilder) { base.ResolveReferences(modelBuilder); foreach (Class659 class659 in this.list_1) { class659.ResolveReferences(modelBuilder); } DxfHatch handledObject = (DxfHatch)this.HandledObject; if (!handledObject.Associative) { return; } bool flag = false; foreach (DxfHatch.BoundaryPath boundaryPath in handledObject.BoundaryPaths) { if (boundaryPath.BoundaryObjects.Count > 0) { flag = true; break; } } if (flag) { return; } handledObject.Associative = false; }
/// <summary> /// 方法,向模型空间添加一个图案填充 /// </summary> /// <param name="_model">模型空间</param> /// <param name="_hatchName">填充名称</param> /// <param name="_startX">起点X坐标</param> /// <param name="_startY">起点Y坐标</param> /// <param name="_endX">终点X坐标</param> /// <param name="_endY">终点Y坐标</param> /// <returns></returns> public DxfHatch AddRecHatch(string _hatchName, double _startX, double _startY, double _endX, double _endY) { DxfHatch hatch = new DxfHatch(); DxfHatch.BoundaryPath boundary = new DxfHatch.BoundaryPath(); boundary.Type = BoundaryPathType.Polyline; hatch.BoundaryPaths.Add(boundary); DxfHatch.BoundaryPath.Polyline.Vertex[] vertexs = new DxfHatch.BoundaryPath.Polyline.Vertex[4] { new DxfHatch.BoundaryPath.Polyline.Vertex(_startX, _startY), new DxfHatch.BoundaryPath.Polyline.Vertex(_endX, _startY), new DxfHatch.BoundaryPath.Polyline.Vertex(_endX, _endY), new DxfHatch.BoundaryPath.Polyline.Vertex(_startX, _endY) }; boundary.PolylineData = new DxfHatch.BoundaryPath.Polyline(vertexs); boundary.PolylineData.Closed = true; DxfPatternStore.Add(PatternReader.ReadPatterns("acad.pat")); hatch.Pattern = DxfPatternStore.GetPatternWithName(_hatchName); hatch.Scale = 0.5; Model.Entities.Add(hatch); return(hatch); }
/// <summary> /// 方法,向模型空间添加一个圆 /// </summary> /// <param name="_centerX">圆心的X坐标</param> /// <param name="_centerY">圆心的Y坐标</param> /// <param name="_radius">圆的半径</param> /// <param name="_isSolid">实心或空心,true为实心</param> /// <returns></returns> public DxfCircle AddCircle(double _centerX, double _centerY, double _radius, bool _isSolid) { DxfCircle circle = new DxfCircle(new Point2D(_centerX, _centerY), _radius); Model.Entities.Add(circle); if (_isSolid) { DxfHatch hatch = new DxfHatch(); DxfHatch.BoundaryPath boundary = new DxfHatch.BoundaryPath(); boundary.Type = BoundaryPathType.Outermost; hatch.BoundaryPaths.Add(boundary); DxfHatch.BoundaryPath.ArcEdge arcEdge = new DxfHatch.BoundaryPath.ArcEdge(); arcEdge.Center = new Point2D(_centerX, _centerY); arcEdge.Radius = 1; arcEdge.StartAngle = 0; arcEdge.EndAngle = System.Math.PI * 2; boundary.Edges.Add(arcEdge); Model.Entities.Add(hatch); } return(circle); }
public void Test() { DxfModel model = new DxfModel(DxfVersion.Dxf14); DxfHatch hatch = new DxfHatch(); hatch.Color = EntityColors.Green; hatch.ElevationPoint = new Point3D(10,10, 0); hatch.ZAxis = new Vector3D(0, 0, 0); // A boundary path bounded by lines. DxfHatch.BoundaryPath boundaryPath1 = new DxfHatch.BoundaryPath(); boundaryPath1.Type = BoundaryPathType.None; hatch.BoundaryPaths.Add(boundaryPath1); boundaryPath1.Edges.Add(new DxfHatch.BoundaryPath.LineEdge(new Point2D(0, 0), new Point2D(1, 0))); boundaryPath1.Edges.Add(new DxfHatch.BoundaryPath.LineEdge(new Point2D(1, 0), new Point2D(1, 1))); boundaryPath1.Edges.Add(new DxfHatch.BoundaryPath.LineEdge(new Point2D(1, 1), new Point2D(0, 1))); boundaryPath1.Edges.Add(new DxfHatch.BoundaryPath.LineEdge(new Point2D(0, 1), new Point2D(0, 0))); // Define the hatch fill pattern. // Don't set a pattern for solid fill. hatch.Pattern = new DxfPattern(); DxfPattern.Line patternLine = new DxfPattern.Line(); hatch.Pattern.Lines.Add(patternLine); patternLine.Angle = System.Math.PI / 4d; patternLine.Offset = new Vector2D(0.02, -0.01d); patternLine.DashLengths.Add(0.02d); patternLine.DashLengths.Add(-0.01d); patternLine.DashLengths.Add(0d); patternLine.DashLengths.Add(-0.01d); model.Entities.Add(hatch); DxfWriter.Write("DxfWriteHatchTest.dxf", model, false); }
/// <summary> /// 根据花纹库编号将相应的花纹插入到图表中 /// </summary> public DxfHatch getPatternHatch(double X1, double X2, double startDeep, double endDeep) { string path = AppDomain.CurrentDomain.BaseDirectory + "Drill\\patternLibrary\\"; DirectoryInfo directoryInfo = new DirectoryInfo(path); FileInfo[] fileInfo = directoryInfo.GetFiles("*.pat"); //获得pat文档的个数 int fileLength = fileInfo.Length; //遍历所有的已经存在的pat文件 foreach (FileInfo file in fileInfo) { //解决中文乱码问题 StreamReader str = new StreamReader(path + file, Encoding.Default); char[] s = { ',' }; //定义分隔符为逗号 StringBuilder rockName = new StringBuilder(); //存储岩石名称的数组 string readLine = str.ReadLine(); //读取一行数据 while (!string.IsNullOrEmpty(readLine)) //如果数据不为空) { string[] record = readLine.Split(s); rockName.Append(record[1]); string strRockName = rockName.ToString().Trim(); //strRockName = strRockName.Replace(" ", ""); if (string.Equals(strRockName, mrockName))//找到名字相同的花纹 { //读取花纹库 DxfModel model = new DxfModel(); DxfPatternStore.Add(PatternReader.ReadPatterns(path + file)); DxfHatch hatch = new DxfHatch(); hatch.Pattern = DxfPatternStore.GetPatternWithName("" + Path.GetFileNameWithoutExtension(file.Name)); DxfHatch.BoundaryPath boundaryPath = new DxfHatch.BoundaryPath(); boundaryPath.Type = BoundaryPathType.Polyline; hatch.BoundaryPaths.Add(boundaryPath); boundaryPath.PolylineData = new DxfHatch.BoundaryPath.Polyline( new DxfHatch.BoundaryPath.Polyline.Vertex[] { new DxfHatch.BoundaryPath.Polyline.Vertex(X1, -23d - startDeep), new DxfHatch.BoundaryPath.Polyline.Vertex(X2, -23d - startDeep), new DxfHatch.BoundaryPath.Polyline.Vertex(X2, -23d - endDeep), new DxfHatch.BoundaryPath.Polyline.Vertex(X1, -23d - endDeep) } ); boundaryPath.PolylineData.Closed = true; return(hatch); } break; } } return(null); }
public Class1030(DxfModel model) { DxfVersion acadVersion = model.Header.AcadVersion; if (acadVersion < DxfVersion.Dxf15) { this.short_4 = DxfHatch.smethod_2(model.Classes).ClassNumber; this.short_3 = DxfLwPolyline.smethod_2(model.Classes).ClassNumber; this.short_9 = DxfClass.smethod_19(model.Classes).ClassNumber; } if (acadVersion < DxfVersion.Dxf18) { this.short_8 = DxfClass.smethod_15(model.Classes).ClassNumber; this.short_7 = DxfClass.smethod_16(model.Classes).ClassNumber; } this.dxfClass_0 = DxfClass.smethod_0(model.Classes); this.dxfClass_1 = DxfDataTable.smethod_2(model.Classes); this.dxfClass_5 = DxfClass.smethod_1(model.Classes); this.short_0 = DxfClass.smethod_20(model.Classes).ClassNumber; this.short_1 = DxfClass.smethod_21(model.Classes).ClassNumber; this.dxfClass_6 = DxfClass.smethod_5(model.Classes); this.dxfClass_14 = DxfClass.smethod_2(model.Classes); this.dxfClass_10 = DxfClass.smethod_6(model.Classes); this.dxfClass_22 = DxfVisualStyle.smethod_2(model.Classes); this.dxfClass_23 = DxfWipeoutVariables.smethod_2(model.Classes); this.dxfClass_11 = DxfClass.smethod_7(model.Classes); this.short_6 = this.dxfClass_11.ClassNumber; this.short_2 = this.dxfClass_6.ClassNumber; this.dxfClass_7 = DxfMLeader.smethod_2(model.Classes); this.dxfClass_8 = DxfMLeaderStyle.smethod_3(model.Classes); this.dxfClass_9 = DxfMLeaderObjectContextData.smethod_16(model.Classes); this.short_5 = this.dxfClass_10.ClassNumber; this.dxfClass_12 = DxfClass.smethod_3(model.Classes); this.dxfClass_16 = DxfClass.smethod_10(model.Classes); this.dxfClass_17 = DxfClass.smethod_11(model.Classes); this.dxfClass_18 = DxfClass.smethod_14(model.Classes); this.dxfClass_15 = DxfClass.smethod_12(model.Classes); this.dxfClass_19 = DxfClass.smethod_17(model.Classes); this.dxfClass_20 = DxfClass.smethod_18(model.Classes); this.dxfClass_21 = DxfTableContent.smethod_2(model.Classes); this.dxfClass_2 = DxfField.smethod_2(model.Classes); this.dxfClass_3 = DxfFieldList.smethod_2(model.Classes); this.dxfClass_4 = DxfGeoData.smethod_2(model.Classes); this.dxfClass_13 = DxfPlotSettings.smethod_2(model.Classes); this.class1032_0 = new Class1030.Class1032(model); this.class1031_0 = new Class1030.Class1031(model); }
public DxfHatch getHatch_Deck(decimal percentfill, double[] x, double[] y, EntityColor hatchcolor) { DxfHatch hatch = new DxfHatch(); hatch.Color = hatchcolor; if (percentfill != 0) { #region hatch DxfHatch.BoundaryPath.Polyline.Vertex[] Ver = new DxfHatch.BoundaryPath.Polyline.Vertex[13]; if ((Convert.ToInt32(percentfill) > 0) & (Convert.ToInt32(percentfill) <= 100)) { for (int i = 1; i <= 12; i++) { Ver[i] = new DxfHatch.BoundaryPath.Polyline.Vertex(x[i], y[i]); } } DxfHatch.BoundaryPath bp = new DxfHatch.BoundaryPath(); bp.Type = BoundaryPathType.Polyline; hatch.BoundaryPaths.Add(bp); bp.PolylineData = new DxfHatch.BoundaryPath.Polyline( new DxfHatch.BoundaryPath.Polyline.Vertex[] { Ver[1], Ver[2], Ver[3], Ver[4], Ver[5], Ver[6], Ver[7], Ver[8], Ver[9], Ver[10], Ver[11], Ver[12] } ); bp.PolylineData.Closed = true; #endregion hatch } return(hatch); }
public void Visit(DxfHatch hatch) { this.method_0((DxfEntity)hatch); }
public DxfHatchScaleContextData(DxfHatch hatch, DxfScale scale) : base(scale) { this.dxfPattern_0 = hatch.Pattern == null ? (DxfPattern)null : hatch.Pattern.Clone(); this.double_0 = scale.ScaleFactor; }
public DxfHatchViewContextData(DxfHatch hatch, DxfScale scale) : base(hatch, scale) { }
public Class298(DxfHatch hatch) : base((DxfEntity)hatch) { }
public virtual void Visit(DxfHatch hatch) { }
public void Visit(DxfHatch hatch) { this.bool_0 = true; }
/// <summary> /// Visits the specified entity. /// See the <see cref="IEntityVisitor"/> for more details. /// </summary> public override void Visit(DxfHatch hatch) { HandleEntity(hatch); }
public virtual void Visit(DxfHatch hatch) { this.VisitEntity((DxfEntity)hatch); }