开发者

Rotate ACAD element around Z-axis

I want to rotate an ACAD (AutoCAD 2008) element around the Z-Axis. I already have the following code snippet:

Dim mm As Matrix3d = Matrix3d.Rotation(rotateDEG, HOW TO GET THE Z-AXIS HERE?, center)
For Each id As ObjectId In elements
  Dim ent As Entity = CType(tr.GetObject(id, OpenMode.ForWrite), Entity)
  ent.TransformBy(mm)
Next

I use an transformation matrix to rotate the element, but the matrix can only be build with a rotation axis. I know that I can get it from the editor of the current document. But I need it from an element in an arbitrary database, which is not always the active one!

Question: How do I get the Z-Axis for the rotation above?

Edit:

As mentioned below, I can get the Z-Axis from the current editor:

Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ucs As Matrix3d = doc.Editor.CurrentUserCoordinateSystem
Dim cs As CoordinateSystem3d = ucs.CoordinateSystem3d

But I'm not开发者_开发百科 working on the active document and the current database! I have an ObjectID from an arbitrary database which doesn't has to be the current database. And I want to get the Z-Axis from this database without using the Editor object.

Is this possible?


It should be the Z-Axis relative to the current space:

Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ucs As Matrix3d = doc.Editor.CurrentUserCoordinateSystem
Dim cs As CoordinateSystem3d = ucs.CoordinateSystem3d
Dim mm As Matrix3d = Matrix3d.Rotation(rotateDEG, cs.Zaxis, center)


You can use the two properties Database.Ucsxdir and Database.Ucsydir :

Dim zAxis As Vector3d = db.Ucsxdir.CrossProduct(db.Ucsydir)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜