.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Emulate Properties Dialog by selecting object on screen

7 REPLIES 7
Reply
Message 1 of 8
arcticad
758 Views, 7 Replies

Emulate Properties Dialog by selecting object on screen

I'm trying to select an object and have it send data to my program the same way as the properties box.

Anyone have any ideas?

Thank You.
---------------------------



(defun botsbuildbots() (botsbuildbots))
7 REPLIES 7
Message 2 of 8
cadMeUp
in reply to: arcticad

You can try monitoring the 'SelectionAdded' and 'SelectionRemoved' events of the Editor object. The handler's may get called multiple times, for example when I select one line the 'SelectionAdded' handler gets called three times, just one thing to be aware of.
Message 3 of 8
Anonymous
in reply to: arcticad

These events aren't used for that. They are used for
filtering selections. They will not tell you what the final
selection set is, or whether it is a pickfirst selection or
a selection in the context of a command that asks for
a selection.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6223751@discussion.autodesk.com...
You can try monitoring the 'SelectionAdded' and 'SelectionRemoved' events of
the Editor object. The handler's may get called multiple times, for example
when I select one line the 'SelectionAdded' handler gets called three times,
just one thing to be aware of.
Message 4 of 8
Anonymous
in reply to: arcticad

Use the ImpliedSelectionChanged event of the Document.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6222812@discussion.autodesk.com...
I'm trying to select an object and have it send data to my program the same
way as the properties box.

Anyone have any ideas?

Thank You.
Message 5 of 8
cadMeUp
in reply to: arcticad

Yeah, it is better to handle 'ImpliedSelectionChanged'. You can get the implied selection within the handler:
{code}
private void Document_ImpliedSelectionChanged(Object sender, EventArgs e)
{
Document doc = (Document)sender;
Editor ed = doc.Editor;

PromptSelectionResult sr = ed.SelectImplied();
if (sr.Value == null)
return;

ed.WriteMessage("\nSelection Count: {0}", sr.Value.Count);
}
{code}

Much better way! Way more predictable.

The 'SelectionAdded' event of the Editor object will give you the selection count with the 'SelectionAddedEventArgs.AddedObjects' property, if it's an implied (pickfirst) selection or if selecting/removing objects within a command.
Message 6 of 8
Anonymous
in reply to: arcticad

{quote}

The 'SelectionAdded' event of the Editor object will give you the selection
count with the 'SelectionAddedEventArgs.AddedObjects' property, if it's an
implied (pickfirst) selection or if selecting/removing objects within a
command.

{quote}

Nope. It doesn't give you the count of the selection. It only gives you the
count of each 'subselection'.

A subselection is the set of objects selected by the user in response to a
'Select Objects' prompt during selection. When a user is prompted to select
multiple objects, they can make any number of subselections (e.g., the
'Select Objects' prompt repeatedly appears until you press ENTER or cancel
out).

The SelectionAdded event fires for each subselection and allows the objects
selected to be filtered.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6224813@discussion.autodesk.com...
Yeah, it is better to handle 'ImpliedSelectionChanged'. You can get the
implied selection within the handler:
{code}
private void Document_ImpliedSelectionChanged(Object sender, EventArgs e)
{
Document doc = (Document)sender;
Editor ed = doc.Editor;

PromptSelectionResult sr = ed.SelectImplied();
if (sr.Value == null)
return;

ed.WriteMessage("\nSelection Count: {0}", sr.Value.Count);
}
{code}

Much better way! Way more predictable.

The 'SelectionAdded' event of the Editor object will give you the selection
count with the 'SelectionAddedEventArgs.AddedObjects' property, if it's an
implied (pickfirst) selection or if selecting/removing objects within a
command.
Message 7 of 8
cadMeUp
in reply to: arcticad

Yeah, I see what you mean, for selecting objects during command interaction, my mistake. The 'SelectionAdded' & 'SelectionRemoved' events will work in this case. All you need is the pickfirst (implied) set. As you add/remove objects to/from the pickfirst set, 'SelectionAdded' gets fired and passed the number of objects, to the event handler, that are in the pickfirst set ('SelectionAddedEventArgs.AddedObjects.Count', as long as 'AddedObjects' is not null, if it is then obviously the count is 0), and the properties pallette displays or updates it's display of the properties of the selected objects. So the emulation that 'arcticad' needs would react upon the pickfirst set, based on his original post. I don't think he states anything about selected objects during command interaction. When you start the 'MOVE' or 'ROTATE' commands for example and select/deselect objects, nothing tells the the properties pallette to update it's display of properties.

In your first reply I'm trying to understand how this relates to the original posted problem:
"a selection in the context of a command that asks for a selection."
Seems a command would not be active in this case. If it was then emulation of selecting an object and properties display updating wouldn't be needed.

I agree though, 'ImpliedSelectionChanged' is the way to go. It gives exactly what is needed. It gets fired when you expect it to and you can get the pickfirst selection within the handler: Editor.SelectImplied(). I did originally consider the 'ImpliedSelectionChanged', but seeing that the event args passed to the handler doesn't pass anything useful I overlooked it. You can easily get the pickfirst set within the handler.

But, with regards the 'SelectionAdded' & 'SelectionRemoved' events, maybe someone can explain why:

When you make an implied selection, the 'SelectionAdded' event gets fired, obviously. Now with the objects still selected, when you move your mouse over one of the selected objects, just move it over a selected object, the 'SelectionAdded' event gets fired multiple times again? There isn't even a selection being made, the mouse is just sitting there. That seems very odd!
Message 8 of 8
Anonymous
in reply to: arcticad

If PICKADD = 1, then the SelectionAdded/Removed events
fire, but pass only the objects added to/removed from the
selection, so it really isn't a very good way to detect that the
pickfirst selection changed.

Additionally, if a command sets the pickfirst selection through
code, before it exits, the events may not fire either.

The point is that those two events are not for the purpose of
detecting that the pickfirst selection changed, the Document's
ImpliedSelectionChanged event is for that.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6224881@discussion.autodesk.com...
Yeah, I see what you mean, for selecting objects during command interaction,
my mistake. The 'SelectionAdded' & 'SelectionRemoved' events will work in
this case. All you need is the pickfirst (implied) set. As you add/remove
objects to/from the pickfirst set, 'SelectionAdded' gets fired and passed
the number of objects, to the event handler, that are in the pickfirst set
('SelectionAddedEventArgs.AddedObjects.Count', as long as 'AddedObjects' is
not null, if it is then obviously the count is 0), and the properties
pallette displays or updates it's display of the properties of the selected
objects. So the emulation that 'arcticad' needs would react upon the
pickfirst set, based on his original post. I don't think he states anything
about selected objects during command interaction. When you start the 'MOVE'
or 'ROTATE' commands for example and select/deselect objects, nothing tells
the the properties pallette to update it's display of properties.

In your first reply I'm trying to understand how this relates to the
original posted problem:
"a selection in the context of a command that asks for a selection."
Seems a command would not be active in this case. If it was then emulation
of selecting an object and properties display updating wouldn't be needed.

I agree though, 'ImpliedSelectionChanged' is the way to go. It gives exactly
what is needed. It gets fired when you expect it to and you can get the
pickfirst selection within the handler: Editor.SelectImplied(). I did
originally consider the 'ImpliedSelectionChanged', but seeing that the event
args passed to the handler doesn't pass anything useful I overlooked it. You
can easily get the pickfirst set within the handler.

But, with regards the 'SelectionAdded' & 'SelectionRemoved' events, maybe
someone can explain why:

When you make an implied selection, the 'SelectionAdded' event gets fired,
obviously. Now with the objects still selected, when you move your mouse
over one of the selected objects, just move it over a selected object, the
'SelectionAdded' event gets fired multiple times again? There isn't even a
selection being made, the mouse is just sitting there. That seems very odd!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost