重点:FindInstance方法的使用,传参为修改目标对象的父级对象的参考。
CATIProduct_var spChildConnector = NULL_var;
for(int i = 1; i <= nNum; ++i)
{
spChildConnector = (*DirectListChildren)[i];//DirectListChildren为从根节点处拿到的ALLChildren
CATIProduct_var spChildConnectorInstance = NULL_var;//声明一个实例对象
CATIProduct_var spChildConnectorRef = spChildConnector->GetFatherProduct()->GetReferenceProduct();//将连接器的父级对象做成参考
spChildConnectorInstance=spChildConnector->FindInstance(spChildConnectorRef);
spChildConnectorInstance->SetPrdInstanceName(sCode);//sCode是你想要更改的实例名称
}