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:
<p>Sub SetHeelAngle(angle)</p><p> Dim swMoveCopyBodyFeatureData As SldWorks.MoveCopyBodyFeatureData</p><p> Dim swFeature As SldWorks.Feature</p><p></p><p> boolstatus = swModel.Extension.SelectByID2("Heel_Trim", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)</p><p> Set myFeature = swModel.SelectionManager.GetSelectedObject6(1, -1)</p><p> Set swMoveCopyBodyFeatureData = myFeature.GetDefinition</p><p> swMoveCopyBodyFeatureData.TransformType = swMoveCopyBodyFeatureTransformType_e.swTransformType_Rotation</p><p> swMoveCopyBodyFeatureData.TransformZ = (angle * PI / 180)</p><p> myFeature.ModifyDefinition swMoveCopyBodyFeatureData, swModel, Nothing</p><p> </p><p> swModel.ClearSelection2 True</p><p>End Sub</p>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?
SolidworksApi macros
I can't see that you have called swMoveCopyBodyFeatureData.AccessSelections anywhere. That needs to be the first call before modifying any parameters.
Thank you, that fixed it. Interestingly enough, translation worked just fine even without calling AccessSelections...
If you don't mind me asking, is there a faster way to read/write values of the move-copy feature? The way I'm doing it makes the model roll back and then roll forward again. It takes a lot of time compared to a simple rebuild. What can be done about it?