Czy można edytować atrybuty bloków w programie AutoCAD za pomocą Autodesk.AutoCAD.Interop?
Opracowałem zewnętrzną aplikację WPF do generowania rysunków w c #. Za pomocą Autodesk.AutoCAD.Interop udało mi się narysować, wymiarować, dodawać bloki i wszystko, co jest wymagane przez aplikację, jednak nie mogę wypełniać tabelki rysunkowej ani generować listy części.
Wszystkie przykłady, które widziałem, oparte są na mechanizmie, który wymaga, aby aplikacja działała jako wtyczka w programie AutoCAD. Prawda jest taka, że wstawienie używanej linii to jedna lub dwie linie kodu za pomocą ModelSpace.InsertLine, teraz jest to co najmniej 8 linii kodu!
Czy istnieje sposób na osiągnięcie tej funkcjonalności za pomocą Autodesk.AutoCAD.Interop? Czy istnieje sposób na połączenie za pomocą interopu z wtyczką, którą można wywołać z zewnętrznego exe?
Wszelkie wskazówki na ten temat zostaną docenione.
Dzięki.
EDYTOWAĆ Ilustrować:
// before - Draw Line with Autodesk.AutoCAD.Interop
private static AcadLine DrawLine(double[] startPoint, double[] endPoint)
{
AcadLine line = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint);
return line;
}
// Now - Draw line with Autodesk.AutoCAD.Runtime
[CommandMethod("DrawLine")]
public static Line DrawLine(Coordinate start, Coordinate end)
{
// Get the current document and database
// Get the current document and database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the Block table for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
// Open the Block table record Model space for write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
// Create a line that starts at 5,5 and ends at 12,3
Line acLine = new Line(start.Point3d, end.Point3d);
acLine.SetDatabaseDefaults();
// Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acLine);
acTrans.AddNewlyCreatedDBObject(acLine, true);
// Save the new object to the database
acTrans.Commit();
return acLine;
}
}