找回密码 注册 QQ登录
开思网工业级高精度在线3D打印服务

iCAx开思网

CAD/CAM/CAE/设计/模具 高清视频【积分说明】如何快速获得积分?快速3D打印 手板模型CNC加工服务在线3D打印服务,上传模型,自动报价
查看: 20138|回复: 5
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
1
发表于 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空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 赞一下!赞一下!
2
发表于 2004-9-10 15:54:05 | 只看该作者

马上注册,结交更多同行朋友,交流,分享,学习。

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

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

马上注册,结交更多同行朋友,交流,分享,学习。

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

x
4
 楼主| 发表于 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 咨询|手机版|联系我们|iCAx开思网  

GMT+8, 2024-11-20 01:37 , Processed in 0.054962 second(s), 12 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

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