C++怎么写坐标的程序?

C++怎么写坐标的程序?,第1张

描述点坐标,并将二维点坐标类的定义放入tpoint.h文件中。

tpoint.h文件内容如下:

/Tpoint类的说明部分 

class Tpoint { 

  public: 

    void SetPoint(int x,int y)     

    int Xcoord( ) { return X}

    int Ycoord( ) { return Y} 

    void Move(int xOffset,int yOffset)   

  private: 

    int X,Y } 

//Tpoint类的实现部分 

void Tpoint::SetPoint(int x,int y) {

   X=x   Y=y 

void Tpoint::Move(int xOffset,int yOffset) { 

  X+=xOffset   Y+=yOffset 

}

通过ExcelVBA编写程序。

VBA简单的说就是一种自动化语言,它可以使常用的程序自动化,可以创建自定义的解决方案。可以用Excel的宏语言来使Excel自动化运行等。

选择ExcelVBA编程的理由是因为它的计算功能非常强大,是现今任何编程计算器无法逾越的。它运用范围广,计算速度快,计算精度高,合理化显示等。

1.要改两个部份,第一步,改首行的private 为 public

2.ss_dim.Select acSelectionSetAll, , , dxf_code, dxf_value

改正:

ss_dim.SelectOnScreen dxf_code, dxf_value

这样就是输出选中对象了。

----------------------------

Public Sub GetLWPOLYLINECoordinates()

Dim ss_dim As AcadSelectionSet, ent As AcadLWPolyline

Dim dxf_code() As Integer, dxf_value() As Variant

Dim i As Long, j As Long

Dim dbCor As Variant, x As Double, y As Double, z As Double

Set ss_dim = ThisDrawing.SelectionSets.Add("ssLine1")

ReDim dxf_code(0), dxf_value(0)

dxf_code(0) = 0: dxf_value(0) = "LWPOLYLINE"

'ss_dim.Select acSelectionSetAll, , , dxf_code, dxf_value

ss_dim.SelectOnScreen dxf_code, dxf_value

Open "d:\aaaaa.txt" For Append As #1

For Each ent In ss_dim

For j = 0 To UBound(ent.Coordinates) \ 2

x = ent.Coordinates(j * 2)

y = ent.Coordinates(j * 2 + 1)

Print #1, (j)",," &x &"," &y

Next

Next

Close #1

ss_dim.Clear

ss_dim.Delete

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/11823804.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存