Hello,
There are many examples of using SetImpliedSelection to highlight a selection in the editor.
eg:
Dim ids As ObjectId() = New ObjectId(objsNew.Count - 1) {}
objsNew.CopyTo(ids, 0)
doc.Editor.SetImpliedSelection(ids)
However the selected/highlighted objects are not added to the properties window or to the previous selection making the selection difficult to change properties and use in commands.
I am thinking of adding SendStringToExecute("(command "Select" etc to the end of my code but it looks a bit difficult.
Does anyone know how I could add a "true" selection to the editor?
Kind Regards
David
Hi David,
Does this blog post help ?
http://adndevblog.typepad.com/autocad/2015/01/entity-selection-to-modify-properties.html
Regards,
Balaji
Hi Balaji,
Unfortunately that does not seem to work.
Basically I am taking a selection >
PromptSelectionResult objPromptSelectionResult = activeDoc.Editor.GetSelection;
Modifying the selection in a form >
Document activeDoc = Application.DocumentManager.MdiActiveDocument;
DocumentLock objDocumentLock = activeDoc.LockDocument;
using (Transaction acTrans = activeDoc.TransactionManager.StartTransaction()) {
ObjectIdCollection objsNew = new ObjectIdCollection();
for (int i = uxSelectedItemTypes.Items.Count - 1; i >= 0; i += -1) {
if (uxSelectedItemTypes.GetItemChecked(i)) {
clsStringAndObjectItem objStringAndObjectItem = uxSelectedItemTypes.Items.Item(i);
List<ObjectId> ListOfObjId = objStringAndObjectItem.StringAndObjectItemObject;
foreach (ObjectId obj in ListOfObjId) {
objsNew.Add(obj);
}
}
}
ObjectId[] ids = new ObjectId[objsNew.Count];
objsNew.CopyTo(ids, 0);
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.SetImpliedSelection(ids);
if (acTrans != null)
acTrans.Dispose();
if (objDocumentLock != null)
objDocumentLock.Dispose();
}
Then retuning the selection to lisp (I reluctantly had to to do this as the selection was not working) >
ResultBuffer rbfResult = default(ResultBuffer);
Document activeDoc = Application.DocumentManager.MdiActiveDocument;
Editor ed = activeDoc.Editor;
rbfResult = new ResultBuffer(new TypedValue(Convert.ToInt32(5007), ed.SelectImplied.Value));
return rbfResult;
The lisp part >
(setq refineSelection_sel1 (refineSelection_dotNet))
(if refineSelection_sel1
(command ".select" (car refineSelection_sel1) ""
".pselect" (car refineSelection_sel1) ""
)
)
I would love to work out what I'm doing wrong in the .net part so I don't have to call it via a lisp command.
Kind Regards
David
Hi David,
I think this is what you're looking for:
using Autodesk.AutoCAD.Internal; //Fill an array of ObjectIds from your selection ObjectId[] ida = ...; Utils.SelectObjects(ida);
The entities will be highlighted and selected, and all properties will be shown in the Properties window.
Regards,
Henk