[求助]版主帮忙调试一下曲线等分程序
<p>又要麻烦版主了;我把vb.net(vb.net代码见本论坛的我的“关于曲率问题”)改写为c#的,调试时出现cad崩溃现象,不知哪里出了问题</p><p>帮吗调试一下,主要为了学习用,谢谢!!!见附件</p><p>我的系统:cad2008,vs2008</p><p><a href="mailto:czlj2008@163.com">czlj2008@163.com</a></p><p> </p>public void Test()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
int n;
string ts = "\r请选择线条(圆弧、直线或者多义线):";
PromptEntityOptions opt = new PromptEntityOptions(ts);
//PromptEntityOptions opt = New PromptEntityOptions(ts);
//opt.SetRejectMessage();
//opt.SetRejectMessage(intCount & "只能线条");
opt.SetRejectMessage("只能线条");
opt.AddAllowedClass(typeof(Polyline), true);
opt.AddAllowedClass(typeof(Arc), true);
opt.AddAllowedClass(typeof(Line), true);
PromptEntityResult res = ed.GetEntity(opt);
if (res.Status != PromptStatus.OK)
{
ed.WriteMessage("\r用户自行退出!");
}
else
{
PromptIntegerOptions iop = new PromptIntegerOptions("指定等分段的数量:");
iop.DefaultValue = 10;
PromptIntegerResult irt = ed.GetInteger(iop);
if (irt.Status != PromptStatus.OK || irt.Value < 2)
{
return;
}
else
{
n = irt.Value;
}
using (Transaction trans = db.TransactionManager.StartTransaction())
{
Curve cv = (Curve)(trans.GetObject(res.ObjectId, OpenMode.ForWrite));
double len = cv.GetDistanceAtParameter(cv.EndParam);
int i;
for (i = 0; i <= n; i++)
{
Point3d p = cv.GetPointAtDist(i * len / n);
Vector3d kp = cv.GetFirstDerivative(cv.GetParameterAtDistance(i * len / n));
double ka = kp.GetAngleTo(Vector3d.XAxis) - Math.PI / 2;
AddText(p, "等分点" + i.ToString(), 3, ka, 1, 1);
}
trans.Commit();
}
}
}
<p><strong><font face="Verdana" color="#da2549">感谢lzh741206版主,这么晚了还帮忙调试程序,很感动!谢谢!!</font></strong></p><p><strong><font face="Verdana" color="#da2549">提前给您以及MJTD.COM的各位版主拜个早年了,祝各位工作顺利,万事如意,身体健康,合家欢乐!!!</font></strong></p> 雪山飞狐_lzh版主您好,addtext的函数已经有了,好多年没有写代码了,忘记了。谢谢!
页:
[1]