private static void Solid() { DxfDocument dxf = new DxfDocument(); Solid solid = new Solid(); solid.FirstVertex=new Vector3f(0,0,0); solid.SecondVertex = new Vector3f(1, 0, 0); solid.ThirdVertex = new Vector3f(0, 1, 0); solid.FourthVertex = new Vector3f(1, 1, 0); dxf.AddEntity(solid); dxf.Save("solid.dxf", DxfVersion.AutoCad2000); //dxf.Load("solid.dxf"); //dxf.Save("solid.dxf"); }
private Solid ReadSolid(ref CodeValuePair code) { var solid = new Solid(); Vector3f v0 = Vector3f.Zero; Vector3f v1 = Vector3f.Zero; Vector3f v2 = Vector3f.Zero; Vector3f v3 = Vector3f.Zero; Vector3f normal = Vector3f.UnitZ; Dictionary<ApplicationRegistry, XData> xData = new Dictionary<ApplicationRegistry, XData>(); code = this.ReadCodePair(); while (code.Code != 0) { switch (code.Code) { case 5: solid.Handle = code.Value; code = this.ReadCodePair(); break; case 8: //layer code solid.Layer = this.GetLayer(code.Value); code = this.ReadCodePair(); break; case 62: //aci color code solid.Color = new AciColor(short.Parse(code.Value)); code = this.ReadCodePair(); break; case 6: //type line code solid.LineType = this.GetLineType(code.Value); code = this.ReadCodePair(); break; case 10: v0.X = float.Parse(code.Value); code = this.ReadCodePair(); break; case 20: v0.Y = float.Parse(code.Value); code = this.ReadCodePair(); break; case 30: v0.Z = float.Parse(code.Value); code = this.ReadCodePair(); break; case 11: v1.X = float.Parse(code.Value); code = this.ReadCodePair(); break; case 21: v1.Y = float.Parse(code.Value); code = this.ReadCodePair(); break; case 31: v1.Z = float.Parse(code.Value); code = this.ReadCodePair(); break; case 12: v2.X = float.Parse(code.Value); code = this.ReadCodePair(); break; case 22: v2.Y = float.Parse(code.Value); code = this.ReadCodePair(); break; case 32: v2.Z = float.Parse(code.Value); code = this.ReadCodePair(); break; case 13: v3.X = float.Parse(code.Value); code = this.ReadCodePair(); break; case 23: v3.Y = float.Parse(code.Value); code = this.ReadCodePair(); break; case 33: v3.Z = float.Parse(code.Value); code = this.ReadCodePair(); break; case 70: solid.Thickness = float.Parse(code.Value); code = this.ReadCodePair(); break; case 210: normal.X = float.Parse(code.Value); code = this.ReadCodePair(); break; case 220: normal.Y = float.Parse(code.Value); code = this.ReadCodePair(); break; case 230: normal.Z = float.Parse(code.Value); code = this.ReadCodePair(); break; case 1001: XData xDataItem = this.ReadXDataRecord(code.Value, ref code); xData.Add(xDataItem.ApplicationRegistry, xDataItem); break; default: if (code.Code >= 1000 && code.Code <= 1071) throw new DxfInvalidCodeValueEntityException(code.Code, code.Value, this.file, "The extended data of an entity must start with the application registry code " + this.fileLine); code = this.ReadCodePair(); break; } } solid.FirstVertex = v0; solid.SecondVertex = v1; solid.ThirdVertex = v2; solid.FourthVertex = v3; solid.Normal = normal; solid.XData = xData; return solid; }
private void WriteSolid(Solid solid) { if (this.activeSection != StringCode.EntitiesSection && !this.isBlockEntities) { throw new InvalidDxfSectionException(this.activeSection, this.file); } this.WriteCodePair(0, solid.CodeName); this.WriteCodePair(5, solid.Handle); this.WriteCodePair(100, SubclassMarker.Entity); this.WriteEntityCommonCodes(solid); this.WriteCodePair(100, SubclassMarker.Solid); this.WriteCodePair(10, solid.FirstVertex.X); this.WriteCodePair(20, solid.FirstVertex.Y); this.WriteCodePair(30, solid.FirstVertex.Z); this.WriteCodePair(11, solid.SecondVertex.X); this.WriteCodePair(21, solid.SecondVertex.Y); this.WriteCodePair(31, solid.SecondVertex.Z); this.WriteCodePair(12, solid.ThirdVertex.X); this.WriteCodePair(22, solid.ThirdVertex.Y); this.WriteCodePair(32, solid.ThirdVertex.Z); this.WriteCodePair(13, solid.FourthVertex.X); this.WriteCodePair(23, solid.FourthVertex.Y); this.WriteCodePair(33, solid.FourthVertex.Z); this.WriteCodePair(39, solid.Thickness); this.WriteCodePair(210, solid.Normal.X); this.WriteCodePair(220, solid.Normal.Y); this.WriteCodePair(230, solid.Normal.Z); this.WriteXData(solid.XData); }