- 积分
- 8888
- 明经币
- 个
- 注册时间
- 2012-8-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 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;
- }
- }
- }
复制代码- [CommandMethod("FX")]
- 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[BlockTableRecord.ModelSpace], 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();
- }
- }
- }
- }
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|