Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
AutoCAD Mechanical 2023
API VB.NET or C# and VisualStudio
i try to regen the Entity in Drawing, but the Result ist not exactly good.
They are still some Entity, and they are not regetereted.
Actualy
the Goal:
This is my Code:
C#
[CommandMethod("Regen_OpenDWG", CommandFlags.Session)]
public void OpenDWG()
{
string strFileName = @"C:\InventorAPI\Example\2023.03.16\Test_A.dwg";
string strFileNameSave = @"C:\InventorAPI\Example\2023.03.16\Test_B.dwg";
DocumentCollection acDocMgr = Application.DocumentManager;
using (Database acCurDB = new Database(false, true))
{
acCurDB.ReadDwgFile(strFileName, FileOpenMode.OpenForReadAndReadShare, true, "");
// Regenerate each entity in the drawing
Document acDoc = Application.DocumentManager.MdiActiveDocument;
acDoc.SendStringToExecute("_REGENALL ", true, false, false);
acCurDB.SaveAs(strFileNameSave, DwgVersion.AC1032);
}
}
VB.NET:
<CommandMethod("Regen_OpenDWG", CommandFlags.Session)>
Public Sub OpenDWG()
Dim strFileName As String = "C:\InventorAPI\Example\2023.03.16\Test_A.dwg"
Dim strFileNameSave As String = "C:\InventorAPI\Example\2023.03.16\Test_B.dwg"
Dim acDocMgr As DocumentCollection = Application.DocumentManager
Using acCurDB As New Database(False, True)
acCurDB.ReadDwgFile(strFileName, FileOpenMode.OpenForReadAndReadShare, True, "")
' Regenerate each entity in the drawing
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
acDoc.SendStringToExecute("_REGENALL ", True, False, False)
acCurDB.SaveAs(strFileNameSave, DwgVersion.AC1032)
End Using
End Sub
Thanks for any Suggestion
Solved! Go to Solution.