遇到几个ReverseCurve无法换向的polyline,原因不明,请大神研究下
本帖最后由 Real_King 于 2015-8-4 16:23 编辑附件已上传,不存在重复点问题
在CASS中使用H命令换向也没有用
public static bool Clockwise(this Polyline pline)//判断Polyline是否顺时针绘制
{
Polyline pline1 = (Polyline)pline.Clone();
double bulge0 = pline1.GetBulgeAt(0);
double area0 = pline1.Area;
if (bulge0 == 0.0)
{
pline1.SetBulgeAt(0, 0.5);
double area1 = pline1.Area;
if (area1 > area0)
return false;
else
return true;
}
else
{
pline1.SetBulgeAt(0, 0);
double area1 = pline1.Area;
if (bulge0 > 0)
{
if (area1 > area0)
return true;
else
return false;
}
else
{
if (area1 > area0)
return false;
else
return true;
}
}
}
public void FX()
{
Autodesk.AutoCAD.ApplicationServices.Document DOC = AcadApp.DocumentManager.MdiActiveDocument;
Autodesk.AutoCAD.EditorInput.Editor ed = DOC.Editor; Database db = HostApplicationServices.WorkingDatabase;
PromptEntityOptions CADentity_PEO = new PromptEntityOptions("\n请准确选择PL线");
CADentity_PEO.SetRejectMessage("\n所选实体非PL线.");
CADentity_PEO.AddAllowedClass(typeof(Polyline), true);
PromptEntityResult CADentity_RST = ed.GetEntity(CADentity_PEO);
if (CADentity_RST.Status == PromptStatus.OK)
{
using (DocumentLock DOClock = DOC.LockDocument())
{
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead); //以读方式打开块表.
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt, OpenMode.ForWrite);
Polyline ZDline = CADentity_RST.ObjectId.GetObject(OpenMode.ForWrite) as Polyline; //宗地线
if (!(ZDline.Clockwise())) { ZDline.ReverseCurve(); MessageBox.Show("逆时针已成顺时针"); }
else { MessageBox.Show("SSZ"); }
trans.Commit();
}
}
}
}
页:
[1]