iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 27820|回复: 5
打印 上一主题 下一主题

請問如何用catia的VBA量測角度?

[复制链接]
跳转到指定楼层
楼主
发表于 2004-9-9 22:06:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
我想要量測兩線段的夾角度數不知要如何寫
  
我附上程式碼希望能有高手幫我看一下
  
我是在造型模組下做3點兩直線然後要量這兩直線的夾角
  
以下是程式碼
  
Sub CATMain()
********************以下畫3點兩直線
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
  
Dim part1 As Part
Set part1 = partDocument1.Part
  
Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory
  
Dim hybridShapePointCoord1 As HybridShapePointCoord
Set hybridShapePointCoord1 = hybridShapeFactory1.AddNewPointCoord(0#, 0#, 100#)
  
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
  
Dim body1 As Body
Set body1 = bodies1.Item("artBody")
  
body1.InsertHybridShape hybridShapePointCoord1
  
part1.InWorkObject = hybridShapePointCoord1
  
part1.Update
  
Dim hybridShapePointCoord2 As HybridShapePointCoord
Set hybridShapePointCoord2 = hybridShapeFactory1.AddNewPointCoord(0#, 100#, 100#)
  
body1.InsertHybridShape hybridShapePointCoord2
  
part1.InWorkObject = hybridShapePointCoord2
  
part1.Update
  
Dim hybridShapePointCoord3 As HybridShapePointCoord
Set hybridShapePointCoord3 = hybridShapeFactory1.AddNewPointCoord(100#, 100#, 100#)
  
body1.InsertHybridShape hybridShapePointCoord3
  
part1.InWorkObject = hybridShapePointCoord3
  
part1.Update
  
Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromObject(hybridShapePointCoord1)
  
Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointCoord3)
  
Dim hybridShapeLinePtPt1 As HybridShapeLinePtPt
Set hybridShapeLinePtPt1 = hybridShapeFactory1.AddNewLinePtPt(reference1, reference2)
  
body1.InsertHybridShape hybridShapeLinePtPt1
  
part1.InWorkObject = hybridShapeLinePtPt1
  
part1.Update
  
Dim reference3 As Reference
Set reference3 = part1.CreateReferenceFromObject(hybridShapePointCoord1)
  
Dim reference4 As Reference
Set reference4 = part1.CreateReferenceFromObject(hybridShapePointCoord2)
  
Dim hybridShapeLinePtPt2 As HybridShapeLinePtPt
Set hybridShapeLinePtPt2 = hybridShapeFactory1.AddNewLinePtPt(reference3, reference4)
  
body1.InsertHybridShape hybridShapeLinePtPt2
  
part1.InWorkObject = hybridShapeLinePtPt2
  
part1.Update
******************以下量測兩線段夾角
Dim reference5 As Reference
Set reference5 = part1.CreateReferenceFromObject(hybridShapeLinePtPt1)
Dim reference6 As Reference
Set reference6 = part1.CreateReferenceFromObject(hybridShapeLinePtPt2)
dim reference9 AS string
set reference9=CATIA.GetWorkbenchId
Dim TheSPAWorkbench As Workbench
TheSPAWorkbench = partDocument1.GetWorkbench("reference9")
Dim TheMeasurable As Measurable
Set TheMeasurable = TheSPAWorkbench.Measurable(reference5)
Dim Angle As Double
Angle = TheMeasurable.GetAngleBetween(reference6)
  
MsgBox "CATShapeDesignWorkbench=" & CStr(Angle)
  
End Sub
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
发表于 2004-9-10 15:54:05 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
板凳
 楼主| 发表于 2004-9-10 22:42:42 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
地板
 楼主| 发表于 2004-9-10 23:43:48 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
5
发表于 2007-4-1 20:10:28 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
6
发表于 2012-5-18 09:14:13 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

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

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-11-15 04:29 , Processed in 0.020091 second(s), 7 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

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