hatchelhoff Posted November 26, 2011 Share Posted November 26, 2011 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 Quote Link to comment Share on other sites More sharing options...
SEANT Posted November 26, 2011 Share Posted November 26, 2011 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. Quote Link to comment Share on other sites More sharing options...
colmguckian Posted November 26, 2011 Share Posted November 26, 2011 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.