栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

autocad.net 画多段线

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

autocad.net 画多段线

using System;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.Geometry;

namespace 3dToPline

{

public class ToPline

{

[CommandMethod("ToPline")]

public void Tpolyline()

{

Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

Database db = doc.Database;

Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

Entity entity = null;

double count2d;

double count3d;

count3d = 0;

count2d = 0;

// 创建三维多段线的选择集

TypedValue[] filList = new TypedValue[1];

// 二维三维选择集过滤 "*Polyline" 为多段线,二维多段线,三维多段线 过滤。

filList[0] = new TypedValue((int)DxfCode.Start, "Polyline");

// 建立过滤器

SelectionFilter filter = new SelectionFilter(filList);

PromptSelectionResult ents = ed.SelectAll(filter); //(selops, filter);

ed.WriteMessage("n正在进行三维线转多段线.....");

if (ents.Status == PromptStatus.OK)

{

using (Transaction transaction = db.TransactionManager.StartTransaction())

{

SelectionSet SS = ents.Value;

foreach (ObjectId id in SS.GetObjectIds())

{

entity = (Entity)transaction.GetObject(id, OpenMode.ForWrite, true);

if (entity != null)

{

// ed.WriteMessage(entity.GetType().Name);

if (entity.GetType().Name == "Polyline3d")

{

count3d = count3d + 1;

Polyline3d pl3d = (Polyline3d)transaction.GetObject(id, OpenMode.ForWrite, true);

Point3dCollection pts = new Point3dCollection();

pl3d.GetStretchPoints(pts);

Point2dCollection pt2d = new Point2dCollection();

double Elv;

Elv = 0;

foreach (Point3d pt3d in pts)

{

Point2d p2d = new Point2d(pt3d.X, pt3d.Y);

Elv = Elv + pt3d.Z;

pt2d.Add(p2d);

// ed.WriteMessage("n节点坐标为{0},{1},{2}", pt3d.X, pt3d.Y, pt3d.Z);

}

Polyline pl = Polyline(pt2d, 0);

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/910641.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号