Adding an AngleConstraint |
Top Previous Next |
Here's what I use:
bool AddAngleConstraintOfTwoWorkAxisProxies (CComPtr<AssemblyComponentDefinition>& pAsmCompDef, CComPtr<WorkAxisProxy>& pWAProxyA, CComPtr<WorkAxisProxy>& pWAProxyB, const double kRadsAngle) { // Get the list of constraints of the assembly so you can add a new one CComPtr<AssemblyConstraints> pConstraintList ; HRESULT hRes = pAsmCompDef->get_Constraints(&pConstraintList) ; if (FAILED(hRes) || (pConstraintList == nullptr)) { ShowCOMError (hRes,L"AddAngleConstraintOfTwoWorkAxisProxies could not get constraints.") ; return false ; }
CComVariant varReal(kRadsAngle); CComPtr<AngleConstraint> pAngleConstraint ; hRes = pConstraintList->AddAngleConstraint(pWAProxyA, pWAProxyB, varReal, kDirectedSolution, gkvarEmpty, gkvarEmpty, gkvarEmpty, &pAngleConstraint); if ((FAILED(hRes) || (pAngleConstraint == nullptr))) { ShowCOMError (hRes,L"AngleConstraint failed") ; return false ; }
return true ; }
|
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)