Page 1 of 1

Create Viewport camera using Python Plugin

Posted: Tue Nov 14, 2023 5:26 pm
by mariolino
I am a beginner in Python programming, I am trying to create a new "camera viewport" with the following code, however I am having difficulty finding a way to assign the created viewport name, however I can't enter the X1, Y2, Z3 angles.

If anyone can help me I thank you very much.

CC & Python together are amazing !!! Congratulations !!!

Code: Select all

--------------------------------------------------------------------------------
import pycc
from cccorelib import CCVector3d
new_viewport_object = pycc.cc2DViewportObject()
new_viewport_parameters = new_viewport_object.getParameters()
new_camera_center = CCVector3d(2023, 301, 610)
auto_update_focal = False
new_focal_distance = 600.5
new_pivot_point = CCVector3d(2028, 305, 485)
new_viewport_parameters.setCameraCenter(new_camera_center, auto_update_focal)
new_viewport_parameters.setPivotPoint(new_pivot_point, auto_update_focal)
new_viewport_parameters.computeDistanceToHalfWidthRation()
new_viewport_parameters.computeDistanceToWidthRatio()
new_viewport_parameters.computeViewMatrix()
new_viewport_parameters.computeWidthAtFocalDist()
new_viewport_object.setParameters(new_viewport_parameters)
pycc.GetInstance().addToDB(new_viewport_object)
print("Camera Center:", new_viewport_parameters.getCameraCenter())
print("Focal Distance:", new_viewport_parameters.getFocalDistance())
print("Pivot Point:", new_viewport_parameters.getPivotPoint())
print("Distance To Half Width Ratio:", new_viewport_parameters.computeDistanceToHalfWidthRation())
print("Distance To Width Ratio:", new_viewport_parameters.computeDistanceToWidthRatio())
print("View Matrix:", new_viewport_parameters.computeViewMatrix())
print("Width At Focal Dist:", new_viewport_parameters.computeWidthAtFocalDist())
--------------------------------------------------------------------------------

Re: Create Viewport camera using Python Plugin

Posted: Fri Nov 17, 2023 1:43 pm
by daniel
Is it a question related to CloudCompy or the Python plugin? In which case you might get a better/faster answer by asking the question directly on their respective github page.