Posts: 17
Registered: ‎01-27-2005
Message 1 of 2 (188 Views)

Block Rotation

188 Views, 1 Replies
02-13-2006 03:10 PM
Ok, I've seen many post on how to insert blocks. Is there a way to insert the block and the rotate it like the native autocad command?(it actually shows the block when you insert it and while rrotating it)

Here is the code I'm testing (a lot of it is directly from the examples) you can see that in order to rotate the block I use the getangle from the editor, but this just allows me to select random points for the angle. In VBA a blockreference has the rotate function in which you can specify the base point at least. Anything similar in .net. Or simply put how to rotate an object by selecting it??

Public Sub bTEST()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim tr As Transaction = doc.TransactionManager.StartTransaction
Dim PromtOptions As PromptPointOptions = New PromptPointOptions("Select point of insertion: ")
Dim InsertPoint As PromptPointResult = ed.GetPoint(PromtOptions)
Dim AnglePromt As PromptAngleOptions = New PromptAngleOptions("Angle of Block")
Dim Angle As PromptDoubleResult = ed.GetAngle(AnglePromt)

Dim dwgName As String = HostApplicationServices.Current.FindFile("C:\Blocks\JBOX.dwg", Application.DocumentManager.MdiActiveDocument.Database, FindFileHint.Default)
Dim db As Database = New Database(False, False)
db.ReadDwgFile(dwgName, IO.FileShare.Read, True, "")
Dim NewBlkId As ObjectId
NewBlkId = doc.Database.Insert(dwgName, db, False)
Dim bt As BlockTable = tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead, True)
Dim btr As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite, True)
Dim bref As BlockReference = New BlockReference(InsertPoint.Value, NewBlkId)
tr.AddNewlyCreatedDBObject(bref, True)
bref.Rotation = Angle.Value
Dim Scale As Scale3d = New Scale3d(50, 50, 1)
bref.ScaleFactors = Scale
bref.LayerId = MyLayer()
db = Nothing

Catch ex As Exception
End Try

End Sub
Distinguished Contributor
Posts: 1,691
Registered: ‎12-15-2003
Message 2 of 2 (188 Views)

Re: Block Rotation

02-13-2006 06:01 PM in reply to: flongsworth
The following post in the AUGI forums has a Jigging example that should head you in the right direction.


Regards - Nathan
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.