赞
踩
c# cad二次开发 类库 CAD标注,长度标注
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using AcDotNetTool;
namespace _09标注
{
public class Class1
{
[CommandMethod(“RotatedDimDemo”)]
public void RotatedDimDemo()
{
Database db = HostApplicationServices.WorkingDatabase;
Line line = new Line(new Point3d(100, 100, 0), new Point3d(200, 200, 0));
RotatedDimension rotatedDim = new RotatedDimension();
Point3d p1 = new Point3d(100, 100, 0);
Point3d p2 = new Point3d(200, 200, 0);
rotatedDim.XLine1Point = new Point3d(100, 100, 0);
rotatedDim.XLine2Point = new Point3d(200, 200, 0);
rotatedDim.DimensionText = “<>米”;
rotatedDim.DimLinePoint = new Point3d(210, 150, 0);
rotatedDim.Rotation = p1.GetVectorTo(p2).GetAngleTo(Vector3d.XAxis);
rotatedDim.AlternatePrefix = “Prefix”;
rotatedDim.AlternateSuffix = “Suffix”;
rotatedDim.Dimasz = 20;
//rotatedDim.TextRotation = Math.PI * 0.2;
//rotatedDim.Oblique = 3;
db.AddEnityToModelSpace(rotatedDim,line);
}
[CommandMethod(“DimDemo”)]
public void DimDemo()
{
Database db = HostApplicationServices.WorkingDatabase;
//AlignedDimension aDim = new AlignedDimension();
//Point3d p1 = new Point3d(10, 10,0);
//Point3d p2 = new Point3d(20, 15, 0);
//aDim.XLine1Point = p1;
//aDim.XLine2Point = p2;
//aDim.DimLinePoint = new Point3d(10, 20, 0);
//LineAngularDimension2 lDim = new LineAngularDimension2();
//lDim.XLine1Start = new Point3d(10, 10, 0);
//lDim.XLine1End = new Point3d(20, 10, 0);
//lDim.XLine2Start = new Point3d(10, 15, 0);
//lDim.XLine2End = new Point3d(20, 30, 0);
//lDim.ArcPoint = new Point3d(5, 15, 0);
//Point3AngularDimension p3Dim = new Point3AngularDimension();
//p3Dim.CenterPoint = new Point3d(10, 10, 0);
//p3Dim.XLine1Point = new Point3d(20, 12, 0);
//p3Dim.XLine2Point = new Point3d(20, 20, 0);
//p3Dim.ArcPoint = new Point3d(25, 15, 0);
//ArcDimension arcDim = new ArcDimension(new Point3d(10,10,0),new Point3d(20,10,0),new Point3d(20,20,0),new Point3d(25,10,0),“<>”,db.Dimstyle);
// Arc arc = new Arc();
// arc.Center = new Point3d(10, 10, 0);
// arc.Radius = 50;
// arc.StartAngle = 0;
// arc.EndAngle = Math.PI * 0.25;
//ArcDimension arcDim = new ArcDimension(arc.Center,arc.StartPoint,arc.EndPoint,
// new Point3d(arc.EndPoint.X+5,arc.EndPoint.Y,arc.EndPoint.Z),“<>”,db.Dimstyle);
//RadialDimension rDim = new RadialDimension();
//rDim.Center = new Point3d(10, 10, 0);
//rDim.ChordPoint = new Point3d(20, 30, 0);
//rDim.LeaderLength = 10;
DiametricDimension dDim = new DiametricDimension();
dDim.ChordPoint = new Point3d(10, 10, 0);
dDim.FarChordPoint = new Point3d(50, 20, 0);
dDim.LeaderLength = 5;
db.AddEnityToModelSpace(dDim);
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。