- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
my Problem is: I wrote a workflow in .NET, that allows the user to create new pointfeatures by selecting a point from the Map. These points are meant to be midpoints of an rectangle, and the feature holds information about width and height of this rectangle. Now, I would like to preview the rectangle during the selection process by adding an rectangle with the given height an width to the cursor.
I read an blog about this and tried to use Autodesk.AUTOCAD.EditorInput.Editor.Drag - and it works fine. The rectangle is right there under my cursor. BUT: This function does what dragging often does: The moment I cancel the point selection with rectangle on my cursor, zoom of the map jumpes back to where it started. That's not what I want!
So, my question: Is there a way to stop the drag-function from jumping back on cancel OR does anyone know a better way to change the appearence of the cursor in .NET?
Thank you in advance!
Here is the code with 'Drag' i used so far:
Private Function GetPoint(pDocument As Autodesk.Map.IM.Forms.Document, pHeight As Double, pWidht As Double) As Point
Dim result As Point = Nothing
Dim vDocument As Document = Core.Application.DocumentManager.MdiActiveDocument
Dim vDataBase As Database = vDocument.Database
Dim vEditor As Editor = vDocument.Editor
Dim originPoint As Point3d = Point3d.Origin
Dim vTrans As Transaction = vDataBase.TransactionManager.StartTransaction()
Using vTrans
Dim rect = CreateDragRectangle(Point2d.Origin, pHeight, pWidht)
Dim vBlockTable As BlockTable = DirectCast(vTrans.GetObject(vDataBase.BlockTableId, OpenMode.ForRead), BlockTable)
Dim vTableRecord As BlockTableRecord = DirectCast(vTrans.GetObject(vBlockTable(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
Dim rectID = vTableRecord.AppendEntity(rect)
vTrans.AddNewlyCreatedDBObject(rect, True)
Dim psr As PromptSelectionResult = vEditor.SelectLast()
If psr.Status = PromptStatus.OK Then
Dim ppr As PromptPointResult = vEditor.Drag(psr.Value, vbLf & "Select next point: ", Function(pt As Point3d, ByRef mat As Matrix3d) As SamplerStatus
If originPoint = pt Then Return SamplerStatus.NoChange
mat = Matrix3d.Displacement(Point3d.Origin.GetVectorTo(pt))
Return SamplerStatus.OK
End Function)
If ppr.Status = PromptStatus.OK Then
result = New Point(ppr.Value.X, ppr.Value.Y)
End If
End If
End Using
Return result
End Function
Solved! Go to Solution.