Rotate cropped view around center of cropped view

Hi all. Is it possible to rotate a cropped view around the center of that cropped view and not the entire view?
Or is it possible to rotate that cropped view around a specific point?

SolidworksApi/macros
Answers 7
FR
FR 2021-04-08 Best Answer

Hello,

Try this. Select a cropped view > Run the macro

Each time it is run, It will turn the view 90 degrees around its center.

Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swView As SldWorks.View
Dim boolstatus As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'boolstatus = swModel.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
Set swView = swModel.SelectionManager.GetSelectedObject6(1, -1)

Dim vPos As Variant
Dim ViewOutline As Variant
Dim xPos, yPos As Double
Dim myAngle As Double
myAngle = 90
ViewOutline = swView.GetOutline
xPos = (ViewOutline(0) + ViewOutline(2)) / 2
yPos = (ViewOutline(1) + ViewOutline(3)) / 2

swView.Angle = swView.Angle + myAngle / 180 * 3.1415926535897

vPos = swView.Position
ViewOutline = swView.GetOutline

vPos(0) = vPos(0) + xPos - (ViewOutline(0) + ViewOutline(2)) / 2
vPos(1) = vPos(1) + yPos - (ViewOutline(1) + ViewOutline(3)) / 2
swView.Position = vPos
End Sub

FE
FE 2021-04-08

Here is the finished macro.

The macro does: rotation around cropped view, keeps view label in original position, possibility to break alignment to parent view, possibility to scale the view.

FE
FE 2021-04-08

The files I attached don't seem to get through

FR
FR 2021-04-08

attach your files, I will take a look

FE
FE 2021-04-08

That's just the problem. I don't know how to find the label name. Could not find a note or label or name attached to a view.

If I move the label outside of the view and rotate the view then the label does not follow the view as it did before moving the label (on my pc anyway)

FR
FR 2021-04-08

Not sure about the label. It follows the view just fine on my PC.

I guess if you can get the label name, then you would just need to set its position coordinates like the view coordinates

FE
FE 2021-04-08

Thank you ‌.

This is great!!

One question though: The view label also changes position. I can not find the method for getting the view label/caption and the associated position. I would like for the label too stay in the same position, perhaps with the possibility to change the label itself.

comment imagecomment image