Ok. I was excited when I found this post a few days ago since I had spent a day looking and not finding much. Since then I have found a few posts on how to create a block rotation jig in C#, but nothing in VB, so I've learned how to translate (kind of).
I came up with the following...
Code:
Class rotateBlockJig
Inherits EntityJig
Sub New(ByVal ent As Entity)
'mybase.new must be called because the base class entity jig does not have an accesible sub new that can be accesses with no arguments
MyBase.New(ent)
End Sub
Private lastMousePosition As Point3d = New Point3d()
Property jiggedBlockReference() As BlockReference
Get
Return Me.Entity
End Get
Set(ByVal value As BlockReference)
End Set
End Property
Property currentPosition() As Point3d
Get
Return jiggedBlockReference.position
End Get
Set(ByVal value As Point3d)
End Set
End Property
Protected Overrides Function Sampler(ByVal prompts As Autodesk.AutoCAD.EditorInput.JigPrompts) As Autodesk.AutoCAD.EditorInput.SamplerStatus
Dim jigOpt As JigPromptPointOptions = New JigPromptPointOptions("Select Rotation :")
jigOpt.UserInputControls = UserInputControls.Accept3dCoordinates
jigOpt.UserInputControls = UserInputControls.GovernedByOrthoMode
Dim res As PromptPointResult = prompts.AcquirePoint(jigOpt)
If res.Status <> PromptStatus.OK Then
Return SamplerStatus.Cancel
End If
If (res.Value.IsEqualTo(currentPosition, New Tolerance(0.1, 0.1))) Then
Return SamplerStatus.NoChange
End If
lastMousePosition = res.Value
Return SamplerStatus.OK
End Function
Protected Overrides Function Update() As Boolean
Dim oldPosition As Point2d = New Point2d(currentPosition.X, currentPosition.Y)
Dim newPosition As Point2d = New Point2d(lastMousePosition.x, lastMousePosition.Y)
jiggedBlockReference.Rotation = oldPosition.GetVectorTo(newPosition).Angle - Math.PI / 2
'code for use with dynamic blocks
For Each prop As DynamicBlockReferenceProperty In jiggedBlockReference.DynamicBlockReferencePropertyCollection
If prop.PropertyName.ToUpper = "LENGTH" Then
prop.Value = oldPosition.GetDistanceTo(newPosition)
End If
Next
Return True
End Function
End Class
This works well except that I can't constrain the rotation with ORTHO. I've got the "jigOpt.UserInputControls = UserInputControls.GovernedByOrthoMode" line in there, but it's not working.
To be frank I'm a newbie at .NET and programming in general. I've spent the last year learning and working with VBA and now we're moving to 64bit, so the .NET conversion was inevitable. I understand the basics of what's going on with the jig, but I just don't understand where the ORTHO comes into play.
For us newbies any explanation would be greatly appreciated.
Thanks,
JL