From b3673bf692ed8ad085ae979c875a68d6693a7f39 Mon Sep 17 00:00:00 2001 From: Nathan Wreggit Date: Fri, 31 Mar 2023 09:47:01 -0700 Subject: [PATCH] Fix Go to implementation (#15) * Fix implementation of GO TO * Add label specify where the objects are --- FindAndReplaceCAD/CADUtil.cs | 22 ++--------- .../FindAndReplaceCAD.csproj.user | 2 +- FindAndReplaceCAD/MainWindow.xaml | 7 ++-- FindAndReplaceCAD/Util/DBTextUtil.cs | 5 +-- FindAndReplaceCAD/Util/DimensionUtil.cs | 7 +--- FindAndReplaceCAD/Util/ITypeUtil.cs | 39 +++++++++++++++---- FindAndReplaceCAD/Util/MLeaderUtil.cs | 15 +------ FindAndReplaceCAD/Util/MTextUtil.cs | 5 +-- 8 files changed, 48 insertions(+), 54 deletions(-) diff --git a/FindAndReplaceCAD/CADUtil.cs b/FindAndReplaceCAD/CADUtil.cs index 7929d5f..4d233d6 100644 --- a/FindAndReplaceCAD/CADUtil.cs +++ b/FindAndReplaceCAD/CADUtil.cs @@ -51,8 +51,7 @@ public static IList ReadCADItems() using (Transaction myT = tm.StartTransaction()) { - - BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForRead); + BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead); // iterate through block table to locate objects @@ -72,21 +71,6 @@ public static IList ReadCADItems() return textFound; } - /// - /// Replaces all standard text with the escaped version needed to place back into text contents for AutoCAD - /// https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2020/ENU/AutoCAD-Core/files/GUID-7D8BB40F-5C4E-4AE5-BD75-9ED7112E5967-htm.html - /// - /// Text for a single element - /// String with all characters escaped for AutoCAD - //public static string ReplaceWithCADEscapeCharacters(string data) - //{ - // data = data.Replace(@"\", @"\\"); // Must come first - // data = data.Replace("\r\n", @"\P"); - // data = data.Replace(@"{", @"\{"); - // data = data.Replace(@"}", @"\}"); - // return data; - //} - /// /// Moves and scales the viewport to center on the CAD element specified by its object ID /// https://through-the-interface.typepad.com/through_the_interface/2012/12/zooming-panning-and-orbiting-the-current-autocad-view-using-net.html @@ -103,8 +87,8 @@ public static void MoveViewPort(ObjectId objId) { TypeUtil.TypeInformation t = TypeUtil.GetTypeInformation(objId); ITypeUtil typeUtil = t.TypeUtil; - DBObject obj = myT.GetObject(objId, OpenMode.ForRead); - typeUtil.MoveViewPort(ed, view, myT, obj); + Entity obj = (Entity) myT.GetObject(objId, OpenMode.ForRead); + typeUtil.MoveViewPort(ed, myT, obj); obj.Dispose(); myT.Commit(); diff --git a/FindAndReplaceCAD/FindAndReplaceCAD.csproj.user b/FindAndReplaceCAD/FindAndReplaceCAD.csproj.user index a1532db..581e742 100644 --- a/FindAndReplaceCAD/FindAndReplaceCAD.csproj.user +++ b/FindAndReplaceCAD/FindAndReplaceCAD.csproj.user @@ -18,7 +18,7 @@ C:\Program Files\Autodesk\AutoCAD 2022\acad.exe - C:\Users\natha\OneDrive\Projects\AutoCAD\FindAndReplaceCAD\config\Drawing1.dwg /b C:\Users\natha\OneDrive\Projects\AutoCAD\FindAndReplaceCAD\config\script.scr /nologo + "C:\Users\natha\OneDrive\Desktop\CI-001 - Standard\CI-001.dwg" /b C:\Users\natha\OneDrive\Projects\AutoCAD\FindAndReplaceCAD\config\script.scr /nologo Program diff --git a/FindAndReplaceCAD/MainWindow.xaml b/FindAndReplaceCAD/MainWindow.xaml index 090685e..9939663 100644 --- a/FindAndReplaceCAD/MainWindow.xaml +++ b/FindAndReplaceCAD/MainWindow.xaml @@ -22,8 +22,8 @@ - + @@ -33,7 +33,7 @@ - + - +