[求助]怎样获取CAD图形中直线的端点坐标和圆弧的圆心坐标??
我在提取CAD图形几何数据时无法得到直线的端点坐标,圆弧的圆心坐标,及起始角和终止角?(直线的长度和圆弧半径都能读取)<BR>总是报告说property let未定义 property get过程无法返回If acadObj.ObjectName = "AcDbLine" Then ' 若是直线,则可提取其参数<BR> L = acadObj.Length<BR> X1 = acadObj.StartPoint(0): Y1 = acadObj.StartPoint(1)<BR> X2 = acadObj.EndPoint(0): Y2 = acadObj.EndPoint(1)
ElseIf acadObj.ObjectName = "AcDbArc" Then ' 若是圆弧,则可提取其参数<BR> R = acadObj.Radius<BR> Cx = acadObj.Centerpoint(0): Cy = acadObj.Centerpoint(1)<BR> A1 = acadObj.StartAngle: A2 = acadObj.EndAngle
以上为部分程序代码,请大家帮忙出了什么问题? Cx = acadObj.Centerpoint(0): Cy = acadObj.Centerpoint(1)好像应该是:
Cx = acadObj.Center(0): Cy = acadObj.Center(1) 我感觉应该是变量未定义好的关系,如下:
Dim lineobj As AcadLine<BR>Dim pnt1(0 To 2) As Double<BR>pnt1(0) = lineobj.StartPoint(0)<BR>pnt1(1) = lineobj.StartPoint(1)<BR>pnt1(2) = lineobj.StartPoint(2) 简单问题总是复杂化。<BR>请注意起点、终点、圆心均返回变体。所以直接定义变体就可以了。如<BR>Dim StartPnt as Variant<BR>StartPnt = LineObj.StartPoint<BR>这样,StartPnt就是起点的坐标了,X坐标为StartPnt(0),Y坐标为StartPnt(1),Z坐标为StartPnt(2)。 谢谢楼上各位,问题解决了,嘿嘿
页:
[1]