How can I select just one object using vb net (SelectOnScreen)

How can I select just one object using vb net (SelectOnScreen)

Anonymous
Not applicable
5,693 Views
5 Replies
Message 1 of 6

How can I select just one object using vb net (SelectOnScreen)

Anonymous
Not applicable

Hello to all experts.

Question.

I don't want user to be able to select more than one item. How should I do that ?

"Selectonscreen"  allow users to select more than one item. But I want as soon as user pick (let's say a line). program exits.

 

thanks for all help.

Regards,

 

 

0 Likes
Accepted solutions (4)
5,694 Views
5 Replies
Replies (5)
Message 2 of 6

_gile
Consultant
Consultant
Accepted solution

Hi

 

Have a look at:

Editor.PromptEntityOptions

Editor.PromptEntityResult



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 6

Anonymous
Not applicable

Editor.GetEntity

0 Likes
Message 4 of 6

Anonymous
Not applicable
Accepted solution

Thanks Gile.

 

You were right . With your tip I was able to google it and find a good tweaked working code.

Thanks again from everybody in this discussion. I am learning here.

 

  Sub test_editor_prompt()
        Dim myPEO As New Autodesk.AutoCAD.EditorInput.PromptEntityOptions(vbLf & "Select BarMark:")
        Dim mydwg, mydb, myed, myPS, myPer, myent, mytrans, mytransman As Object
        mydwg = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        mydb = mydwg.Database
        myed = mydwg.Editor
        myPEO.SetRejectMessage("You must select a BarMark." & vbCrLf)
        myPEO.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.DBText), False)
        myPer = myed.GetEntity(myPEO)
        myPS = myPer.Status
        Select Case myPS
            Case Autodesk.AutoCAD.EditorInput.PromptStatus.OK
                'MsgBox("Good job!")
                mytransman = mydwg.TransactionManager
                mytrans = mytransman.StartTransaction
                myent = myPer.ObjectId.GetObject(Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
                'MsgBox("Entity is on layer " & myent.Layer)
                'Where did he click?!
            Case Autodesk.AutoCAD.EditorInput.PromptStatus.Cancel
                MsgBox("You cancelled.")
                Exit Sub
            Case Autodesk.AutoCAD.EditorInput.PromptStatus.Error
                MsgBox("Error warning.")
                Exit Sub
            Case Else
                Exit Sub
        End Select
    End Sub

 

0 Likes
Message 5 of 6

kerry_w_brown
Advisor
Advisor
Accepted solution
Dsharifi, Why are you declaring all your variables to be type Object ??

// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 6 of 6

Anonymous
Not applicable
Accepted solution

Thanks Kerry for taking your time.

Honestly . I am not an expert person. I found subroutine in internet. Paste it in my code . Encounter error regarding declaration. I didn't know how to declared those variable. I put object and program worked.

I know if I declare them properly I reduce the memroy usage. But I don't know how. Could you Help me? But program is working right now.

Thanks again for sharing.

 

0 Likes