SendCommand from palette button retaining preselected object(s)

SendCommand from palette button retaining preselected object(s)

SRSDS
Advisor Advisor
646 Views
2 Replies
Message 1 of 3

SendCommand from palette button retaining preselected object(s)

SRSDS
Advisor
Advisor

Hi, Hope someone can help here..

 

I have a palette with a button. I'd like to be able to repeat the button command if space or enter is pressed.

But I also may have preselected objects to base the command on (otherwise it needs a pickfirst selection).

 

For some reason SendStringToExecute clears the current selectionset and I need to reselect an entity.

While calling the Sub directly doesn't allow the command to be repeated and ignores the DR CommandMethod call. 

Is there another way to achieve this?

 

 

    Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDraw.Click
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim mycommands As New Commands
        mycommands.Draw()
        'doc.SendStringToExecute("DR ", True, False, True)
    End Sub

 

    <CommandMethod("DR")> _
    Sub Draw()
'If selectedobjects.count>0 then ...
    End Sub

 

0 Likes
Accepted solutions (1)
647 Views
2 Replies
Replies (2)
Message 2 of 3

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

>> For some reason SendStringToExecute clears the current selectionset and I need to reselect an entity.

It will not clear the pickfirstselectionset if you tell to hold it ... within the command-attribute "UsePickSet":

 

<CommandMethod("DR", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)> _
Sub Draw()
   '...
End Sub

So you can do SendCommand for the commands to be repeatable by user <ENTER>

 

HTH, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 3

SRSDS
Advisor
Advisor

That was quick...Works!

Thanks again!!

 

0 Likes