Replace command tool from the Assembly Panel

Replace command tool from the Assembly Panel

Anonymous
Not applicable
376 Views
4 Replies
Message 1 of 5

Replace command tool from the Assembly Panel

Anonymous
Not applicable
Vb.net 2008
Inventor 2009


Background:

In an assembly, I am capturing the "Replace" command in the
OnFileInsertDialog event of the File Events.

When a user has a part selected and clicks the "Replace" command tool from
the Assembly Panel, the OnFileInsertDialog event fires and everything works
as expected. The "ActiveDocument.SelectSet" has a reference to the selected
part in the OnFileInsertDialog event.



Problem/question:

If the user does not have a part selected and then clicks the "Replace"
command tool they are prompted to select a part and then the
OnFileInsertDialog event fires. However, when the event fires the
"ActiveDocument.SelectSet" does not have any reference at all.

Why is the "ActiveDocument.SelectSet.Count" = 0 after the user has been
prompted to and has selected a part during the "Replace"?
0 Likes
377 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I can explain the behavior, but I don't know of a solution for what you're
trying to do.

The reason for the behavior is that in the first case the user is selecting
the part, which adds it to the select set. When you run the Replace command
it's smart enough to look and see if an occurrence is already selected and
if it is it uses the selected occurrence and skips the step of having the
user select one.

If there's not an occurrence selected when the command is run then the
command has the user select an occurrence. This selection is not using the
standard select command but is specific to the Replace command so it does
not affect the select set. You'll see the same behavior if you write a
command using the SelectEvents object. Any selections that happen through
the SelectEvents of your command are local to your command and do not
interact with the select set.

I don't know of any way to determine which occurrence was selected within
the command.
--
Brian Ekins
Autodesk Inventor API Product Designer
http://blogs.autodesk.com/modthemachine
0 Likes
Message 3 of 5

Anonymous
Not applicable
Brian - Thank you for your quick response.

I am the programmer for an “in-house” document management system. When a
user clicks the “Replace” tool, I cancel the OnFileInsertDialog event and
provide my own dialog window for selection of the replacement document.

If the user is prompted and makes a selection that isn’t part of the
SelectSet then how does the ComponentDefinition Replace command work for
this scenario? Is there another way for the ComponentDefinition to
reference the object that the user has selected?




"Brian Ekins (Autodesk)" wrote in message
news:6120327@discussion.autodesk.com...
> I can explain the behavior, but I don't know of a solution for what you're
> trying to do.
>
> The reason for the behavior is that in the first case the user is
> selecting
> the part, which adds it to the select set. When you run the Replace
> command
> it's smart enough to look and see if an occurrence is already selected and
> if it is it uses the selected occurrence and skips the step of having the
> user select one.
>
> If there's not an occurrence selected when the command is run then the
> command has the user select an occurrence. This selection is not using
> the
> standard select command but is specific to the Replace command so it does
> not affect the select set. You'll see the same behavior if you write a
> command using the SelectEvents object. Any selections that happen through
> the SelectEvents of your command are local to your command and do not
> interact with the select set.
>
> I don't know of any way to determine which occurrence was selected within
> the command.
> --
> Brian Ekins
> Autodesk Inventor API Product Designer
> http://blogs.autodesk.com/modthemachine
0 Likes
Message 4 of 5

Anonymous
Not applicable
I'm not sure exactly what you're asking here. Here's a basic description of
Inventor's behavior. If you're not running any command you are in the
Select command. When you select entities while in the Select command they
are added to the select set. A few commands are totally dependent on the
Select command for input. For example, the delete command doesn't prompt
you to select entities but deletes what's already in the select set.

Some other commands will take advantage of the select set when possible.
For example, when the Replace or Fillet commands are executed they look to
see what entities are in the select set and if they're valid for that
command will use them. With the Fillet command you can then use the dialog
to continue to select additional entities. For the replace command, it only
needs a single input so if there's something in the select set it skips the
selection step. Finally there are other commands that ignore the select set
completely. For example, the Extrude command doesn't care what's selected
before you run it.

When a command is running it uses a different method of selection that
doesn't involve the select set that's local to that command. There's not
any way through the API to know what the command is selecting.
--
Brian Ekins
Autodesk Inventor API Product Designer
http://blogs.autodesk.com/modthemachine
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thanks Brian,

Your last paragraph is the answer to my question.

I'm sorry if my problem wasn't clear. What I was trying to get to is #5
below:

1. In an assembly nothing is selected.
2. The user clicks the replace command.
3. The user is prompted by Inventor to select a part to replace.
4. Now, the "OnFileInsertDialog" event fires.
5. There is no way to know what part the user has selected because the
selection isn't part of the "SelectSet"

Pete


"Brian Ekins (Autodesk)" wrote in message
news:6120470@discussion.autodesk.com...
> I'm not sure exactly what you're asking here. Here's a basic description
> of
> Inventor's behavior. If you're not running any command you are in the
> Select command. When you select entities while in the Select command they
> are added to the select set. A few commands are totally dependent on the
> Select command for input. For example, the delete command doesn't prompt
> you to select entities but deletes what's already in the select set.
>
> Some other commands will take advantage of the select set when possible.
> For example, when the Replace or Fillet commands are executed they look to
> see what entities are in the select set and if they're valid for that
> command will use them. With the Fillet command you can then use the
> dialog
> to continue to select additional entities. For the replace command, it
> only
> needs a single input so if there's something in the select set it skips
> the
> selection step. Finally there are other commands that ignore the select
> set
> completely. For example, the Extrude command doesn't care what's selected
> before you run it.
>
> When a command is running it uses a different method of selection that
> doesn't involve the select set that's local to that command. There's not
> any way through the API to know what the command is selecting.
> --
> Brian Ekins
> Autodesk Inventor API Product Designer
> http://blogs.autodesk.com/modthemachine
0 Likes