here is my jig rotate code
Protected Overrides Function Sampler(ByVal prompts As JigPrompts) As SamplerStatus Dim myPPR As PromptPointResult myPPR = prompts.AcquirePoint(myOpts) Dim curPos As Point3d curPos = myPPR.Value If curPos.IsEqualTo(BasePt) Then Return SamplerStatus.NoChange Else myMatrix = Geometry.Matrix3d.Displacement( _ BasePt.GetVectorTo(myPPR.Value)) Dim pt1 As New Point2d(BasePt.X, BasePt.Y) Dim pt2 As New Point2d(myPPR.Value.X, myPPR.Value.Y) BaseRo = pt1.GetVectorTo(pt2).Angle End If Return SamplerStatus.OK End If End Function Protected Overrides Function Update() As Boolean myBRef.Rotation = BaseRo Return False End Function
I always rotate the block with bottom left point as fixed point. What can I do to make the block rotate around another point? such as centre point of the block?
Thanks very much
Solved! Go to Solution.
I have updated code
Protected Overrides Function Update() As Boolean myMatrix = Geometry.Matrix3d.Rotation(BaseRo, Vector3d.ZAxis, BasePt) myBRef.TransformBy(myMatrix) ' myBRef.Rotation = BaseRo End Function
This seems to make myBRef rotate with the point I set it to. However the block is just keeping rotate even my mouse stopped. Plus the block is like a crazy wheel.
That is because you are transforming the block by the angle from the basept to the cursor, but after the first time through the sampler, the angle you need to transform by is (angle from the basept to the cursor) minus (angle that you applied the last time through the sampler).
See if you can figure that out... otherwise I have an example, but it's a bit different than yours, because I used AcquireAngle instead of AcquirePoint, and I'm setting the Position and Rotation properties of the block in the Update function, instead of using TransformBy.
So I fiddled with your jig a little, and it works if you add a class level variable for the last angle, and make your update routine like this:
Protected Overrides Function Update() As Boolean Entity.TransformBy(Matrix3d.Rotation(BaseRo - lastang, Vector3d.ZAxis, BasePt)) lastang = BaseRo End Function
BTW, "Entity" in my code above is a Friend ReadOnly Property of the class that comes along with inheriting EntityJig, no need to declare your own MyBref.
I assume you either already did figure that out, or eventually would have, but I am posting because when I ran it that way, the block was not displaying properly for some reason. I mean the jig worked as expected, but only a portion of the block was visible on screen.
When I run the same block, with the same code, through my off center rotate jig, It looks normal, so I wondered if you were seeing the same thing?
Here is my jig:
Public Class BlkRotJigOffCen Inherits EntityJig Dim NewAng, Radius, OrigRot As Double Dim CenPt As Autodesk.AutoCAD.Geometry.Point3d Dim jigopts As New JigPromptAngleOptions() Protected Overrides Function Sampler(ByVal prompts As Autodesk.AutoCAD.EditorInput.JigPrompts) As Autodesk.AutoCAD.EditorInput.SamplerStatus Dim PrAngRes As PromptDoubleResult = prompts.AcquireAngle(jigopts) If NewAng = PrAngRes.Value Then Return SamplerStatus.NoChange Else NewAng = PrAngRes.Value Return SamplerStatus.OK End If End Function Protected Overrides Function Update() As Boolean Try CType(Entity, BlockReference).Rotation = NewAng + OrigRot CType(Entity, BlockReference).Position = CenPt.Add(New Vector3d(Radius * Cos(NewAng), Radius * Sin(NewAng), 0)) Return True Catch ex As Exception Return False End Try End Function Public Sub New(ByVal bref As BlockReference, ByVal Cpt As Point3d, ByVal prompt As String) MyBase.New(bref) OrigRot = bref.Rotation CenPt = Cpt Radius = Cpt.GetVectorTo(bref.Position).Length jigopts.UserInputControls = UserInputControls.GovernedByOrthoMode jigopts.Cursor = CursorType.RubberBand jigopts.BasePoint = Cpt jigopts.UseBasePoint = True jigopts.Message = vbLf & prompt End Sub Public Function GetEntity() As Entity Return Entity End Function End Class
Thanks for your reply.
My problem solved. However your whole module doesn't work correctly. The "LastAngle" method works perfect.
I have tested both of your solution. the effects are the same.
Sorry, I saw the same effect for using your 1st method.
I am twisting your 2nd code and try to make it works my way
It works great for me, but my purpose is a little different than yours. For me it is supposed to rotate the block around a point that is outside the block by some distance. (In one case it's only about 8 inches away, in another case it's between 60 and 90 inches away).
For what it's worth, I also tested my jig using the TransformBy method in the update function, to see if that was what was causing the glitch, but it seemed to work the same (graphics-wise), but it would cause me to have to change some of my input arguments. Maybe that would make it easier for you though?
Thanks for your reply
I have tested both method carefully on my end. They both looks the same(graphic-wise) ,neither of them show block fully.
The 2nd way still not working, as the position has some problem. I do think the math is correct but just doesn't looks ok.
My block postion is the bottom left corner, I would like it to rotate around bottom its right corder. (I am sure I pass the correct point in)
Start with some of our most frequented solutions to get help installing your software.