Hi
Any ide how I can fix this
90 will be 270 and 270 will be 90
br.Rotation = DegToRad(270) this turn the block arrow down but I need to have the arrow upp
<CommandMethod("BLOCKINS1")>
Public Sub blocktry()
' Insert.Enabled = False
Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView()
Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database
Dim ed As Editor = acDoc.Editor
Using lockmedoc As DocumentLock = acDoc.LockDocument()
Dim blockName As String = "BLOCKNAME"
Dim blockQualifiedFileName As String = "PATH TO BLOCK" & "..dwg"
Using tr As Transaction = db.TransactionManager.StartTransaction()
Try
Dim bt As BlockTable = CType(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
If Not bt.Has(blockName) Then
Dim tmpDb As Database = New Database(False, True)
tmpDb.ReadDwgFile(blockQualifiedFileName, System.IO.FileShare.Read, True, "")
Try
db.Insert(blockName, tmpDb, True)
Catch
End Try
End If
Dim ppr As PromptPointResult = ed.GetPoint(vbLf & "Specify insertion point: ")
'If ppr.Status = PromptStatus.Cancel Then 'Insert.Enabled = True
If ppr.Status <> PromptStatus.OK Then Return
Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim br As BlockReference = New BlockReference(Point3d.Origin, bt(blockName))
br.ScaleFactors = New Scale3d(1)
br.Rotation = DegToRad(30)
br.TransformBy(Matrix3d.Displacement(ppr.Value - Point3d.Origin).PreMultiplyBy(ed.CurrentUserCoordinateSystem))
btr.AppendEntity(br)
tr.AddNewlyCreatedDBObject(br, True)
ed.WriteMessage(vbLf & br.Name & " Inserted")
' Insert.Enabled = True
Catch exx As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(vbLf & exx.ToString())
'Insert.Enabled = True
End Try
tr.Commit()
tr.Dispose()
End Using
End Using
End Sub
Public Function DegToRad(angle As Double)
'convert degrees to radians
DegToRad = ((angle / 180) * Math.PI)
End Function
Public Function RadToDeg(angle As Double)
'convert radians to degrees
RadToDeg = ((angle * 180) / Math.PI)
End Function