08-21-2017
11:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-21-2017
11:30 PM
Hi @navbor,
Try the following VBA code to copy one design view to another design view.
Sub Main()
Dim oDef As ComponentDefinition
Set oDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim copyDesign As DesignViewRepresentation
Dim oView As DesignViewRepresentation
Dim eye, target As Point
Dim upVector As UnitVector
Set copyDesign = oDef.RepresentationsManager.DesignViewRepresentations.Item("BaseView") ' View1
Call copyDesign.Activate
Dim currentView As View
Set currentView = ThisApplication.ActiveView
Dim currentCamera As Camera
Set currentCamera = currentView.Camera
Dim tg As TransientGeometry
Set tg = ThisApplication.TransientGeometry
Set eye = tg.CreatePoint(currentCamera.eye.X, currentCamera.eye.Y, currentCamera.eye.Z)
Set target = tg.CreatePoint(currentCamera.target.X, currentCamera.target.Y, currentCamera.target.Z)
Set upVector = tg.CreateUnitVector(currentCamera.upVector.X, currentCamera.upVector.Y, currentCamera.upVector.Z)
Set oView = oDef.RepresentationsManager.DesignViewRepresentations.Item("TargetView") ' View 3
Call oView.Activate
Dim docCamera As Camera
Dim docView As View
Set docView = ThisApplication.ActiveView
Set docCamera = docView.Camera
docCamera.eye = eye
docCamera.upVector = upVector
docCamera.target = target
'Call docCamera.Fit
Call docCamera.Apply
Call docView.Update
oView.AutoSaveCamera = True
End Sub
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
