Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
[2022/01/26]
Browse files Browse the repository at this point in the history
* The Polyline2D and Polyline3D Explode method will preserve the smooth type.
* Deleted the references to the ImageDefinitionReactor from the ImageDefinition they will be created when the DXF is saved.
* (fixed) Issues, introduced in the last two updates, when saving Polyline2D, Polyline3D, and PolyfaceMesh entities that were part of a Block.
  • Loading branch information
haplokuon committed Jan 26, 2022
1 parent 37b17d1 commit cec6153
Show file tree
Hide file tree
Showing 16 changed files with 539 additions and 327 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MIT License

netDxf library
Copyright (c) 2019-2021 Daniel Carvajal (haplokuon@gmail.com)

Copyright (c) 2019-2022 Daniel Carvajal (haplokuon@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions TestDxfDocument/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4030,18 +4030,18 @@ public static void DynamicBlocks()
// the application registry for this extended data always has the name "AcDbBlockRepBTag"
XData xdata = block.Record.XData["AcDbBlockRepBTag"];
string handle = null;
// the original dynamic block handle is stored in the extended data
// the original dynamic block record handle is stored in the extended data
foreach (XDataRecord data in xdata.XDataRecord)
{
if (data.Code == XDataCode.DatabaseHandle)
handle = (string) data.Value;
}

// now we can the original dynamic block record
// now we can get the original dynamic block record
BlockRecord originalDynamicBlockRecord = (BlockRecord) drawing.GetObjectByHandle(handle);
string dynamicBlockName = originalDynamicBlockRecord.Name;
// if we need the original block instead of just the record, we can get it from the list of block since we know now its name
Block originalBlockRecord = drawing.Blocks[dynamicBlockName];
Block originalBlock = drawing.Blocks[dynamicBlockName];

// the dynamic parameter of this insert was NOT modified so the block will be the original
insert = drawing.Entities.Inserts.ElementAt(1);
Expand Down
5 changes: 5 additions & 0 deletions doc/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Change history

### [2022/01/26]
* The Polyline2D and Polyline3D Explode method will preserve the smooth type.
* Deleted the references to the ImageDefinitionReactor from the ImageDefinition they will be created when the DXF is saved.
* (fixed) Issues, introduced in the last two updates, when saving Polyline2D, Polyline3D, and PolyfaceMesh entities that were part of a Block.

### [2021/12/06]
* Rename Face3d to Face3D.
* Rename Face3dEdgeFlags to Face3DEdgeFlags.
Expand Down
18 changes: 17 additions & 1 deletion netDxf/Collections/SupportFolders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public SupportFolders(int capacity)
public SupportFolders(IEnumerable<string> folders)
{
if (folders == null)
{
throw new ArgumentNullException(nameof(folders));
}
this.folders = new List<string>();
this.AddRange(folders);
}
Expand Down Expand Up @@ -119,7 +121,9 @@ public string FindFile(string file)
set
{
if (string.IsNullOrEmpty(value))
{
throw new ArgumentNullException(nameof(value));
}
this.folders[index] = value;
}
}
Expand Down Expand Up @@ -166,8 +170,10 @@ IEnumerator IEnumerable.GetEnumerator()
/// <param name="item">Folder path to add to the list. The item cannot be null.</param>
public void Add(string item)
{
if(string.IsNullOrEmpty(item))
if (string.IsNullOrEmpty(item))
{
throw new ArgumentNullException(nameof(item));
}
this.folders.Add(item);
}

Expand All @@ -178,7 +184,9 @@ public void Add(string item)
public void AddRange(IEnumerable<string> collection)
{
if (collection == null)
{
throw new ArgumentNullException(nameof(collection));
}
foreach (string s in collection)
{
this.folders.Add(s);
Expand All @@ -201,7 +209,9 @@ public void Clear()
public bool Contains(string item)
{
if (string.IsNullOrEmpty(item))
{
throw new ArgumentNullException(nameof(item));
}
return this.folders.Contains(item);
}

Expand All @@ -223,7 +233,9 @@ public void CopyTo(string[] array, int arrayIndex)
public bool Remove(string item)
{
if (string.IsNullOrEmpty(item))
{
throw new ArgumentNullException(nameof(item));
}
return this.folders.Remove(item);
}

Expand All @@ -244,6 +256,10 @@ public int IndexOf(string item)
/// <param name="item">The object to insert into the list.</param>
public void Insert(int index, string item)
{
if (string.IsNullOrEmpty(item))
{
throw new ArgumentNullException(nameof(item));
}
this.folders.Insert(index, item);
}

Expand Down
15 changes: 0 additions & 15 deletions netDxf/DxfDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -931,13 +931,6 @@ internal void AddEntityToDocument(EntityObject entity, Block block, bool assignH
Image image = (Image) entity;
image.Definition = this.imageDefs.Add(image.Definition, assignHandle);
this.imageDefs.References[image.Definition.Name].Add(image);

if (!image.Definition.Reactors.ContainsKey(image.Handle))
{
ImageDefinitionReactor reactor = new ImageDefinitionReactor(image.Handle);
this.NumHandles = reactor.AssignHandle(this.NumHandles);
image.Definition.Reactors.Add(image.Handle, reactor);
}
image.ImageDefinitionChanged += this.Image_ImageDefinitionChanged;
break;
case EntityType.MLine:
Expand Down Expand Up @@ -1136,7 +1129,6 @@ internal bool RemoveEntityFromDocument(EntityObject entity)
case EntityType.Image:
Image image = (Image)entity;
this.imageDefs.References[image.Definition.Name].Remove(image);
image.Definition.Reactors.Remove(image.Handle);
image.ImageDefinitionChanged -= this.Image_ImageDefinitionChanged;
break;
case EntityType.MLine:
Expand Down Expand Up @@ -1732,13 +1724,6 @@ private void Image_ImageDefinitionChanged(Image sender, TableObjectChangedEventA

e.NewValue = this.imageDefs.Add(e.NewValue);
this.imageDefs.References[e.NewValue.Name].Add(sender);

if (!e.NewValue.Reactors.ContainsKey(sender.Handle))
{
ImageDefinitionReactor reactor = new ImageDefinitionReactor(sender.Handle);
this.NumHandles = reactor.AssignHandle(this.NumHandles);
e.NewValue.Reactors.Add(sender.Handle, reactor);
}
}

private void Underlay_UnderlayDefinitionChanged(Underlay sender, TableObjectChangedEventArgs<UnderlayDefinition> e)
Expand Down
6 changes: 3 additions & 3 deletions netDxf/Entities/AlignedDimension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ protected override void CalculateReferencePoints()
Vector2 ref2 = this.SecondReferencePoint;
Vector2 dirRef = ref2 - ref1;
Vector2 dirDesp = Vector2.Normalize(Vector2.Perpendicular(dirRef));
Vector2 vec = this.offset* dirDesp;
Vector2 vec = this.offset * dirDesp;
Vector2 dimRef1 = ref1 + vec;
Vector2 dimRef2 = ref2 + vec;

Expand Down Expand Up @@ -358,8 +358,8 @@ protected override void CalculateReferencePoints()
scale = (double) styleOverride.Value;
}

double gap = textGap*scale;
this.textRefPoint = Vector2.MidPoint(dimRef1, dimRef2) + gap*dirDesp;
double gap = textGap * scale;
this.textRefPoint = Vector2.MidPoint(dimRef1, dimRef2) + gap * dirDesp;
}
}

Expand Down
Loading

0 comments on commit cec6153

Please sign in to comment.