Insert Camera Example (VBA)
This example shows how to insert a camera and print out its settings.
'------------------------------------------
'
' Preconditions: Model document is open.
'
' Postconditions: A camera is inserted in the model document.
See
' Lights
and Cameras folder.
'
'------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swCamera As SldWorks.camera
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
' Insert a camera
Set swCamera = swModelDocExt.InsertCamera
' Print out camera settings
Debug.Print "ID =
" & swCamera.ID
Debug.Print "Focal distance =
" & swCamera.GetFocalDistance
* 1000# & " mm"
Debug.Print "Perspective mode =
" & swCamera.Perspective
Debug.Print "Depth of field effects enabled =
" & swCamera.DepthOfFieldEnabled
Debug.Print "Distance from focal plane to where focus
is lost = " & swCamera.DepthOfFieldOffset
* 1000# & " mm"
Debug.Print "Horizontal angle of the field of view
=
" & swCamera.FieldOfViewAngle
* 1000# & " mm"
Debug.Print "Depth of the field of view =
" & swCamera.FieldOfViewDepth
* 1000# & " mm"
Debug.Print "Height of the field of view =
" & swCamera.FieldOfViewHeight
* 1000# & " mm"
End Sub