- 积分
- 217
- 明经币
- 个
- 注册时间
- 2014-10-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
这是我写的?在屏幕上指定旋转角度不会了(现在是错误的) 请指点下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.GraphicsInterface;
namespace XXXX
{
public class EntJip:DrawJig
{
public BlockReference m_blo;
private Point3d m_pt1, m_pt2;
public EntJip(Point3d pt1, BlockReference blo)
{
m_pt1 = pt1;//块的插入点
m_blo = blo;
}
protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
{
draw.Geometry.Draw(m_blo);
return true;
}
protected override SamplerStatus Sampler(JigPrompts prompts)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
//Matrix3d mt = ed.CurrentUserCoordinateSystem;
JigPromptPointOptions optJigPoint = new JigPromptPointOptions("\n请制定插入角度:");
optJigPoint.Cursor = CursorType.NoSpecialCursor;
optJigPoint.UserInputControls = UserInputControls.NoZeroResponseAccepted | UserInputControls.NoNegativeResponseAccepted;
//optJigPoint.BasePoint = m_pt1.TransformBy(mt);//指定块参照的插入点
optJigPoint.BasePoint = m_pt1;
optJigPoint.UseBasePoint = true;
//获得点
PromptPointResult resJigPoint = prompts.AcquirePoint(optJigPoint);
Point3d tempt = resJigPoint.Value;
//拖拽取消
if (resJigPoint.Status == PromptStatus.Cancel)
{
return SamplerStatus.Cancel;
}
//进行拖拽
if (m_pt2 != tempt)
{
m_pt2 = tempt;
m_blo.Position = m_pt1;
double rotationAngle = m_pt2.AngleFromXAxis(m_pt1);
m_blo.TransformBy(Matrix3d.Scaling(1, m_pt1) * Matrix3d.Rotation(rotationAngle-rotationAngle, Vector3d.ZAxis, m_pt1));
return SamplerStatus.OK;
}
else
{
return SamplerStatus.NoChange;
}
}
}
}
|
|