cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Using SetConstraints() in vb api

JL_10223642
7-Bedrock

Using SetConstraints() in vb api

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

ACCEPTED SOLUTION

Accepted Solutions

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. 

View solution in original post

2 REPLIES 2

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. 

Announcements


Top Tags