获取 Curve 坐标方法
///
/// 获取线对象上的坐标集和突度集
///
/// Curve对象
/// 坐标集
/// 突度集
public static void GetPolylinePoint3dsAndBulge(this Curve curve,ref Point3dCollection Point3dColl,ref DoubleCollection Bulges)
{
try
{
Point3dColl.Clear();
Bulges.Clear();
switch (curve.GetEntityType())
{
case "Polyline":
Polyline polylineObject = (Polyline)curve;
int NumberOfVertices = polylineObject.NumberOfVertices;
for (int i = 0; i
/// 返回CAD对象类型
///
/// 对象名称
///
public static string GetEntityType(this Entity ent)
{
try
{
return ent.GetType().ToString().Replace("Autodesk..DatabaseServices.", "");
}
catch
{
return "";
}
} ///
/// 获取ObjectId的Entity
///
/// 对象ID
/// 事务处理对象
/// 读取模式
///
public static DBObject GetEntity(this ObjectId ObjId, Transaction trans, OpenMode openmode, bool openErased, bool forceOpenOnLockeDLayer)
{
try
{
return (DBObject)trans.GetObject(ObjId, openmode, openErased, forceOpenOnLockeDLayer);
}
catch (Exception)
{
return null;
}
}
///后面部分是抄的,原来自己写的方向有时候有问题
///忘记哪里了,急用没留地址,找不到了
///希望这位朋友不要介意啊,哈哈
//计算凸起值
public static double GetBulge(this Arc A, bool SEbo)
{
double Bulge = 0;
double L1 = GetDistance(A.StartPoint, A.EndPoint);
double Angle = A.EndAngle - A.StartAngle;
if (AngleMath.PI)
{
//判断是否大于180度
Bulge = A.Radius + Math.Sqrt(Math.Pow(A.Radius, 2) - Math.Pow((L1 / 2), 2));
//计算凸起值
}
else
{
Bulge = A.Radius - Math.Sqrt(Math.Pow(A.Radius, 2) - Math.Pow((L1 / 2), 2));
//计算凸起值
}
Point3d Pt2 = A.GetPointAtDist(A.GetDistanceAtParameter(A.EndParam) / 2);
//取中点
double TempDouble = 0;
if (SEbo == true)
{
//判断方向
TempDouble = PtSide(A.StartPoint, Pt2, A.EndPoint);
}
else
{
TempDouble = PtSide(A.EndPoint, Pt2, A.StartPoint);
}
if (TempDouble > 0)
{
//判断圆弧是凸向哪边
return -Bulge / (L1 / 2);
}
else
{
return Bulge / (L1 / 2);
}
}
//判断圆弧是凸向哪边
private static double PtSide(Point3d pt1, Point3d pt2, Point3d pt3)
{
Vector3d vect1 = pt1.GetVectorTo(pt2);
Vector3d vect2 = pt1.GetVectorTo(pt3);
return vect2.X * vect1.Y - vect1.X * vect2.Y;
}
扩展方法需要放在静态类里面
小狼兄发贴啦
大家快来支持啊
好东西,支持下,收藏啦
收藏一下先。以后有用的时候来再来
谢谢。
我这几一正在看ployline
再次谢谢!!
终于找到了。支持下
页:
[1]