CloudCompare-PythonPlugin
CloudCompare-PythonPlugin copied to clipboard
Create Viewport camera using Python Plugin
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.
is it possible to have more examples than those plublished at this address ? https://tmontaigu.github.io/CloudCompare-PythonPlugin/examples.html
CC & Python together are amazing !!! Congratulations !!!
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())