using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.GraphicsInterface;
namespace TlsCad.Jigs
{
public class CircleDrawJig : DrawJig
{
private Point3d _center;
private double _radius;
private Vector3d _normal = Vector3d.ZAxis;
private static double _defaultValue = 10.0;
public CircleDrawJig(Point3d center)
{
_center = center;
}
//调用图形接口绘制图元
protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw wd)
{
SubEntityTraits set = wd.SubEntityTraits;
set.Color = 1;
set.LineWeight = LineWeight.LineWeight050;
wd.Geometry.Circle(_center,_radius,_normal);
set.Color = 2;
set.LineWeight = LineWeight.LineWeight035;
wd.Geometry.Circle(_center, _radius/2, _normal);
return true;
}
protected override SamplerStatus Sampler(JigPrompts prompts)
{
JigPromptDistanceOptions opts = new JigPromptDistanceOptions();
opts.UserInputControls =
UserInputControls.Accept3dCoordinates |
UserInputControls.NullResponseAccepted; //允许空值输入,即空格和鼠标右键
opts.BasePoint = _center;
opts.UseBasePoint = true;
opts.Message = "\n请输入半径:";
opts.Cursor = CursorType.RubberBand;
opts.DefaultValue = _defaultValue;
PromptDoubleResult res = prompts.AcquireDistance(opts);
if (res.Status == PromptStatus.OK)
{
if (_radius == res.Value)
{
return SamplerStatus.NoChange;
}
else
{
_radius = res.Value;
return SamplerStatus.OK;
}
}
else if (res.Status == PromptStatus.None)
{
//空值输入时返回
return SamplerStatus.OK;
}
else
{
return SamplerStatus.Cancel;
}
}
public Entity GetEntity()
{
return new Circle(_center, _normal, _radius);
}
public static void DoIt()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptPointResult pntRes = ed.GetPoint("\n请选择圆心");
if (pntRes.Status == PromptStatus.OK)
{
CircleDrawJig jig = new CircleDrawJig(pntRes.Value);
PromptResult jigRes = ed.Drag(jig);
if (jigRes.Status == PromptStatus.OK)
{
Database db = doc.Database;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
Entity ent = jig.GetEntity();
btr.AppendEntity(ent);
tr.AddNewlyCreatedDBObject(ent,true);
tr.Commit();
}
}
}
}
}
} 原来在这,右键取消捆饶1天,学习了 看到代码中 有 set.LineWeight = LineWeight.LineWeight035;
我尝试将其LineWeight035 改为最大的LineWeight211,发现绘制的时候,宽度没有变化。
请问,这个是什么原因呢?
谢谢哈 l510319004 发表于 2014-1-18 10:02 static/image/common/back.gif
看到代码中 有 set.LineWeight = LineWeight.LineWeight035;
我尝试将其LineWeight035 改为最大的LineWeig ...
设置LWDISPLAY系统变量为1 sieben 发表于 2014-1-18 14:28 static/image/common/back.gif
设置LWDISPLAY系统变量为1
感谢下先~
不过通过 set 命令查看
LWDISPLAY 是打开的状态的~
本帖最后由 caiqs 于 2015-8-9 19:02 编辑
public Circle myCircle;
private double cirRadius;
private Point3d cirCenter;
// 利用myCircle派生EntityJig基类
public CircleJig(Circle myCircle): base(myCircle)
{
//原来的问题出在圆未实例化,导致重绘失败
myCirRadius=new Circle(new Point3d(0,0,0),new Vector3d(0,0,1),10));
cirCenter = myCircle.Center;
cirRadius = myCircle.Radius;
}
protected override bool Update()
{
Cirlce tmpcir=(Circle)Entity;
tmpcir.Radius=cirRadius;
return true;
}
页:
1
[2]