08-30-2017
09:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-30-2017
09:46 PM
Hi @navbor,
I did some more modifications to the code. Try the following VBA code.
Sub Main()
Dim oDef As ComponentDefinition
Set oDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim copyDesign As DesignViewRepresentation
Dim oView As DesignViewRepresentation
Dim Eye As Point, Target As Point
Dim UpVector As UnitVector
Set copyDesign = oDef.RepresentationsManager.DesignViewRepresentations.Item("Bottom")
Call copyDesign.Activate
Dim currentView As View
Set currentView = ThisApplication.ActiveView
Dim currentCamera As camera
Set currentCamera = currentView.camera
Set Eye = currentCamera.Eye
Set Target = currentCamera.Target
Set UpVector = currentCamera.UpVector
Dim Width As Double
Dim Height As Double
Call currentCamera.GetExtents(Width, Height)
Set oView = oDef.RepresentationsManager.DesignViewRepresentations.Item("Left")
Call oView.Activate
Dim docCamera As camera
Dim docView As View
Set docView = ThisApplication.ActiveView
Set docCamera = docView.camera
SetCameraData docCamera, Eye, Target, UpVector, Width, Height
SetCameraData docCamera, Eye, Target, UpVector, Width, Height
' save the camera for the design view
oView.SaveCurrentCamera
Call docView.Update
End Sub
Sub SetCameraData(oCamera As camera, oEye As Point, oTarget As Point, oUpVector As UnitVector, dWidth As Double, dHeight As Double)
oCamera.UpVector = oUpVector
oCamera.Eye = oEye
oCamera.Target = oTarget
oCamera.SetExtents dWidth, dHeight
oCamera.Apply
End Sub
In the above code, "SetCameraData" function is used to twice. Because, if it called once. Still there is a bit tolerance between Design View Representations.
It is observed in the result of previous VBA code.
Please feel free to contact if there is any doubt.
If solves problem, click on "Accept as solution" / give a "Kudo".
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network
