如何旋转工程图的视图

原文链接:

http://adndevblog.typepad.com/manufacturing/2014/11/rotate-camera-around-any-axis-any-angle.html

大家知道,工程图里,先是生成基础视图(也就是主视图),然后产生投影视图。例如:




DrawingView.Rotation 或 DrawingView.RotateByAngle 只能让视图绕垂直纸面的轴 (也就是视点方向)旋转。如果我们要让视图绕着相机上方向旋转怎么办? 

其实,Inventor API提供了丰富的相机功能,可以轻松实现这个流程。我直接贴代码了。注意其中的解释:


Sub RotateBaseView()

   ' 预先选择好基础视图
  Dim baseView As DrawingView
  Set baseView = ThisApplication.ActiveDocument.SelectSet(1)
   
 ' 通过设置相机的UpVector = 相机视点方向来实现旋转
 ' 视点方向 = 眼睛到观察点的向量
 ' 然后计算新眼睛位置
  
  Dim c As Camera
  Set c = baseView.Camera
  
  Dim oldEye As Point
  Set oldEye = c.Eye.Copy
  
  Dim oldTarget As Point
  Set oldTarget = c.Target.Copy
  
  Dim oldViewDir As Vector
  Set oldViewDir = oldEye.VectorTo(oldTarget)
  
  Dim viewDist As Double
  viewDist = oldViewDir.Length
  
  Dim newTargetToEye As Vector
  Set newTargetToEye = c.UpVector.AsVector().Copy
  Call newTargetToEye.ScaleBy(viewDist)
  
  Call oldTarget.TranslateBy(newTargetToEye)

  c.Eye = oldTarget
  c.UpVector = oldViewDir.AsUnitVector()
  
  Call c.ApplyWithoutTransition
End Sub

 


运行结果:



推荐论坛阅读:

如何在iLogoic里使用相机

http://forums.autodesk.com/t5/inventor-customization/controlling-the-camera-using-ilogic/m-p/5033496/highlight/true



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值