明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1038|回复: 1

正六形形顶点坐标

[复制链接]
发表于 2008-8-30 14:01:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2008-9-8 23:08:44 编辑
  1. Sub ls()
  2.   Dim pp(0 To 2) As Double, ppp(0 To 2) As Double
  3.   Dim objLine As AcadLine
  4.   Dim Hexagon(6) As Variant
  5.   s = 10
  6.   Hexagon(0) = Array(s / 2 * Tan(30 * 3.1415926 / 180), s / 2)
  7.   Hexagon(1) = Array(-s / 2 * Tan(30 * 3.1415926 / 180), s / 2)
  8.   Hexagon(2) = Array(-s * Tan(30 * 3.1415926 / 180), pp(1) = 0)
  9.   Hexagon(3) = Array(-s / 2 * Tan(30 * 3.1415926 / 180), -s / 2)
  10.   Hexagon(4) = Array(s / 2 * Tan(30 * 3.1415926 / 180), -s / 2)
  11.   Hexagon(5) = Array(s * Tan(30 * 3.1415926 / 180), pp(1) = 0)
  12.   Hexagon(6) = Array(s / 2 * Tan(30 * 3.1415926 / 180), s / 2)
  13.   
  14.   For ii = 0 To UBound(Hexagon) - 1
  15.     pp(0) = Hexagon(ii)(0): pp(1) = Hexagon(ii)(1)
  16.     ppp(0) = Hexagon(ii + 1)(0): ppp(1) = Hexagon(ii + 1)(1)
  17.     Set objLine = ThisDrawing.ModelSpace.AddLine(pp, ppp)
  18.   Next ii
  19. End Sub
 楼主| 发表于 2008-9-8 23:08:00 | 显示全部楼层
本帖最后由 作者 于 2008-9-8 23:09:12 编辑
  1. Sub ls()
  2.   nn = ThisDrawing.ModelSpace.Count - 1
  3.   Dim objText As AcadText, objLine As AcadLine
  4.   Dim Xls As New XlsMdbTxtData
  5.   Dim xx As Worksheet
  6.   
  7.   Set xx = Xls.ReturnxlSheet("Sheet1")
  8.   xx.Range("A:z").ClearContents
  9.   For ii = 0 To nn
  10.    Select Case ThisDrawing.ModelSpace.Item(ii).ObjectName
  11.      Case "AcDbText"
  12.        Set objText = ThisDrawing.ModelSpace.Item(ii)
  13.        aa = Split(objText.TextString, ",")
  14. '     For jj = 0 To UBound(aa)
  15.        'Set objLine = ThisDrawing.HandleToObject(aa(1))
  16.        With objLine
  17.     '     Debug.Print .Delta(0), .Delta(1)
  18.        End With
  19. '     Next jj
  20.     Case "AcDbLine"
  21.        Set objLine = ThisDrawing.ModelSpace.Item(ii)
  22.        With objLine
  23.          'Debug.Print Format(.Delta(0), "0.00"), Format(.Delta(1), "0.00"), .Angle
  24.          
  25.            xx.Cells(ii + 1, 1) = Format(.Delta(0), "0.0000")
  26.            xx.Cells(ii + 1, 2) = Format(.Delta(1), "0.0000")
  27.            xx.Cells(ii + 1, 3) = Format(.Angle, "0.0000")
  28.            gg = "Hexagon(" & ii
  29.            gg = gg & ")=array("
  30.            If Abs(Round(.Delta(0), 4)) = 5.7735 Then
  31.              gg = gg & " S/tan(" & Format(.Angle, "0.0000") & ")"
  32.            End If
  33.            gg = gg & ","
  34.            If Abs(Round(.Delta(1), 2)) = 10 Then
  35.              gg = gg & .Delta(1) / Abs(.Delta(1)) & "* S"
  36.            End If
  37.            gg = gg & ")"
  38.            Debug.Print gg
  39.          Set objText = ThisDrawing.ModelSpace.AddText(tt, .StartPoint, 0.5)
  40.        End With
  41.       
  42.   End Select
  43.   Next ii
  44.   
  45. End Sub
  46. Sub ms()
  47.   S = 20
  48.   Dim Hexagon(6) As Variant
  49.   Dim pp(0 To 2) As Double, ppp(0 To 2) As Double
  50.   Dim objLine As AcadLine
  51.   
  52.   Hexagon(0) = Array(-S / Tan(4.1888), -1 * S)
  53.   Hexagon(1) = Array(-S / Tan(5.236), -1 * S)
  54.   Hexagon(2) = Array(-2 * S / Tan(5.236), 0)
  55.   Hexagon(3) = Array(1 * S / Tan(1.0472), 1 * S)
  56.   Hexagon(4) = Array(1 * S / Tan(2.0944), 1 * S)
  57.   Hexagon(5) = Array(2 * S / Tan(2.0944), 0)
  58.   Hexagon(6) = Array(-S / Tan(4.1888), -1 * S)
  59.   For ii = 0 To 5  'Step 2
  60.     pp(0) = Hexagon(ii)(0): pp(1) = Hexagon(ii)(1)
  61.     ppp(0) = Hexagon(ii + 1)(0): ppp(1) = Hexagon(ii + 1)(1)
  62.     Set objLine = ThisDrawing.ModelSpace.AddLine(pp, ppp)
  63.   Next ii
  64. End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 07:47 , Processed in 0.160658 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表