乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 73|回复: 3

VBA中如何获得CAD modelspace中坐标

[复制链接]

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
6
发表于 2009-6-11 20:40:00 | 显示全部楼层 |阅读模式
Hi every master,
我是VBA编程新手,现有一问题要向高手请教,VBA中如何获得 modelspace中所有circle和块的中心坐标,
我试了很久,都没实现,不知道可以用什么方法实现?thanks.

回复

使用道具 举报

158

主题

2315

帖子

10

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2951
发表于 2009-6-11 21:24:00 | 显示全部楼层
使用选择集,选择圆和块。
如果是圆,则可直接读到圆心。
如果是块,则使用GetBoundingBox来取得对角点后计算中心点。
回复

使用道具 举报

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
6
发表于 2009-6-13 11:16:00 | 显示全部楼层
谢谢版主的解答 ,
只不过我还是不知道用哪个命令来获取圆心,我的目的是这样的,我想遍历图形中所有的circle and block and polyline的中心位置,然后把它们中心坐标写到一个文本文件中去,不知道要用到哪几个command来实现,我买了版主二次开发的一本书,可书上也没有这方面的教材,还望版主不吝赐教。Thanks.
回复

使用道具 举报

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2009-6-13 17:47:00 | 显示全部楼层
书上没有的找帮助
  1. Sub Example_Center()
  2.    
  3.     Dim circObj As AcadCircle
  4.     Dim currCenterPt(0 To 2) As Double
  5.     Dim newCenterPt(0 To 2) As Double
  6.     Dim radius As Double
  7.    
  8.     ' Define the initial center point and radius for the circle
  9.     currCenterPt(0) = 20: currCenterPt(1) = 30: currCenterPt(2) = 0
  10.     radius = 3
  11.    
  12.     ' Create the circle in model space
  13.     Set circObj = ThisDrawing.ModelSpace.AddCircle(currCenterPt, radius)
  14.     ZoomAll
  15.     MsgBox "The center point of the circle is " & currCenterPt(0) & ", " & currCenterPt(1) & ", " & currCenterPt(2), vbInformation, "Center Example"
  16.     ' Change the center point of the circle
  17.     newCenterPt(0) = 25: newCenterPt(1) = 25: newCenterPt(2) = 0
  18.     circObj.center = newCenterPt
  19.     circObj.Update
  20.    
  21.     ' Query the results of the new center position
  22.     ' Notice the output from the center property is a variant
  23.     Dim centerPoint As Variant
  24.     centerPoint = circObj.center
  25.     MsgBox "The center point of the circle is " & centerPoint(0) & ", " & centerPoint(1) & ", " & centerPoint(2), vbInformation, "Center Example"
  26. End Sub
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-1 23:45 , Processed in 0.308669 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表