Jump to content

vb.net select points


hatchelhoff

Recommended Posts

I have a code which creates a selection winow.

I need to edit the code so that the user will be allowed to pick the window points on screen instead of the points being hardcoded

any ideas?

 

 

 
Public Class Class1
<CommandMethod("selectwindowa")> _
Public Sub selectwindowa()
Dim mydwg As Document = DocumentManager.MdiActiveDocument
Dim myeditor As Editor = DocumentManager.MdiActiveDocument.Editor
Dim mypsr As PromptSelectionResult = mydwg.Editor.SelectWindow( _
New Point3d(-2, -2, 0), New Point3d(2, 2, 0))
If mypsr.Status = PromptStatus.OK Then
Using myTrans As Transaction = mydwg.TransactionManager.StartTransaction
For Each myObjectID As ObjectId In mypsr.Value.GetObjectIds
Dim myEnt As Entity = myObjectID.GetObject(OpenMode.ForRead)
MsgBox(myEnt.Layer & vbTab & myEnt.GeometricExtents.ToString)
Next
End Using
End If

Link to comment
Share on other sites

One way to get two user selected points – while giving the user some visual feedback – would be to first use a PromptPointOptions/Editor.GetPoint()/PromptPointResult interaction to get an initial point. That point can then be used with a PromptCornerOptions/ Editor.GetCorner()/PromptPointResult. Those two points can be fed to the Editor Selection method.

Link to comment
Share on other sites

Thanks SeanT I have tried you suggestion and it works.

FYI final code is below

 

 
Public Class Class1
<CommandMethod("selectwindowa")> _
Public Sub selectwindowa()
Dim mydwg As Document = DocumentManager.MdiActiveDocument
Dim myeditor As Editor = DocumentManager.MdiActiveDocument.Editor
Dim myPPR As Point3d = myeditor.GetPoint("Select 1st Point: ").Value
Dim myPPR1 As Point3d = myeditor.GetCorner("Select 2nd Point: ", myPPR).Value
Dim mypsr As PromptSelectionResult = mydwg.Editor.SelectWindow( _
myPPR, myPPR1)
If mypsr.Status = PromptStatus.OK Then
Using myTrans As Transaction = mydwg.TransactionManager.StartTransaction
For Each myObjectID As ObjectId In mypsr.Value.GetObjectIds
Dim myEnt As Entity = myObjectID.GetObject(OpenMode.ForRead)
MsgBox(myEnt.Layer & vbTab & myEnt.GeometricExtents.ToString)
Next
End Using
End If
End Sub
End Class

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...