SetAsCylindricalJointMotion: RuntiError 3: Cannot be editied before rolling back

SetAsCylindricalJointMotion: RuntiError 3: Cannot be editied before rolling back

Anonymous
Not applicable
401 Views
1 Reply
Message 1 of 2

SetAsCylindricalJointMotion: RuntiError 3: Cannot be editied before rolling back

Anonymous
Not applicable

I'm using the following code to define a cylindrical motion between a bolt and a screw driver model which are aligned on the Y Axis, I get the error:

Runtime Error 3: Cannot be Edited before Rolling Back

This happens when  the line : "toolPath.setAsCylindricalJointMotion(direction)" is called.

what is causing this error and how can I make the code work?

def makeToolPath(self,jointGeometry, motionType, direction=None, rotationAxis =None, yaw=None,customDirection=None, customRotation=None, customYaw=None, object1=None, object2=None ):
        if object1 is None:
            object1=self.toolComponent
        if object2 is None:
            object2=self.objectComponent
        joints =self.objectInstance.asBuiltJoints
        occ1 = self.objectInstance.allOccurrencesByComponent(object1)[0]
        occ2 = self.objectInstance.allOccurrencesByComponent(object2)[0]
        toolPathInput = joints.createInput(occ1, occ2, jointGeometry)
        toolPath = joints.add(toolPathInput)
        if motionType == adsk.fusion.JointTypes.RigidJointType:
            toolPath.setAsRigidJointMotion()
        elif motionType==adsk.fusion.JointTypes.SliderJointType:
            toolPath.setAsSliderJointMotion(direction,customDirection)
        elif motionType==adsk.fusion.JointTypes.RevoluteJointType:
            toolPath.setAsRevoluteJointMotion(rotationAxis,customRotation)
        elif motionType==adsk.fusion.JointTypes.PlanarJointType:
            toolPath.setAsPlanarJointMotion(direction,customDirection)
        elif motionType==adsk.fusion.JointTypes.CylindricalJointType:
            toolPath.setAsCylindricalJointMotion(direction)
        elif motionType==adsk.fusion.JointTypes.PlanarJointType:
            toolPath.setAsPinSlotJointMotion(rotationAxis, direction, customRotation, customDirection)
        elif motionType==adsk.fusion.JointTypes.BallJointType:
            toolPath.setAsBallJointMotion(direction, yaw,customDirection, customYaw)
        else:
            raise TypeError("There is no motion type of "+motionType)
        return toolPath
        
jointGeometry = adsk.fusion.JointGeometry.createByPoint(self.toolComponent.originConstructionPoint)
direction = adsk.fusion.JointDirections.YAxisJointDirection
motionType = adsk.fusion.JointTypes.CylindricalJointType
self.setToolPath(jointGeometry, motionType, direction)
0 Likes
402 Views
1 Reply
Reply (1)
Message 2 of 2

liujac
Alumni
Alumni

Hi,

 

Edit on existing joint, you must roll the timeline back to just before the joint.

But in the case of joint creations, you can change your code as below, then it should work.

 

def makeToolPath(self,jointGeometry, motionType, direction=None, rotationAxis =None, yaw=None,customDirection=None, customRotation=None, customYaw=None, object1=None, object2=None ):
        if object1 is None:
            object1=self.toolComponent
        if object2 is None:
            object2=self.objectComponent
        joints =self.objectInstance.asBuiltJoints
        occ1 = self.objectInstance.allOccurrencesByComponent(object1)[0]
        occ2 = self.objectInstance.allOccurrencesByComponent(object2)[0]
        toolPathInput = joints.createInput(occ1, occ2, jointGeometry)
        if motionType == adsk.fusion.JointTypes.RigidJointType:
            toolPathInput.setAsRigidJointMotion()
        elif motionType==adsk.fusion.JointTypes.SliderJointType:
            toolPathInput.setAsSliderJointMotion(direction,customDirection)
        elif motionType==adsk.fusion.JointTypes.RevoluteJointType:
            toolPathInput.setAsRevoluteJointMotion(rotationAxis,customRotation)
        elif motionType==adsk.fusion.JointTypes.PlanarJointType:
            toolPathInput.setAsPlanarJointMotion(direction,customDirection)
        elif motionType==adsk.fusion.JointTypes.CylindricalJointType:
            toolPathInput.setAsCylindricalJointMotion(direction)
        elif motionType==adsk.fusion.JointTypes.PlanarJointType:
            toolPathInput.setAsPinSlotJointMotion(rotationAxis, direction, customRotation, customDirection)
        elif motionType==adsk.fusion.JointTypes.BallJointType:
            toolPathInput.setAsBallJointMotion(direction, yaw,customDirection, customYaw)
        else:
            raise TypeError("There is no motion type of "+motionType)
            
        toolPath = joints.add(toolPathInput)
        return toolPath

Jack

0 Likes