catia中的条带分析

Band analysis in catia

我需要使用 VBA 测量两个 im catia 产品之间距离的代码。我不想使用组来衡量。我想在代码中使用 distance.firstproduct 和 distance.secondproduct 而不是使用 distance.firstgroup。有人可以帮我处理代码吗? 谢谢

sub main()
Dim MyDoc As Document
Set MyDoc = CATIA.ActiveDocument

Dim MyProduct As Product
Set MyProduct = MyDoc.Product

Dim Product1 As Product
Dim Product2 As Product

Set Product1 = MyProduct.Products.Item("Part1.1")
Set Product2 = MyProduct.Products.Item("Part2.1")


Dim MySelection As Selection
Set MySelection = MyDoc.Selection

MySelection.Clear

Dim cDistances As Distances
Set cDistances = MyProduct.GetTechnologicalObject("Distances")

Dim MyDistance As Distance
set mydistance=cdistance.add


MyDistance.ComputationType = catDistanceComputationTypebetweentwo
MyDistance.MeasureType = catDistanceMeasureTypeMinimum
Set MyDistance.Firstproduct=product1  '<----Error Line
set myDistance.secondproduct=product2  '<----Error Line

MeasureDistance = MyDistance.Value

MySelection.Clear
end sub

FirstProductSecondProduct 属性为只读,如 Catia CAA 文档所述:

Property FirstProduct( ) As Product (Read Only)

Returns the product belonging to the first group that realizes the minimum distance.

您必须创建组并将产品添加到组中才能评估距离。