I need to rotate UCS as "(command "_.UCS" "_Z" degree)" in .net..
Please help me
Solved! Go to Solution.
Solved by Giri_kani. Go to Solution.
Solved by Ajilal.Vijayan. Go to Solution.
After changing UCS Z , i want to place some entities like block,line,polyline and so on..
But those entities are not rotating correctly based on UCS Z axis..
How to place an entity after changing UCS in .net?
Transform all the entities points to draw in the new coordinate system.
Use TransformBy
'' Create a line that starts at 5,5 and ends at 12,3 Dim acLine As Line = New Line(New Point3d(5, 5, 0).TransformBy(Rot), _ New Point3d(12, 3, 0).TransformBy(Rot))
Have a look at this example also.
Public Class UCS <CommandMethod("ROTZ")> _ Public Sub ShowHatchDialog() Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim db As Database = acDoc.Database Dim ucs As Matrix3d = acDoc.Editor.CurrentUserCoordinateSystem Dim cs As CoordinateSystem3d = ucs.CoordinateSystem3d Dim Rot As Matrix3d = Matrix3d.Rotation(0.785398163, cs.Zaxis, New Point3d(0, 0, 0)) acDoc.Editor.CurrentUserCoordinateSystem = Rot acDoc.Editor.Regen() '' Start a transaction Using acTrans As Transaction = db.TransactionManager.StartTransaction() '' Open the Block table for read Dim acBlkTbl As BlockTable acBlkTbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead) '' Open the Block table record Model space for write Dim acBlkTblRec As BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _ OpenMode.ForWrite) '' Create a line that starts at 5,5 and ends at 12,3 Dim acLine As Line = New Line(New Point3d(5, 5, 0).TransformBy(Rot), _ New Point3d(12, 3, 0).TransformBy(Rot)) '' Add the new object to the block table record and the transaction acBlkTblRec.AppendEntity(acLine) acTrans.AddNewlyCreatedDBObject(acLine, True) '' Save the new object to the database acTrans.Commit() End Using End Sub End Class
This is working fine for Line,Polyline,Solid...But for block insertion,it is not working..
I need to change the block based on current UCS with rotation point..that is i have rotation point..
Example:
BlockReference bref = new BlockReference(insertion_point.TransformBy(Rot), blkid);
bref.Rotation = DegToRad(270);
The Above code is not working correctly...
Hi,
For block reference try the following.
For block insertion point dont use TransformBy.
Then add.
bref.TransformBy(Rot)
bref.Rotation = DegToRad(270);
See the sample code inere.
Public Class UCS
<CommandMethod("ROTZ")> _
Public Sub ShowHatchDialog()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = acDoc.Database
Dim ucs As Matrix3d = acDoc.Editor.CurrentUserCoordinateSystem
Dim cs As CoordinateSystem3d = ucs.CoordinateSystem3d
Dim Rot As Matrix3d = Matrix3d.Rotation(0.785398163, cs.Zaxis, New Point3d(0, 0, 0))
acDoc.Editor.CurrentUserCoordinateSystem = Rot
acDoc.Editor.Regen()
Dim strBlockName As String = "MyBlock"
Using tr As Transaction = db.TransactionManager.StartTransaction
Dim bt As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead)
Dim btrMS As BlockTableRecord = bt(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForRead)
If Not bt.Has(strBlockName) Then
Exit Sub
Else
btrMS.UpgradeOpen()
End If
Dim btr As BlockTableRecord = bt(strBlockName).GetObject(OpenMode.ForRead)
Dim bref As New BlockReference(New Point3d(5, 5, 0), btr.ObjectId)
bref.TransformBy(Rot)
bref.Rotation = 4.71238898
btrMS.AppendEntity(bref)
tr.AddNewlyCreatedDBObject(bref, True)
tr.Commit()
End Using
End Sub
End Class
(command "_.AREA" "_E" (entlast))
I want to do the above mentioned process in .net....
Please guide me how to do?