.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autocad 2012 - TransformBy 3D rotation of polyline

1 REPLY 1
Reply
Message 1 of 2
Seegee
337 Views, 1 Reply

Autocad 2012 - TransformBy 3D rotation of polyline

Hey guys, what I am trying to do is 3DRotate a polyline to "stand it up."

 

I am using the TransformBy method to do this. The problem is, I put 90 degrees as the angle parameter (to rotate it 90 degrees and stand it up) but It is not rotating the full 90 degrees. Here is a picture of the outcome: http://snag.gy/wXNe6.jpg . As you can see, the piece is still a bit slanted, and not fully stood up.

 

Here is my code:

 

  <CommandMethod("multirotate")> _
        Public Shared Sub rectangles()
            Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim acCurDb As Database = acDoc.Database
            Dim acEd As Editor = acDoc.Editor

            Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()

                Dim acBlkTbl As BlockTable
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, _
                                             OpenMode.ForRead)


                Dim acBlkTblRec As BlockTableRecord
                acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                                OpenMode.ForWrite)


                Dim opts As New PromptEntityOptions(vbLf & "Select an entity :")
                opts.SetRejectMessage(vbLf & "Must be a Polyline...")
                opts.AddAllowedClass(GetType(Polyline), True)

                Dim res As PromptEntityResult = acEd.GetEntity(opts)
                MsgBox(acTrans.GetObject(res.ObjectId, OpenMode.ForRead).GetType().ToString())
                Dim acBR As Polyline = acTrans.GetObject(res.ObjectId, OpenMode.ForWrite)

                Dim curUCSMatrix As Matrix3d = acDoc.Editor.CurrentUserCoordinateSystem
                Dim curUCS As CoordinateSystem3d = curUCSMatrix.CoordinateSystem3d
                acBR.TransformBy(Matrix3d.Rotation(90, curUCS.Yaxis, acBR.StartPoint))

                acTrans.Commit()
            End Using

        End Sub

 

 

 

 

1 REPLY 1
Message 2 of 2
_gile
in reply to: Seegee

Hi,

 

The rotation angle have to be expressed in radians: Math.PI / 2.0



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost