what i want to do ? -> i want to create a camera, then i want to assign that camera to a capture (existing or newly created).
problem ->
1- using similar code to the as of v5 new camera i create is getting created in the parent note, not in the 3d shape. as i want to assign it to a FTA Capture i need a camera in the 3d shape. As per the CHM file, it says "Created Camera for 3DPart scenario is no more located under the 3DShape"
2- In 3dx , Capture does expose a property named Camera as Camera3d, which says "Retrieves or sets a camera." but i dont know how to use it. i tried few methods all are failing and giving error as object or property doesnt support this method.
So do we need to use the same method if so how ? or there is another method to create and assign a camera to the capture.
thanks.
here is the catia code which works in V5
Sub create_CAM()
Dim activeDoc As Document
Dim activeViewer As Viewer3D
Dim MyCamera As Camera3D
On Error GoTo ErrorHandler
If CATIA.Documents.Count = 0 Then
MsgBox "No active CATIA document was found.", _
vbExclamation, _
"Create ISO Camera"
Exit Sub
End If
Set activeDoc = CATIA.ActiveDocument
Set activeViewer = CATIA.ActiveWindow.activeViewer
CATIA.StartCommand "* iso"
CATIA.RefreshDisplay = True
WaitMs 1000
CATIA.StartCommand "Fit All In"
CATIA.RefreshDisplay = True
WaitMs 1000
'Create the camera from the current viewer state
Set MyCamera = activeViewer.NewCamera()
'Rename Camera000, Camera001, etc. to ISOCAM
MyCamera.name = "ISOCAM"
CATIA.RefreshDisplay = True
' MsgBox "Camera created successfully: " & MyCamera.name, _
' vbInformation, _
' "Create ISO Camera"
Exit Sub
ErrorHandler:
' MsgBox "The camera could not be created or renamed." & vbCrLf & _
' vbCrLf & _
' "Error " & Err.Number & ": " & Err.Description, _
' vbCritical, _
' "Create ISO Camera"
End Sub
here is the 3dx code which i am trying
Sub CATMain()
' Get the active editor and product/part document context
Dim oEditor As Editor
Set oEditor = CATIA.ActiveEditor
' Assuming you are inside a 3D Shape context
Dim oPart As Part
Set oPart = oEditor.ActiveObject
' Retrieve the Annotation Set
Dim oAnnotationSets As AnnotationSets
Set oAnnotationSets = oPart.AnnotationSets
Dim oAnnotationSet As AnnotationSet
Set oAnnotationSet = oAnnotationSets.Item(1)
' Access the Captures collection
Dim oCaptures As Captures
Set oCaptures = oAnnotationSet.Captures
' Get your specific target capture (e.g., the first capture)
Dim oCapture As Capture
Set oCapture = oCaptures.Item(1)
Dim oVisuServices As visuServices
Set oVisuServices = CATIA.GetSessionService("VisuServices")
Dim oCameras As Cameras
Set oCameras = oVisuServices.Cameras
' Select the desired Camera3D object (e.g., Camera.1)
Dim oCamera As Camera3D
Set oCamera = oCameras.Item(1)
' --- Attach the Camera to the Capture ---
Set oCapture.Camera = oCamera
' Enable the viewpoint state so the view changes when the capture is displayed
oCapture.ViewPoint = True
' Refresh display to apply changes
CATIA.ActiveWindow.activeViewer.Reframe
End Sub
