Hello,
I've run into a strange problem. A sub in my macro has to modify a rotation angle of the Z axis of a move-copy feature that exists in the model. The code looks like this:
Sub SetHeelAngle(angle)
Dim swMoveCopyBodyFeatureData As SldWorks.MoveCopyBodyFeatureData
Dim swFeature As SldWorks.Feature
boolstatus = swModel.Extension.SelectByID2("Heel_Trim", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
Set myFeature = swModel.SelectionManager.GetSelectedObject6(1, -1)
Set swMoveCopyBodyFeatureData = myFeature.GetDefinition
swMoveCopyBodyFeatureData.TransformType = swMoveCopyBodyFeatureTransformType_e.swTransformType_Rotation
swMoveCopyBodyFeatureData.TransformZ = (angle * PI / 180)
myFeature.ModifyDefinition swMoveCopyBodyFeatureData, swModel, Nothing
swModel.ClearSelection2 True
End Sub
Weird thing is, after this sub is called, it actually modifies the Z axis value, but the body is not rotated. If I manually open the feature, I can see that the rotation value is applied, but the model doesn't react. Here's a screenshot:
As you can see, the Z value is 45 degrees, yet the model is not rotated. If I try to click OK, I get a message saying "Please define either a translation or a rotation", which kind of implies that Solidworks doesn't recognize that value. I tried rebuilding, force-rebuilding, but it's still won't rotate the model.
Interestingly enough, if I use the exact same code to define translation (skipping the swMoveCopyBodyFeatureTransformType_e.swTransformType_Rotation), then everything updates perfectly.
I'm sure I'm missing something obvious here, but I can't figure it out. Could anyone help, please?