diff --git a/README.md b/README.md index c349bd21..a31e2f18 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,6 @@ save the file as either R12 or the newest version possible (e.g., R2013 or R2010 ## Status Support for DXF files is complete from versions R10 through R2014 _EXCEPT_ for the following entities: -- HATCH - MESH - MLEADER - SURFACE diff --git a/src/IxMilia.Dxf.Generator/GeneratorBase.cs b/src/IxMilia.Dxf.Generator/GeneratorBase.cs index 86d6271e..cca2e57a 100644 --- a/src/IxMilia.Dxf.Generator/GeneratorBase.cs +++ b/src/IxMilia.Dxf.Generator/GeneratorBase.cs @@ -834,6 +834,12 @@ public string WriteConverter(XElement property) } } + public IEnumerable WriteCustomCode(XElement spec) + { + var code = AttributeOrDefault(spec, "Code"); + return new[] { code }; + } + public IEnumerable WriteProperty(XElement spec, XElement entity) { var property = GetPropertiesAndPointers(entity).Single(p => Name(p) == spec.Attribute("Property").Value); @@ -894,6 +900,8 @@ public IEnumerable WriteSpecificValue(XElement spec) } } + private int _foreachLevel = 0; + public IEnumerable WriteValue(XElement spec, XElement entity) { switch (spec.Name.LocalName) @@ -914,9 +922,12 @@ public IEnumerable WriteValue(XElement spec, XElement entity) lines.Add("{"); } - lines.Add($"{indent}foreach (var item in {property})"); + var itemSuffix = _foreachLevel == 0 ? "" : _foreachLevel.ToString(); + lines.Add($"{indent}foreach (var item{itemSuffix} in {property})"); lines.Add($"{indent}{{"); + _foreachLevel++; lines.AddRange(spec.Elements().SelectMany(e => WriteValue(e, entity)).Select(l => $"{indent} {l}")); + _foreachLevel--; lines.Add($"{indent}}}"); if (condition != null) { @@ -927,6 +938,8 @@ public IEnumerable WriteValue(XElement spec, XElement entity) return lines; case "WriteExtensionData": return new[] { "AddExtensionValuePairs(pairs, version, outputHandles);" }; + case "WriteCustomCode": + return WriteCustomCode(spec); default: throw new NotSupportedException(); } diff --git a/src/IxMilia.Dxf.Generator/Specs/EntitiesSpec.xml b/src/IxMilia.Dxf.Generator/Specs/EntitiesSpec.xml index 2a6ca57c..eb4b2a9c 100644 --- a/src/IxMilia.Dxf.Generator/Specs/EntitiesSpec.xml +++ b/src/IxMilia.Dxf.Generator/Specs/EntitiesSpec.xml @@ -519,7 +519,80 @@ HATCH --> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +