Camera Settings within ACT Extension

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 472
100 Answers 250 Likes 100 Comments Second Anniversary
✭✭✭✭
edited June 2023 in Structures
    camera = Graphics.Camera
    camera.FocalPoint = Point([0.255500, -0.002500, 0.000000], 'm')
    camera.ViewVector = Vector3D(0.000000, 0.000000, 1.000000)
    camera.UpVector = Vector3D(0.000000, 1.000000, 0.000000)
    camera.SceneHeight = Quantity(0.327739, 'm')
    camera.SceneWidth = Quantity(0.624862, 'm')
    camera.Rotate(30, CameraAxisType.ScreenY)
    camera.Rotate(30, CameraAxisType.ScreenX)
    camera.SetFit()

The above mentioned code within ACT Console works perfectly fine, however when used within an extension, I get the following error:

File "C:\Program Files\ANSYS Inc\v201\ACT\extensions\DropTestReport\main.py", line 14, in main 
AttributeError: 'type' object has no attribute 'Camera'
Tagged:

Best Answers

  • Chemsdine CHEMAI
    Chemsdine CHEMAI Member, Employee Posts: 201
    100 Likes 100 Comments Second Anniversary Ansys Employee
    ✭✭✭✭
    Answer ✓

    Can you try to use the full path i.e: camera = ExtAPI.Graphics.Camera

Answers

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 369
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    You can also get the camera view and up vectors from a CS like this:

    **Graphics.Camera.FocalPoint = Point([0.057308251171011626, 0.049519448731302887, 0.013134819241786163], 'm')
    Graphics.Camera.ViewVector = CS.PrimaryAxisDirection
    Graphics.Camera.UpVector = CS.SecondaryAxisDirection
    
    Graphics.Camera.SceneHeight = Quantity(0.32284138156079928, 'm')
    Graphics.Camera.SceneWidth = Quantity(0.24734358049907681, 'm')**