Community
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<stuartmp74> wrote in messageHi
href="news:6089354@discussion.autodesk.com">news:6089354@discussion.autodesk.com...
All Is it possible to access the View Cube buttons through the API. I would
like to map them on to a macro run by my space
explorer.
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<Stuartmp74> wrote in messageHi
href="news:6089467@discussion.autodesk.com">news:6089467@discussion.autodesk.com...
Brian this is my code Please try running the Function 'Positive90' I am having
Rotate the Model about the horizontal Axis. I have no trouble with rotating
the model about the up vector (vertical axis) which is the 'Positive90'
function less the 'RotateMatrix90' sub. But I can't seam to Rotate the Matrix
to a position normal to the up vector so I can Rotate the Model about the
horizontal Axis Could you help me out on this one. I have actually be tiring
on and off for years to do it but I just can't seem to get my head around how
the matrix translation works. I am drawing a circle just as a reference until
I perfect the code I really work appreciate you time on this one. As I said
before. I would like to map them these functions onto run by my space Explorer
Option Explicit 'LoadBaseValues Dim oApp As Inventor.Application Dim oDoc As
Document Dim oView As View Dim oCompDef As ComponentDefinition Dim
oClientGraphics As ClientGraphics Dim oTransGeom As TransientGeometry Dim
MyCamera As Camera Dim oCurvesNode As GraphicsNode Dim oCenter As Point Dim
oNormal As UnitVector Dim oTransformMatrix As Matrix 'LoadBaseValues
'DrawCircle Dim oCircle As Inventor.Circle Dim oCircleGraphics As
CurveGraphics 'DrawCircle 'RotateCameraAbout Dim oCurveEval As CurveEvaluator
Dim dPi As Double Dim dIncrement As Double Dim dCurrent As Double Dim adEye(2)
As Double Dim adGuessparams() As Double Dim adMaxDeviations() As Double Dim
adParams(0) As Double Dim aenSolTypes() As SolutionNatureEnum Dim adPoint(2)
As Double Dim oNewEye As Point 'RotateCameraAbout Public Function Positive90()
LoadBaseValues RotateMatrix90 DrawCircle RotateCameraAbout -90 DeleteCircle
End Function Public Function Negitive90() LoadBaseValues RotateMatrix90
DrawCircle RotateCameraAbout 90 DeleteCircle End Function Sub LoadBaseValues()
Set oApp = ThisApplication Set oDoc = oApp.ActiveDocument Set oView =
oApp.ActiveView ' Set a reference to component definition of the active
document. ' This assumes that a part or assembly document is active. Set
oCompDef = oDoc.ComponentDefinition ' Check to see if the test graphics data
object already exists. ' If it does clean up by removing all associated of the
client graphics ' from the document. If it doesn't create it. On Error Resume
Next Set oClientGraphics =
oCompDef.ClientGraphicsCollection.Item("SampleGraphicsID") If Err.Number = 0
Then On Error GoTo 0 ' An existing client graphics object was successfully
obtained so clean up. oClientGraphics.Delete ' update the display to see the
results. oView.Update GoTo Continue: Else Continue: Err.Clear On Error GoTo 0
' Set a reference to the transient geometry object for user later. Set
oTransGeom = oApp.TransientGeometry 'The Camera is analogous to a real-world
camera. 'You can define its position in space, the direction in which it is
pointed and how it is tipped. 'You can also control the type of lens by
setting the perspective angle.' 'Each time the Camera property of the View is
used a new Camera object is returned.' 'The Camera object returned contains
the current camera settings of the view.' 'This is important to understand
because changing the camera may not behave as expected. 'For example the
following code will result in no changes to the view contents. Set MyCamera =
oView.Camera ' Create the ClientGraphics object. Set oClientGraphics =
oCompDef.ClientGraphicsCollection.Add("SampleGraphicsID") ' Create a new
graphics node within the client graphics objects. Set oCurvesNode =
oClientGraphics.AddNode(1) Set oCenter = MyCamera.Target Set oNormal =
MyCamera.UpVector ' Create a matrix. A new matrix is initialized with an
identity matrix. Set oTransformMatrix = oTransGeom.CreateMatrix End If End Sub
Sub DrawCircle() ' Create a transient circle object Set oCircle =
oTransGeom.CreateCircle(oCenter, oNormal,
MyCamera.Target.DistanceTo(MyCamera.Eye)) ' Create a circle graphics object
within the node. Set oCircleGraphics = oCurvesNode.AddCurveGraphics(oCircle)
ThisApplication.ActiveView.Update End Sub Sub RotateCameraAbout(ByVal dAngle
As Double) ' Get the evaluator from the circle to get points along the circle.
Set oCurveEval = oCircle.Evaluator ' Calculate the angle to step with each
increment. ' Define Pi dPi = Atn(1) * 4 dIncrement = (dPi / 180) * dAngle '
Determine the position along the circle where the eye currently is. adEye(0) =
MyCamera.Eye.x adEye(1) = MyCamera.Eye.Y adEye(2) = MyCamera.Eye.Z Call
oCurveEval.GetParamAtPoint(adEye, adGuessparams, adMaxDeviations, adParams,
aenSolTypes) ' Initialize the position using the current eye position.
dCurrent = adParams(0) ' Calculate a point on the circle using the current
parameter. adParams(0) = dCurrent + dIncrement Call
oCurveEval.GetPointAtParam(adParams, adPoint) ' Create a point that defines
the eye position. Set oNewEye =
ThisApplication.TransientGeometry.CreatePoint(adPoint(0), adPoint(1),
adPoint(2)) ' Set the eye and apply the camera. MyCamera.Eye = oNewEye
MyCamera.ApplyWithoutTransition End Sub Sub DeleteCircle() Set oClientGraphics
= oCompDef.ClientGraphicsCollection.Item("SampleGraphicsID") If Err.Number = 0
Then On Error GoTo 0 ' An existing client graphics object was successfully
obtained so clean up. oClientGraphics.Delete ' update the display to see the
results. oView.Update End If End Sub Sub RotateMatrix90() Debug.Print
MyCamera.UpVector.x Debug.Print MyCamera.UpVector.Y Debug.Print
MyCamera.UpVector.Z ' Set the rotation of the matrix for a 90 degree rotation
about the Z axis. 'I think the problem located here on the next line. ****
,oTransGeom.CreateVector(0, 1, 0) ********** ' but I don't know how to fix it.
I think the coordinates need to change as the up vector changes . ' Although I
don't know how to do it. Call oTransformMatrix.SetToRotation(3.14159265358979
/ 2, oTransGeom.CreateVector(0, 1, 0), oCenter) oNormal.TransformBy
oTransformMatrix End Sub Edited by: Stuartmp74 on Dec 13, 2008 5:09
AM
has there been any updates since this question was last asked - either in Inventor 2014 or 2015?