.NET

Reply
Contributor
flongsworth
Posts: 17
Registered: ‎01-27-2005
Message 1 of 2 (182 Views)

Block Rotation

182 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
Try
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)
btr.AppendEntity(bref)
tr.AddNewlyCreatedDBObject(bref, True)
bref.Rotation = Angle.Value
bref.TransformBy(ed.CurrentUserCoordinateSystem)
Dim Scale As Scale3d = New Scale3d(50, 50, 1)
bref.ScaleFactors = Scale
bref.LayerId = MyLayer()
db = Nothing
tr.Commit()

Catch ex As Exception
ed.WriteMessage(ex.ToString)
Finally
tr.Dispose()
End Try


End Sub
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 2 of 2 (182 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.

http://forums.augi.com/showthread.php?t=33081

Regards - Nathan

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community