AlexMorasan
Automotive
- Aug 17, 2020
- 13
Hello everyone
I have to create a macro that will allow the user to create an specific viewpoint of the main assembly so the user can take an screenshot ( the screenshot is use to update our assembly handbook).
I have analyzed the DMUInfEngineeringView file and with that I have created my own code.
Language="VBSCRIPT"
Sub CATMain()
Dim ProjectionM
Dim FocusD
FocusD = 837.729
' Get the viewer
Set oViewer = CATIA.ActiveWindow.ActiveViewer
' Get the viewpoint
Set oViewpoint = oViewer.Viewpoint3D
Dim origin(2)
Dim sight(2)
Dim up(2)
M = 2568.767
N = -301.194
P = 323.169
X = 0.972
Y = 0.130
Z = 0.195
U = -0.200
V = 2.627
W = 0.979
' Change the viewpoint
oViewpoint.PutUpDirection Array(U, V, W)
oViewpoint.PutOrigin Array(M, N, P)
oViewpoint.PutSightDirection Array(X, Y, Z)
oViewpoint.ProjectionMode = catProjectionCylindric
ProjectionM = oViewpoint.ProjectionMode
MsgBox ProjectionM
oViewpoint.FocusDistance = FocusD
' Update the viewer
oViewer.Update
oViewpoint.GetOrigin origin
oViewpoint.GetSightDirection sight
oViewpoint.GetUpDirection up
For i = 0 to 2
MsgBox origin(i)
Next
For i = 0 to 2
MsgBox sight(i)
Next
For i = 0 to 2
MsgBox up(i)
Next
Set oViewpoint = Nothing
Set oViewer = Nothing
End Sub
However my problem is that instead of getting the viewpoint that I need I always get a rotated version of my desired viewpoint.
Example:
This is the viewpoint that I need, I already know the coordinates for the origin, the sight direction, the up direction and the focus distance (I use another macro to get this data)
This is the viewpoint that I get, as you can see the viewpoint is slightly rotated.
Currently the code is in CATscript but the final version will be in VBA.
I would really appreciate any help you can give me.
Thanks in advance for your support.
Alex
I have to create a macro that will allow the user to create an specific viewpoint of the main assembly so the user can take an screenshot ( the screenshot is use to update our assembly handbook).
I have analyzed the DMUInfEngineeringView file and with that I have created my own code.
Language="VBSCRIPT"
Sub CATMain()
Dim ProjectionM
Dim FocusD
FocusD = 837.729
' Get the viewer
Set oViewer = CATIA.ActiveWindow.ActiveViewer
' Get the viewpoint
Set oViewpoint = oViewer.Viewpoint3D
Dim origin(2)
Dim sight(2)
Dim up(2)
M = 2568.767
N = -301.194
P = 323.169
X = 0.972
Y = 0.130
Z = 0.195
U = -0.200
V = 2.627
W = 0.979
' Change the viewpoint
oViewpoint.PutUpDirection Array(U, V, W)
oViewpoint.PutOrigin Array(M, N, P)
oViewpoint.PutSightDirection Array(X, Y, Z)
oViewpoint.ProjectionMode = catProjectionCylindric
ProjectionM = oViewpoint.ProjectionMode
MsgBox ProjectionM
oViewpoint.FocusDistance = FocusD
' Update the viewer
oViewer.Update
oViewpoint.GetOrigin origin
oViewpoint.GetSightDirection sight
oViewpoint.GetUpDirection up
For i = 0 to 2
MsgBox origin(i)
Next
For i = 0 to 2
MsgBox sight(i)
Next
For i = 0 to 2
MsgBox up(i)
Next
Set oViewpoint = Nothing
Set oViewer = Nothing
End Sub
However my problem is that instead of getting the viewpoint that I need I always get a rotated version of my desired viewpoint.
Example:
This is the viewpoint that I need, I already know the coordinates for the origin, the sight direction, the up direction and the focus distance (I use another macro to get this data)
This is the viewpoint that I get, as you can see the viewpoint is slightly rotated.
Currently the code is in CATscript but the final version will be in VBA.
I would really appreciate any help you can give me.
Thanks in advance for your support.
Alex