Visual Components' Community

New Thinking for Factory Simulation
Welcome to Visual Components' Community Sign in | Help
in Search

How to aim camera to a component?

Last post pe, elo 15 2008 15:53 by Mikko Urho. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • pe, elo 15 2008 15:53

    How to aim camera to a component?

    To aim camera to your component, add the python script below to it. 

    from vcScript import *

    def OnRun():
        scale = 3.5
        view = getApplication().createView('dummy')
        if view.CameraIsOrtho:
            scale = 1404.0
        getApplication().deleteView('dummy')
        cam = getApplication().findCamera()
        for comp in getApplication().Components:
            dvec = cam.Eye - comp.WorldPositionMatrix*comp.BoundCenter
            dvec.normalize()
            dist = scale* comp.BoundDiagonal.length()
            cam.Coi = comp.WorldPositionMatrix*comp.BoundCenter
            cam.Eye = cam.Coi + dist*dvec
            delay(10)

Page 1 of 1 (1 items)