After searching high and low in the documentation for examples of how to get the free degrees of freedom, their rotation points/axes and translation axes I randomely stumbled onto the GetRemainingDOFs function in the IComponent2 namespace. There exists no documentation and a google search for 'IComponent2 GetRemainingDOFs' will return 0 results (well now it will probably return this discussion).
The question is: can you verify my understanding of the function?
Does this function find the degrees of freedom in both rotation and translation and indicate what are the points and axes for these degrees of freedom? What happens when there are 6 DOFs or 3DOFs in rotation or translation?
The C# definition:
int GetRemainingDOFs(out int Rpoint1_status, out MathPoint Rpoint1, out int Rdirection1_status, out MathVector Rdirection1, out int Rpoint2_status, out MathPoint Rpoint2, out int Rdirection2_status, out MathVector Rdirection2, out int Tdirection1_status, out MathVector Tdirection1, out int Tdirection2_status, out MathVector Tdirection2);
More specifically regarding the arguments, could you answer my questions or is my understanding correct?
returned int: What is returned? The number of degrees of freedom?
int RpointX_status/TdirectionX_status: Some status value associated with whether this DOF is free or not. What's the enumeration type? Is it swConstrainedStatus_e?
MathPoint RpointX: The point which this rotational degree of freedom rotates around
MathVector RdirectionX: The axis of rotation for this rotational degree of freedom
MathVector TdirectionX: The vector of translation for this translational degree of freedom
Thanks for reading!
SolidworksApi macros
I suspect that function wasn't supposed to be publicly visible. It isn't in the API help, so it would not surprise me if it wasn't even operational.
Jim S.
Shhh, don't tell anyone about this. I don't want them to remove it from the API. I played around with this function and this is what I get.
This function does as it suggests. It finds both rotation translation DOFs and gives the point and axis of rotation or direction of translation. In order for it to work properly you must fix the component that the DOFs are in reference to. Fully constraining your base part to reference geometry of the assembly does not work. I made a robot arm and to get the degree of freedom for each subsequent joint, I programmatically fix the component it attaches to.
The returned int is:
0 if the solver worked
2 if your base component wasn't fixed.
Status ints (Rpoint_1_status, Tdirection1_status, etc...). This does not appear to be the swConstrainedStatus_e enumeration. Instead this is what I found:
0 if the corresponding object is null (i.e. this is not a free degree of freedom)
1 if the degree of freedom is a simple degree of freedom (pure rotation or translation)
5 if the DOF is more complicated (i.e. the gripper relative to the base in a multi-DOF robot arm)
If there are 3 unconstrained rotation DOFs or 3 unconstrained translation DOFs, then both rotation status ints or both translation status ints will be 5. Which axes it reported I'm not sure.
All points and vectors are relative to the Assembly origin.
Hope this is useful for someone else