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

Block Rotation

1 REPLY 1
Reply
Message 1 of 2
flongsworth
491 Views, 1 Reply

Block Rotation

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
1 REPLY 1
Message 2 of 2
NathTay
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

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