catia二次开发求助

vb6.0开发的,在装配体中想测量两个product的距离,并保持测量,录宏无效。查了一下是用Measurable对象的,但是具体怎么写。如下代码是我找的,但是要转成装配... vb6.0开发的,在装配体中想测量两个product的距离,并保持测量,录宏无效。查了一下是用Measurable对象的,但是具体怎么写。如下代码是我找的,但是要转成装配体中的,该怎么办?reference建不起来...

Dim reference1 As Reference
Set reference1 =
part1.CreateReferenceFromObject(object1)
Dim reference2 As Reference
Set
reference2 = part1.CreateReferenceFromObject(object1)
Dim TheSPAWorkbench As
Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench (
"SPAWorkbench" )
Dim TheMeasurable As Measurable
Set TheMeasurable =
TheSPAWorkbench.Measurable(reference1)
Dim
MinimumDistance As double
MinimumDistance = TheMeasurable.GetAngleBetween(reference2)
我这里刷不出来回答的具体描述,只能看到有人回答了...无语,都不能采纳
展开
 我来答
tylerwang1974
2014-08-08 · TA获得超过2347个赞
知道小有建树答主
回答量:250
采纳率:100%
帮助的人:120万
展开全部
首先,因为你的这个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.因为不是一个文档.
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式