catia二次开发求助

首先,因为你的这个SPAWorkbench是当前ActiveDocument的.

你当前的活动文档就是你需要测量的2个产品的父文档.它是个Product.

在Product里创建Reference只有CreateReferenceFromName可以用的.

这个函数的使用需要写出你想创建Reference的特征的Brep Name.函数的说明如下:

Func CreateReferenceFromName(

CATBSTR

iLabel) As

Reference

Creates a reference from a name. A reference is an object that can stand for

any geometrical object. Creating references is necessary for adding constraints

between two components using Brep elements of the representations of these

components.

Parameters:

iLabel

The path of the Brep element to use in the constraint. This path is passed

as a character string comprising the component path from the root product to the

component concerned, concatenated to the Brep element path in the product's

representation. Components are separated using "/", and the product path is

separated from the Brep using "/!".

Returns:

The created reference

Example:

This example creates a reference from the path of a Brep element in the

Prod2 product located below the Root root product. The face is

located in the Pad.1 pad and limited by the Circle.1 circle.

Dim Ref As Reference

Ref = Prod2.CreateReferenceFromName("Root/Prod2/!Face:(Brp:(Pad.1:0(Brp:(Circle.1))):None())")

你用的 Part.CreateReferenceFromObject只能在零件级的文档内使用.

这个用了也没用.你的Product得不到这个在part里创建的Reference.因为不是一个文档.