如何旋转
本帖最后由 dpec1982 于 2015-7-17 16:06 编辑各位大侠:
环境(vs2010+cad2010)
在上图中:选择整个图形,然后按照一个基点(或者就是以左下角坐标为基点)旋转90或-90。选择所有对象的代码如下:
public static DBObjectCollection Collection()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db=doc. Database;
Editor ed=doc. Editor;
Entity entity=null;
DBObjectCollection entityCollection=new DBObjectCollection();
PromptSelectionResult ents = ed.GetSelection();
if (ents.Status == PromptStatus. OK)
{
using (Transaction transaction = db.TransactionManager.StartTransaction())
{
SelectionSet SS = ents.Value;
foreach (ObjectId id in SS.GetObjectIds())
{
entity = (Entity)transaction.GetObject(id, OpenMode.ForWrite, true);
if (entity != null)
entityCollection.Add(entity);
}
transaction.Commit();
}
}
return entityCollection;
} 所有对象的返回值是DBObjectCollection类型的,但怎么对这个类型以指定的基点进行旋转
自己顶一下吧 自己继续顶 /// <summary>
/// 指定基点与旋转角度旋转实体
/// </summary>
/// <param name="ent">实体对象</param>
/// <param name="basePt">基点</param>
/// <param name="angle">旋转角度</param>
/// <param name="Axis">旋转轴(XY平面内旋转则设为Vector3d.ZAxis)</param>
public static void Rotate(Entity ent, Point3d basePt, double angle, Vector3d Axis)
{
Matrix3d mt = Matrix3d.Rotation(angle, Axis, basePt);
ent.TransformBy(mt);
}
foreach (Entity entity in DBObjectCollection) 谢谢,非常感谢
页:
[1]