Hello,
In the below code, where Assembly is a IpfcAssembly assembled in parentAssembly, why would it return "Object type mismatch" on the last line?
IpfcComponentFeat asmComp = (IpfcComponentFeat)parentAssembly
.AssembleComponent((IpfcSolid)Assembly, null);
IpfcComponentConstraint constraint = (new CCpfcComponentConstraint())
.Create((int)EpfcComponentConstraintType.EpfcASM_CONSTRAINT_DEF_PLACEMENT);
IpfcComponentConstraints constraints = new CpfcComponentConstraints();
constraints.Insert(constraints.Count, constraint);
asmComp.SetConstraints(constraints, null); <--- Error
Regards
Solved! Go to Solution.
Solved using pro toolkit:
ProAsmcompAssemble(ProAssemblyHandle, child.ToProSolid(), identity_matrix, &assemblyComp);
ProArrayAlloc(0, sizeof(ProAsmcompconstraint), 1,(ProArray*)&constraints);
ProAsmcompconstraintAlloc(&constraint);
ProAsmcompconstraintTypeSet(constraint, ProAsmcompConstrType::PRO_ASM_DEF_PLACEMENT);
ProArrayObjectAdd((ProArray*)&constraints, 0, 1, &constraint);
ProAsmcompConstraintsSet(NULL,&assemblyComp, constraints);
And making sure that the subassembly has default csys and datum planes.
I've tested the solution using otk and pro toolkit, with the same issue but on a different place. Now on GetConstraints instead
OtkAssemblyHandle->AssembleComponent(child.ToOtkSolid(), NULL);
pfcComponentConstraint_ptr constraint = pfcComponentConstraint::Create(pfcComponentConstraintType::pfcASM_CONSTRAINT_DEF_PLACEMENT);
pfcComponentConstraints_ptr constraints = child.ToOtkCompFeat()->GetConstraints(); <-- XtypeMismatch
constraints->set(0,constraint);
child.ToOtkCompFeat()->SetConstraints(constraints,NULL);
So there sees to be some logic I'm unaware of.
Solved using pro toolkit:
ProAsmcompAssemble(ProAssemblyHandle, child.ToProSolid(), identity_matrix, &assemblyComp);
ProArrayAlloc(0, sizeof(ProAsmcompconstraint), 1,(ProArray*)&constraints);
ProAsmcompconstraintAlloc(&constraint);
ProAsmcompconstraintTypeSet(constraint, ProAsmcompConstrType::PRO_ASM_DEF_PLACEMENT);
ProArrayObjectAdd((ProArray*)&constraints, 0, 1, &constraint);
ProAsmcompConstraintsSet(NULL,&assemblyComp, constraints);
And making sure that the subassembly has default csys and datum planes.