问题
I have managed to link my Visual Studio to my AutoCAD 2015, but I am struggling to get a handle on a text object within my AutoCAD project from vb.
I was wondering if anyone had any suggestions or tips as to how I could get a handle on an AutoCAD object from my vb code.
Ultimately I want to be able to change the text of this object from my vb code.
Any help or suggestions are appreciated..
Thank You in adavance
回答1:
I would suggest you start with My First Plugin tutorial then this AutoCAD .NET Training material (full list of training material here) that is presented at this video.
Here is a quick example on how list all AutoCAD entities on Model Space:
[CommandMethod("listAllOnModelSpace")]
public static void CmdListAllEntitiesOnModelSpace()
{
Database db = Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTableRecord mSpace = trans.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead) as BlockTableRecord;
foreach(ObjectId entityId in mSpace)
{
Entity entity = trans.GetObject(entityId, OpenMode.ForRead) as Entity;
}
trans.Commit();
}
}
Just had this in C#, but you may translate to VB.NET here.
来源:https://stackoverflow.com/questions/33125471/get-handle-of-object-in-autocad-2015-from-vb-net