Author Topic: Text rotate jig hiding original text.  (Read 1263 times)

0 Members and 1 Guest are viewing this topic.

SamR

  • Mosquito
  • Posts: 15
Text rotate jig hiding original text.
« on: September 13, 2011, 07:32:00 AM »
Hi.
I am using a rotate routine that currently handles blocks and mtext. I don't want to display the original block or mtext rotation when I the jig is dragging the clone.
It works that way but only for the blockreference. It's the same code but jigging mtext is shows the original as well as the rotating clone.

Can anyone suggest a correction to make? I've tried setting the entity visibility to false but the jig entity is also then hidden. Hope someone can help. Attached is the sampler and new jig parts.

Code: [Select]
Public Sub RotateEntity(ByVal objID As ObjectId, ByVal sPrompt As String)
            Dim rotationPoint As Point3d
            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
            Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
            Dim docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
            Dim trans As Transaction = db.TransactionManager.StartTransaction
            Try
                Dim ent As Entity = trans.GetObject(objID, OpenMode.ForRead)
                If TypeOf ent Is BlockReference Then
                    Dim br As BlockReference = DirectCast(trans.GetObject(objID, OpenMode.ForRead), BlockReference)
                    rotationPoint = br.Position
                ElseIf TypeOf ent Is MText Then
                    Dim mt As MText = DirectCast(trans.GetObject(objID, OpenMode.ForWrite), MText)
                    rotationPoint = mt.Location
                End If
                Dim baseAngle As Double = 0 'GetStoredRotation(obj)
                If ent IsNot Nothing Then
                    Dim ucs As Matrix3d = ed.CurrentUserCoordinateSystem ' Get the current UCS, to pass to the Jig
                    Dim jig As New RotateJig(ent, rotationPoint, baseAngle, ucs) ' Create our jig object

                    'ent.UpgradeOpen()
                    'ent.Visible = False
                    'jig.GetEntity().Visible = True

                    Dim res As PromptResult = ed.Drag(jig)
                    If res.Status = PromptStatus.OK Then
                        Dim newAngle As Double = angle 'jig.GetRotation() ' Get the overall rotation angle and dispose of the temp clone
                        Rotation = angle 'this is just to put the angle into our globally used variable
                        ed.WriteMessage(newAngle)
                        jig.GetEntity().Dispose()
                        Dim transf As Matrix3d = Matrix3d.Rotation(newAngle - baseAngle, ucs.CoordinateSystem3d.Zaxis, rotationPoint) ' Rotate the original entity
                        ent.UpgradeOpen()
                        ent.TransformBy(transf)
                    End If
                End If
                trans.Commit() : trans.Dispose()
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                MsgBox("Exception:" + ex.Message)
                trans.Abort() : trans.Dispose()
            Finally
                docLock.Dispose()
            End Try
        End Sub


« Last Edit: September 13, 2011, 07:39:23 AM by SamR »