admin 发表于 2019-7-30 07:18:11

NX二次开发源码分享: Ufun设置工作部件重量


NX二次开发源码分享: Ufun设置工作部件重量


void do_it()
{
    tag_t workPart = UF_ASSEM_ask_work_part();

    if (workPart != NULL_TAG)
    {
      UF_WEIGHT_properties_t propsOld, propsNew;

      UF_CALL(UF_WEIGHT_ask_props(workPart, UF_WEIGHT_units_km, &propsOld));
      ECHO("Old Weight: %f\n", propsOld.mass);
      ECHO("Accuracy: %.2f\n", propsOld.accuracy);

      propsNew.cache_state = propsNew.mass_state = UF_WEIGHT_asserted;
      propsNew.area_state = propsNew.cofm_state = propsNew.mofi_state = propsNew.density_state = propsNew.volume_state = UF_WEIGHT_unknown;
      propsNew.accuracy = 1.0;
      propsNew.units = UF_WEIGHT_units_gm;
      propsNew.mass = 1234.56;
      UF_CALL(UF_WEIGHT_assert_part_props(workPart, &propsNew));

      UF_CALL(UF_WEIGHT_ask_props(workPart, UF_WEIGHT_units_km, &propsOld));
      ECHO("New Weight: %f\n", propsOld.mass);
    }

}
页: [1]
查看完整版本: NX二次开发源码分享: Ufun设置工作部件重量