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

SelectionSet Question(New Pointer, With Keyword)

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Amremad
1082 Views, 6 Replies

SelectionSet Question(New Pointer, With Keyword)

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

6 REPLIES 6
Message 2 of 7
Amremad
in reply to: Amremad

any solution

Message 3 of 7
norman.yuan
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.

 

Message 4 of 7
Amremad
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?

 

Message 5 of 7
Amremad
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 ,

 

Message 6 of 7
norman.yuan
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.

 

Message 7 of 7
Amremad
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

 

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