All I can think of is that I must have copied the wrong version of the code to the forum window in 'Message 4', because I mentioned right in second paragraph of that response about adding in the code for moving the eye also, then adding in the code for updating the view afterwards. But I do not see that code in the code I posted there. I did have an iLogic rule that was working just fine in multiple tests before posting that response. I know I had at least 3 different versions of that rule copied across 3 or more different drawing documents, with slightly different code in each one, so that is probably where the mistake happened.
Anyways, I do not really see the difference between the long route process you are doing there, and simply specifying the two 3D coordinates directly. My working code just specified the 'Target' Point being at zero Z depth, then the 'Eye' at One Z depth, which seemed to work just fine. You are specifying the initial Z depth for the balloon's current location using the Z depth of the original Target. Well the Z depth of the Camera in a normal drawing is already at zero, so I just specified Zero directly there. And normal the 'Eye' Z depth of the Camera in a normal drawing is always in the positive direction, with the X & Y at the same values as the 'Target'. Then you are getting the vector from the camera's current 'Target' point to that balloon location point. Then you are copying the current 'Target' and 'Eye', and moving those two points by the vector you obtained, and using those two copied, moved points to specify the new 'Target' and 'Eye' locations. It seems like the same outcome could be achieved by just directly specifying the location you want the target to be, at the zero Z-depth, then specifying the same exact X & Y coordinates, with a positive Z depth, for the 'Eye', without having to go through all of those extra steps.
For example:
Dim oCamera As Inventor.Camera = ThisApplication.ActiveView.Camera
oCamera.Target = oTG.CreatePoint(oBalloon.Position.X, oBalloon.Position.Y, 0)
oCamera.Eye = oTG.CreatePoint(oBalloon.Position.X, oBalloon.Position.Y, 1)
oCamera.SetExtents(2, 2)
oCamera.Apply()
I know that the original 'Eye' point may not have actually been at 1 unit above zero, but I do not believe its actual height is important, as long as it is directly above the 'Target' point, because we are setting the 'Extents' right after that step, which adjusts the size of the viewing area. Instead of specifying the specific 'Eye' point, we could have also specified the oCamera.UpVector property with a simple UnitVector that is just defined using 0,0,1 inputs. In this 2D environment, that would tell it that the 'up' direction for the observer is in the positive Z direction (above the sheet).
I also created a simple, quickie iLogic rule to correct the camera issue in the first drawing document that I tested my original code in, which corrected the issues it created. It uses the same technique, and worked just fine.
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oCamera As Inventor.Camera = ThisApplication.ActiveView.Camera
oCamera.Target = oTG.CreatePoint(0, 0, 0)
oCamera.Eye = oTG.CreatePoint(0, 0, 1)
oCamera.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
oCamera.Apply()
ThisApplication.ActiveView.Fit(True)
Edit: But I guess we could just use oCamera.Target.Z instead of 0 (zero) when setting the Z-depth of the new 'Target' point, and oCamera.Eye.Z instead of 1 (one) when setting the Z-depth of the new 'Eye' point, since doing so is still simple enough, and is cleaner. And I may have been wrong about just specifying the Camera.UpVector instead of specifying the new 'Eye' point in that process. In some testing, that cause my sheet to go crooked (at an angle). To fix the angled sheet afterwards , I set the Camera.ViewOrientationType property to the kFrontViewOrientation variation, in addition to the (0,0,0) Target & (0,0,1) Eye specs, in the correction rule. That stuff is pretty tricky, and I do not usually mess with this stuff in a drawing environment, so I learned (or re-learned) some stuff while going through this, which is always a bonus.
Wesley Crihfield
(Not an Autodesk Employee)