Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm fairly new to writing an add-in with .NET for AutoCAD.
In this tool, I want to ask the user to select objects in the drawing and receive that object data back to my code.
I know the PromptSelection method allows that, but when I use that, I can't use the mouse wheel to move or pan. I can only zoom in and out and select. Is there a way to 'unlock' the mouse wheel function?
// Request for objects to be selected in the drawing area
PromptSelectionOptions pso = new PromptSelectionOptions();
pso.MessageForAdding = "Select Pipes";
PromptSelectionResult acSSPrompt = ed.GetSelection(pso);
// Allows to bring back the selected objects, but mouse wheel doesn't work for pan, only works for zoom
So I've tried SendStringToExecute method because that allows me to use the mouse wheel , but then I don't know how to get the selected data back to my code.
private void GetObject_Click(object sender, RoutedEventArgs e)
{
try
{
_document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
_document.SendStringToExecute("GETOBJECT ", false, false, true);
}
finally
{
}
}
[CommandMethod("GETOBJECT")]
public void GetObject()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
DocumentLock dl = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
var ed = doc.Editor;
using (Transaction ts = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
try
{
// Request for objects to be selected in the drawing area
PromptSelectionOptions pso = new PromptSelectionOptions();
pso.MessageForAdding = "Select Pipes";
PromptSelectionResult acSSPrompt = ed.GetSelection(pso);
// how do I use this data back in my code?
}
}
}
Can someone please share some ideas?
Thanks!
Solved! Go to Solution.