I've created a VBA macro that generates 3D rotated cubes of different proportions.
The 3D rotation is performed by the "Off Axis 2 Top" rotation function.
In the code and picture below is a simplified illustration of the reference nodes. Green nodes indicate the corner positions before the rotation, while the red nodes are what I wish to find so that I can add text/arrows etc. to these locations everytime a new cube is generated by the macro.
I can use transformation and rotation matrices to find these locations, but is there a simple way to just return the X, Y positions of each corner as it is stored?
Sub MakeCubes()
'Make a 100x100x100 cube at X=100, Y=100
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 100, 100, 100, 100).Select
With Selection.ShapeRange.ThreeD
.SetPresetCamera (msoCameraIsometricOffAxis2Top)
.RotationX = -53.4542333333
.RotationY = -58.7380833333
.RotationZ = 57.6425166667
End With
Selection.ShapeRange.ThreeD.Depth = 100
Selection.Name = "3DCube"
'Place a green marker for Node 1 orignally (Ref node)
ActiveSheet.Shapes.AddShape(msoShapeMathMultiply, 100 - 35 / 2, 100 - 35 / 2, 35, 35). _
Select
Selection.ShapeRange.Adjustments.Item(1) = 0.03
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 176, 80)
.Transparency = 0
End With
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 176, 80)
.Transparency = 0
.Solid
End With
End Sub
Thank you for any help.
Capture.JPG
Bookmarks