diff --git a/AddInManager.sln b/AddInManager.sln
index e527ac2..17769b2 100644
--- a/AddInManager.sln
+++ b/AddInManager.sln
@@ -21,6 +21,7 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TestVB", "TestVB\TestVB.vbp
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug A21|Any CPU = Debug A21|Any CPU
Debug A22|Any CPU = Debug A22|Any CPU
Debug A23|Any CPU = Debug A23|Any CPU
Installer|Any CPU = Installer|Any CPU
@@ -32,11 +33,15 @@ Global
{E3C87D34-638C-47A0-A73A-D967B119458D}.Installer|Any CPU.Build.0 = Release|Any CPU
{E3C87D34-638C-47A0-A73A-D967B119458D}.Release A23|Any CPU.ActiveCfg = Release|Any CPU
{E3C87D34-638C-47A0-A73A-D967B119458D}.Debug A22|Any CPU.ActiveCfg = Debug|Any CPU
+ {E3C87D34-638C-47A0-A73A-D967B119458D}.Debug A21|Any CPU.ActiveCfg = Debug|Any CPU
+ {E3C87D34-638C-47A0-A73A-D967B119458D}.Debug A21|Any CPU.Build.0 = Debug|Any CPU
{5016ED6D-5A9A-4F59-AE49-CAA9615798F7}.Debug A23|Any CPU.ActiveCfg = Debug|Any CPU
{5016ED6D-5A9A-4F59-AE49-CAA9615798F7}.Installer|Any CPU.ActiveCfg = Release|Any CPU
{5016ED6D-5A9A-4F59-AE49-CAA9615798F7}.Installer|Any CPU.Build.0 = Release|Any CPU
{5016ED6D-5A9A-4F59-AE49-CAA9615798F7}.Release A23|Any CPU.ActiveCfg = Release|Any CPU
{5016ED6D-5A9A-4F59-AE49-CAA9615798F7}.Debug A22|Any CPU.ActiveCfg = Debug|Any CPU
+ {5016ED6D-5A9A-4F59-AE49-CAA9615798F7}.Debug A21|Any CPU.ActiveCfg = Debug|Any CPU
+ {5016ED6D-5A9A-4F59-AE49-CAA9615798F7}.Debug A21|Any CPU.Build.0 = Debug|Any CPU
{1661572C-EF3A-4DD6-83BD-CB4239CE8CDD}.Installer|Any CPU.ActiveCfg = Release A23|Any CPU
{1661572C-EF3A-4DD6-83BD-CB4239CE8CDD}.Release A23|Any CPU.ActiveCfg = Release A23|Any CPU
{1661572C-EF3A-4DD6-83BD-CB4239CE8CDD}.Release A23|Any CPU.Build.0 = Release A23|Any CPU
@@ -44,6 +49,8 @@ Global
{1661572C-EF3A-4DD6-83BD-CB4239CE8CDD}.Debug A23|Any CPU.Build.0 = Debug A23|Any CPU
{1661572C-EF3A-4DD6-83BD-CB4239CE8CDD}.Debug A22|Any CPU.ActiveCfg = Debug A22|Any CPU
{1661572C-EF3A-4DD6-83BD-CB4239CE8CDD}.Debug A22|Any CPU.Build.0 = Debug A22|Any CPU
+ {1661572C-EF3A-4DD6-83BD-CB4239CE8CDD}.Debug A21|Any CPU.ActiveCfg = Debug A21|Any CPU
+ {1661572C-EF3A-4DD6-83BD-CB4239CE8CDD}.Debug A21|Any CPU.Build.0 = Debug A21|Any CPU
{E05305A7-28E1-4658-B505-E035FEDDD266}.Debug A23|Any CPU.ActiveCfg = Debug A23|Any CPU
{E05305A7-28E1-4658-B505-E035FEDDD266}.Debug A23|Any CPU.Build.0 = Debug A23|Any CPU
{E05305A7-28E1-4658-B505-E035FEDDD266}.Installer|Any CPU.ActiveCfg = Release A23|Any CPU
@@ -51,11 +58,15 @@ Global
{E05305A7-28E1-4658-B505-E035FEDDD266}.Release A23|Any CPU.Build.0 = Release A23|Any CPU
{E05305A7-28E1-4658-B505-E035FEDDD266}.Debug A22|Any CPU.ActiveCfg = Debug A22|Any CPU
{E05305A7-28E1-4658-B505-E035FEDDD266}.Debug A22|Any CPU.Build.0 = Debug A22|Any CPU
+ {E05305A7-28E1-4658-B505-E035FEDDD266}.Debug A21|Any CPU.ActiveCfg = Debug A22|Any CPU
+ {E05305A7-28E1-4658-B505-E035FEDDD266}.Debug A21|Any CPU.Build.0 = Debug A22|Any CPU
{C736FCE7-CAE8-474B-8A55-672BC5C1F39B}.Debug A23|Any CPU.ActiveCfg = Release A23|Any CPU
{C736FCE7-CAE8-474B-8A55-672BC5C1F39B}.Debug A23|Any CPU.Build.0 = Release A23|Any CPU
{C736FCE7-CAE8-474B-8A55-672BC5C1F39B}.Installer|Any CPU.ActiveCfg = Release A23|Any CPU
{C736FCE7-CAE8-474B-8A55-672BC5C1F39B}.Release A23|Any CPU.ActiveCfg = Release A23|Any CPU
{C736FCE7-CAE8-474B-8A55-672BC5C1F39B}.Release A23|Any CPU.Build.0 = Release A23|Any CPU
+ {C736FCE7-CAE8-474B-8A55-672BC5C1F39B}.Debug A21|Any CPU.ActiveCfg = Debug A23|Any CPU
+ {C736FCE7-CAE8-474B-8A55-672BC5C1F39B}.Debug A21|Any CPU.Build.0 = Debug A23|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Test/ExportBlockCoordinate.cs b/Test/ExportBlockCoordinate.cs
new file mode 100644
index 0000000..f63d897
--- /dev/null
+++ b/Test/ExportBlockCoordinate.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Windows.Forms;
+using Autodesk.AutoCAD.ApplicationServices;
+using Autodesk.AutoCAD.DatabaseServices;
+using Autodesk.AutoCAD.EditorInput;
+using Autodesk.AutoCAD.Geometry;
+using Autodesk.AutoCAD.Runtime;
+using Application = Autodesk.AutoCAD.ApplicationServices.Application;
+
+namespace Test;
+
+public class ExportBlockCoordinate
+{
+ [CommandMethod("ExportBlockCoordinate")]
+ public void Export()
+ {
+ Document doc = Application.DocumentManager.MdiActiveDocument;
+ Editor editor = doc.Editor;
+ Database db = doc.Database;
+
+ // Prompt the user for the layer name
+ PromptResult promptResult = editor.GetString("\nEnter the layer name: ");
+ if (promptResult.Status != PromptStatus.OK)
+ {
+ editor.WriteMessage("\nInvalid input. Layer name not provided.");
+ return;
+ }
+ string layerName = promptResult.StringResult;
+
+ // Display the Save File dialog
+ SaveFileDialog saveFileDialog = new SaveFileDialog();
+ saveFileDialog.Filter = "CSV Files (*.csv)|*.csv";
+ saveFileDialog.Title = "Save Block Information";
+ DialogResult dialogResult = saveFileDialog.ShowDialog();
+
+ if (dialogResult != DialogResult.OK)
+ {
+ editor.WriteMessage("\nInvalid input. Output file path not provided.");
+ return;
+ }
+ string filePath = saveFileDialog.FileName;
+
+ using (Transaction tr = db.TransactionManager.StartTransaction())
+ {
+ // Open the block table for read
+ BlockTable blockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
+
+ // Open the current space block table record for read
+ BlockTableRecord spaceRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead) as BlockTableRecord;
+
+ using (StreamWriter writer = new StreamWriter(filePath))
+ {
+ // Write the CSV header
+ writer.WriteLine("Block Name,X,Y,Z,Rotation");
+
+ // Iterate through all the entities in the current space
+ foreach (ObjectId entityId in spaceRecord)
+ {
+ Entity entity = tr.GetObject(entityId, OpenMode.ForRead) as Entity;
+
+ // Check if the entity is a block reference and on the specified layer
+ if (entity is BlockReference blockRef && blockRef.Layer.Equals(layerName, StringComparison.OrdinalIgnoreCase))
+ {
+ string blockName = blockRef.Name;
+ Point3d location = blockRef.Position;
+ double rotation = blockRef.Rotation;
+ // Write the block information to the CSV file
+ writer.WriteLine($"{blockName},{location.X},{location.Y},{location.Z},{rotation}");
+ }
+ }
+ }
+
+ tr.Commit();
+ }
+ editor.WriteMessage($"\nBlock information exported to: {filePath}");
+ Process.Start(filePath);
+
+ }
+}
\ No newline at end of file
diff --git a/Test/Test.csproj b/Test/Test.csproj
index c3b98f8..974ec0f 100644
--- a/Test/Test.csproj
+++ b/Test/Test.csproj
@@ -8,7 +8,7 @@
x64
true
true
- Debug A22;Debug A23
+ Debug A21;Debug A22;Debug A23
$(Configurations);Release A20;Release A21;Release A22;Release A23