This content has been marked as final. Show 2 replies
I need some help about a simple macro written many years ago, which had worked always perfectly.
The default rotation of SW (using the Up-/Down keys) rotates about the screen X,Y axis, but I want to rotate about the model X,Y or Z axis.
The sense behind the macro is to rotate about the X,Y or Z model axis to turn the model inside ISO or trimetric views.
Below is a simple as possible Test macro, on my system it rotates only about the X axis, regardless which axis vector is given.
And it rotates only one (sometimes 2) times, depends on which view direction is shown in SW before.
Can you confirm the behavior on your system?
Any ideas to accomplish the same with an other code?
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swView As SldWorks.ModelView
Dim Data, Start As Double, Step As Double, Degree As Double
Dim nStatus As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swView = swModel.ActiveView
Data = swModel.GetMassProperties
If IsEmpty(Data) Then
ReDim Data(0 To 2)
Data(0) = 0
Data(1) = 0
Data(2) = 0
Degree = 90
'Rotate the model around the Z axis
swView.RotateAboutAxis Rad(Degree), Data(0), Data(1), Data(2), 0, 0, 1
Private Function Pi() As Double
'Gibt die Zahl Pi zurück
Pi = Atn(1) * 4
Private Function Rad(ByVal X As Double) As Double
'Wandelt Grad in Radiant
Rad = X * Pi / 180