Форум » Программирование в Autodesk Inventor|VBA, iPart, iFeature » Как программно определить угол поворота составной части сборки? » Ответить

Как программно определить угол поворота составной части сборки?

brigval: Как программно определить угол поворота составной части сборки?

Ответов - 3

Ab: ' Set a reference to the assembly component definintion. Dim oAsmCompDef As AssemblyComponentDefinition Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition ' Get an occurrence from the select set. On Error Resume Next Dim oOccurrence As ComponentOccurrence Set oOccurrence = ThisApplication.ActiveDocument.SelectSet.Item(1) If Err Then MsgBox "An occurrence must be selected." Exit Sub End If On Error GoTo 0 ' Get the current transformation matrix from the occurrence. Dim oTransform As Matrix Set oTransform = oOccurrence.Transformation Dim oOrigin As Point Dim oXAxis As Vector Dim oYAxis As Vector Dim oZAxis As Vector Call oTransform.GetCoordinateSystem(oOrigin, oXAxis, oYAxis, oZAxis) Debug.Print "The coordinate system of part " & oOccurrence.name Debug.Print " Origin: " & oOrigin.X & ", " & oOrigin.Y & ", " & oOrigin.Z Debug.Print " X-Axis: " & oXAxis.X & ", " & oXAxis.Y & ", " & oXAxis.Z Debug.Print " Y-Axis: " & oYAxis.X & ", " & oYAxis.Y & ", " & oYAxis.Z Debug.Print " Z-Axis: " & oZAxis.X & ", " & oZAxis.Y & ", " & oZAxis.Z 'now, get back the rotation angle about the above specified rotation vector (from the matrix) Dim oTG As TransientGeometry Set oTG = ThisApplication.TransientGeometry Dim vZ As Vector Dim vX As Vector Dim vY As Vector Set vZ = oTG.CreateVector(0, 0, 1) Set vX = oTG.CreateVector(1, 0, 0) Set vY = oTG.CreateVector(0, 1, 0) Debug.Print " Angles: X " & CStr(vX.AngleTo(oXAxis) * 180 / 3.1415926535) & " Y " & CStr(vY.AngleTo(oYAxis) * 180 / 3.1415926535) & " Z " & CStr(vZ.AngleTo(oZAxis) * 180 / 3.1415926535)

brigval: Ab Спасибо. Такого примера в хелпе 11-го я не нашел. Если я правильно понял, то чтоб определить угол вращения вокруг оси Z надо найти угол поворота вектора oXAxis относительно вектора vX?

Ab: Вокруг оси Z - угол между vZ и oZAxis, вокруг Y - vY и oYAxis, вокруг Z - vZ и oZAxis. Смотрите, проверяйте. А вот, что говорят наши заокеанские друзья: http://discussion.autodesk.com/adskcsp/thread.jspa?messageID=5115290 и http://discussion.autodesk.com/adskcsp/thread.jspa?messageID=5244568




полная версия страницы