|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
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 |
|