Kent,
Using an entirely different approach, the following code WILL rotate your view 90 degrees
around the X axis, but it is probably not exactly what you are looking for, nor how accurate
it proves to be over continued use.
Bob Schader
Code snippet:
'This is the number representing one degree
' in Inventor's Camera.ComputeWithMouseInput Method
' I figured this out by determining through experimentation
' that 90 degrees is represented as 10 * pi
Const rfactor As Double = 0.3490658504
Public Sub RotX90()
' This example simply rotates the view -90 degrees around x axis.
' Change the rval1 value to get other rotations
Dim aView As View
Dim camera As camera
Dim FPoint As Point2d
Dim TPoint1 As Point2d 'rotation points
Dim rval1 As Double 'rotation values
Dim yval As Double
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
rval1 = -90 * rfactor
Set FPoint = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
Set TPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(0, rval1)
Set aView = ThisApplication.ActiveView
Set camera = aView.camera
camera.ComputeWithMouseInput FPoint, TPoint1, 0, kRotateViewOperation
camera.Fit
camera.Apply
aView.Update
ThisApplication.ActiveDocument.Update
End Sub
"Kent Keller" wrote in message news:8B0DB107941C183E37AC3ED61D927BD2@in.WebX.maYIadrTaRb...
> Thanks Thilak
>
>
> I have made a dialog that lists the Eye coords, the Target Coords and the UpVector coords
> for any view that I click a button in. This has helped a lot but from what I have seen I
> am guessing there must be a way to use some sort of transformation matrix to deal with it
> or??
>
> What I am trying to do in one case is to mimic the way the view reacts if you click on a
> edge of the Glass Box. The right and left code below works if you are looking at the XY
> plane, but any other plane and it doesn't The up and down code has some problems I
> haven't figured out yet, but I would guess if I found the problem it would also only be
> valid when viewing from one direction. What I am trying to do there is to rotate 90 on
> the viewing X axis similar to in AutoCAD... UCS, X, 90, Plan
>
> Often times after the line ocamera.UpVector = oNewUp the two sets of values don't match??
>
> So is there a matrix I need to use, or do I have to try to map out every possibility for
> the ortho views or ??
>
> Thanks for any help.
>
> Dim oView As View
> Set oView = oApp.ActiveView
> Dim ocamera As Camera
> Set ocamera = oView.Camera
> Dim oVect As UnitVector
> Set oVect = ocamera.UpVector
>
> Select Case Index
> Case 0 ' Spin Right
> Set oNewUp = oApp.TransientGeometry.CreateUnitVector( _
> ocamera.UpVector.Y, -ocamera.UpVector.X, ocamera.UpVector.Z)
>
> Case 1 ' Spin Left
> Set oNewUp = oApp.TransientGeometry.CreateUnitVector( _
> -ocamera.UpVector.Y, ocamera.UpVector.X, ocamera.UpVector.Z)
>
> Case 2 ' Up
> Set oNewUp = oApp.TransientGeometry.CreateUnitVector( _
> ocamera.UpVector.X, ocamera.UpVector.Z, -ocamera.UpVector.Y)
>
> Case 3 ' Down
> Set oNewUp = oApp.TransientGeometry.CreateUnitVector( _
> ocamera.UpVector.X, -ocamera.UpVector.Z, ocamera.UpVector.Y)
>
> Case Else
> Exit Sub
>
> End Select
>
> ocamera.UpVector = oNewUp
> ocamera.Apply
>
>
>
>
> --
> Kent
> Assistant Moderator
> Autodesk Discussion Forum Moderator Program
>
>
>
> "raot" wrote in message
> news:E1C3EC0BD2D49D424D2E90301AD9EF9C@in.WebX.maYIadrTaRb...
> > Hi Kent,
> >
> > Sometime back I began writing an article on handling views in Inventor
> > through API but stalled it for
> > a while as I got sucked into other activities.
> >
> > UpVector is the vector that is vertical or rather that would be parallel to
> > the left frame of the document window.
> >
> > To understand it better:
> > 1. Open any part file and switch to any isometric view.
> >
> > 2. Use the following code to change the upvector:
> > Sub test()
> > Dim ocam As Camera
> > Set ocam = ThisDocument.Views(1).Camera
> >
> > Dim ovec As UnitVector
> > Set ovec = ThisApplication.TransientGeometry.CreateUnitVector(0, 0, 1)
> >
> > ocam.UpVector = ovec
> >
> > ocam.Apply
> >
> > End Sub
> >
> > 3. The above code makes the Z axis (Blue) to be pointing vertically upwards.
> > Similarly if you input (1,0,0) then X axis (Red) will be pointing vertically
> > upwards.
> >
> > You may try with various inputs.....such as (1,1,0)
> >
> > cheers,
> > thilak
> >
> >
> > "Kent Keller" wrote in message
> > news:736D07C3600E36A7BF882B5426497DDD@in.WebX.maYIadrTaRb...
> > > I'm Back 8^)
> > >
> > > I tried the basic code below and it works for one Revolution, but
> > then not the next.
> > > If you manually rotate the view another 90 then the code works again. I
> > am guessing
> > > what is happening is the UnitVector is seeing that it is going to be a
> > impossible
> > > coordinate so it errors. I have tried setting the coordinates in a
> > normal Vector first,
> > > and then using it to supply the UnitVector with them all at once, but it
> > says it is a type
> > > mismatch. I also tried making a dummy array and supplying that to the
> > UnitVector but that
> > > didn't work either.
> > >
> > > So I am back to how do you rotate a view90º
> > >
> > > Dim oUp As UnitVector
> > > Set oUp = ocamera.UpVector
> > > oUp.X = ocamera.UpVector.Y
> > > oUp.Y = -ocamera.UpVector.X
> > > oUp.Z = ocamera.UpVector.Z
> > >
> > > ocamera.UpVector = oUp
> > > ocamera.Apply
> > >
> > > --
> > > Kent
> > > Assistant Moderator
> > > Autodesk Discussion Forum Moderator Program
> > >
> > >
> > >
> > >
> >
> >
>
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.465 / Virus Database: 263 - Release Date: 3/25/2003