.NET

Reply
Mentor
Amremad
Posts: 209
Registered: ‎08-24-2010
Message 1 of 7 (277 Views)
Accepted Solution

SelectionSet Question(New Pointer, With Keyword)

277 Views, 6 Replies
04-02-2013 02:05 AM

Hello Every one,

iam so happy to start finally start acutal program using .net

this is a good time for me

so i will ask the first actual question in the field

 

i asked before this question in VBA Forum but no answer there so the people advice me to use .net to solve this problem.

 

my question about selectionset :

1- how can i do SelectionSet With KeyWord like following picture

selection with keyword.jpg

 

2- how can i change mouse pointer on selectionset like picture

original.jpg

 

 3- how can i make selectionset with one determine object like block (allow to select one only)

thx for you

Mentor
Amremad
Posts: 209
Registered: ‎08-24-2010
Message 2 of 7 (258 Views)

Re: SelectionSet Question(New Pointer, With Keyword)

04-02-2013 06:05 AM in reply to: Amremad

any solution

*Expert Elite*
Posts: 893
Registered: ‎04-27-2009
Message 3 of 7 (252 Views)

Re: SelectionSet Question(New Pointer, With Keyword)

04-02-2013 07:06 AM in reply to: Amremad

You look into various GetXXXX() method of Editor class, with appropriate PromptXXXXOptions class and/or SelectionFilter class being used as argument in those GetXXXX() method.

 

For your question 1, depending on your actual need, you can either use Editor.GetSelection() to select one entity or more entities, or you can use GetEntity() to select one entity at a time. All those GetXXX() method takes PromptXXXXOptions as argument, in which you can define keyword.

 

the code would look like (not tested, in C#)

 

PromptSelectionOptions opt=new Promp[tSelectionOptions();

opt.MessageForAdding="\nSelect object on layer xxx:";

opt......

opt.Keywords.Add("Settings");

opt.Keywords.Defalut="Settings";

 

PromptSelectionResult res=ed.GetSelection(opt);

if (res.Status==PromptStatus.OK || res.Status==PromptStatus.Keyword)

{

  ''If status is OK, do something with the selectionset in the PromptSelectionResult object

 

  ''If the status is Keyword, do something according to the keyword value

}

 

As for changing cursor during selecting, the various PromptXXXXOptions class' do not provide a way to do that. I am not aware of anything we can do (at least up to Acad2012 I am currently using);

 

for your last question, you can create a SelectionFilter (which I saw you have used it in your other post) and use it in GetSelection() method as the second argument. if you only want to select one entity(block), then you can use GetEntity() method in conjunction with PromptEntityOption class, in which you can set allowed entity (blockreference only, for example).

 

HTH.

 

Mentor
Amremad
Posts: 209
Registered: ‎08-24-2010
Message 4 of 7 (229 Views)

Re: SelectionSet Question(New Pointer, With Keyword)

04-03-2013 12:46 AM in reply to: norman.yuan

thank you mr norman

 

in first question i made this function but doesn't work

    <CommandMethod("tst")> _
    Public Sub testing()

        Dim TypedValues(0) As TypedValue
        TypedValues.SetValue(New TypedValue(DxfCode.BlockName, "AMR.LEVEL"), 0)

        Dim AcSelFtr As SelectionFilter = New SelectionFilter(TypedValues)

        Dim AcSelOption As PromptSelectionOptions = New PromptSelectionOptions
        AcSelOption.MessageForAdding = ("\nSelect Object on Layer XXX")
        AcSelOption.Keywords.Add("Settings")
        AcSelOption.Keywords.Default = "Settings"

        Dim AcSelPrompt As PromptSelectionResult
        AcSelPrompt=Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(AcSelOption, AcSelFtr)
    End Sub

 Settings doesn't work in this code why?

 

Mentor
Amremad
Posts: 209
Registered: ‎08-24-2010
Message 5 of 7 (226 Views)

Re: SelectionSet Question(New Pointer, With Keyword)

04-03-2013 01:16 AM in reply to: Amremad

i fixed my code and now is work

    <CommandMethod("tst")> _
    Public Sub testing()
        ' create selection filter with typedvalues
        Dim TypedValues(0) As TypedValue
        TypedValues.SetValue(New TypedValue(DxfCode.BlockName, "AMR.LEVEL"), 0)
        Dim AcSelFtr As SelectionFilter = New SelectionFilter(TypedValues)

        'create keywords options for selection
        Dim AcSelOption As PromptSelectionOptions = New PromptSelectionOptions
        AcSelOption.Keywords.Add("Settings")
        AcSelOption.MessageForAdding = ("\nSelect Object on Layer or " & AcSelOption.Keywords.GetDisplayString(True))

        'start selectionset with keywords and filter
        Dim AcSelPrompt As PromptSelectionResult
        AcSelPrompt = Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(AcSelOption, AcSelFtr)

        '
        If AcSelPrompt.Status = PromptStatus.OK Then

        End If
    End Sub

 

how can i handle the keyword or selection that user input it ,

 

*Expert Elite*
Posts: 893
Registered: ‎04-27-2009
Message 6 of 7 (215 Views)

Re: SelectionSet Question(New Pointer, With Keyword)

04-03-2013 06:41 AM in reply to: Amremad

amremad_world wrote:

i fixed my code and now is work

    <CommandMethod("tst")> _
    Public Sub testing()
        ' create selection filter with typedvalues
        Dim TypedValues(0) As TypedValue
        TypedValues.SetValue(New TypedValue(DxfCode.BlockName, "AMR.LEVEL"), 0)
        Dim AcSelFtr As SelectionFilter = New SelectionFilter(TypedValues)

        'create keywords options for selection
        Dim AcSelOption As PromptSelectionOptions = New PromptSelectionOptions
        AcSelOption.Keywords.Add("Settings")
        AcSelOption.MessageForAdding = ("\nSelect Object on Layer or " & AcSelOption.Keywords.GetDisplayString(True))

        'start selectionset with keywords and filter
        Dim AcSelPrompt As PromptSelectionResult
        AcSelPrompt = Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(AcSelOption, AcSelFtr)

        '
        If AcSelPrompt.Status = PromptStatus.OK Then

        End If
    End Sub

 

how can i handle the keyword or selection that user input it ,

 


As shown in my previous reply, you test PromptSelectionResult.Status for both OK, or Keyword:

 

If AcSelPrompt.Status = PromptStatus.OK Then

    Dim ObjIds() As ObjectId=AcSelPrompt.Value.GetObjectIds()

    ''Do something with the obtained objectId array

 

ElseIf AcSelPrompt.Status==PromptStatus.Keyword Then

  'Since you only have one keyword, you do not have to test

  ''which keyword is selected

  ''Just do something to configure settings

Else

   Return

End If

 

I almost alway set a default keyword (PromptxxxxOption.Keyword.Default="xxxxx"), even there is only one keyword used. This way, user can simply hit Enter/Space to get the keyword selected, as opposed to having to enter a key as keyword and then hit Enter/Space. This make your user a bit happier.

 

Mentor
Amremad
Posts: 209
Registered: ‎08-24-2010
Message 7 of 7 (189 Views)

Re: SelectionSet Question(New Pointer, With Keyword)

04-17-2013 06:11 AM in reply to: Amremad

this is correct solution

 

    Public Shared Sub EditInformation()

        ' create selection filter with typedvalues
        Dim TypedValues(0) As TypedValue
        TypedValues.SetValue(New TypedValue(DxfCode.BlockName, "BIO.Doc.Info"), 0)
        Dim AcSelFtr As SelectionFilter = New SelectionFilter(TypedValues)

        'create keywords options for selection
        Dim AcSelOption As PromptSelectionOptions = New PromptSelectionOptions
        AcSelOption.Keywords.Add("Settings")
        AcSelOption.MessageForAdding = ("\nSelect Object on Layer or " & AcSelOption.Keywords.GetDisplayString(True))
        AcSelOption.Keywords.Default = "Settings"
        'start selectionset with keywords and filter
        Dim AcSelPrompt As PromptSelectionResult

        AddHandler AcSelOption.KeywordInput, AddressOf handle_KeywordInput
        AcSelPrompt = Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(AcSelOption, AcSelFtr)

        If AcSelPrompt.Status = PromptStatus.OK Then

        End If
    End Sub

    Private Shared Sub handle_KeywordInput(ByVal sender As Object, ByVal e As SelectionTextInputEventArgs)
        MsgBox(e.Input.ToString)
    End Sub

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community