是否可以使用 Catia vba 在产品中根据约束移动零件?
Is it possible to move a part with repect to constraints in Product using Catia vba?
我必须在两个部件之间移动一个类似球体的探针,以便探针与两个部件接触。而且我必须找到零件的接触点,测量它们的距离并根据这个距离在零件上制作圆角。我已经实现了在零件之间移动球体,但球体正在穿过零件。因此,尝试根据约束
移动
我正在尝试使 Catia 产品中的操纵工具自动化。
是否存在任何命令或方法可以使用 vba 移动相对于 Catia 中的约束的零件?
或
有什么方法可以使用 vba 找到两个部分之间的冲突吗?
期待解决方案。
谢谢!!!
Here 是一个 link 可以找到冲突解决方案的地方。
好的,我明白了,你想看这里的代码:-)
计算 CATScript 中的冲突:
Sub CATMain()
' get root product of document
Dim RootProd As Product
Set RootProd = CATIA.ActiveDocument.Product
' retrieve selection object of active document
Dim objSelection As Selection
Set objSelection = CATIA.ActiveDocument.Selection
' get two selected objects
If (objSelection.Count2 <> 2) Then
MsgBox "Before running the script you must select two products to compute clash for", vbOKOnly, "No products selected"
Exit Sub
End If
Dim FirstProd As Product
Dim SecondProd As Product
Set FirstProd = objSelection.Item2(1).Value
Set SecondProd = objSelection.Item2(2).Value
' create groups for clash computation
Dim objGroups As Groups
Set objGroups = RootProd.GetTechnologicalObject("Groups")
Dim grpFirst As Group
Dim grpSecond As Group
Set grpFirst = objGroups.Add()
Set grpSecond = objGroups.Add()
' add selected products to groups
grpFirst.AddExplicit FirstProd
grpSecond.AddExplicit SecondProd
' get access to Clashes collection
Dim objClashes As Clashes
Set objClashes = RootProd.GetTechnologicalObject("Clashes")
' create new clash
Dim newClash As Clash
Set newClash = objClashes.Add()
' set new clash to be computed between two groups (two selected products)
newClash.FirstGroup = grpFirst
newClash.SecondGroup = grpSecond
newClash.ComputationType = catClashComputationTypeBetweenTwo
' compute clash
newClash.Compute
End Sub
我必须在两个部件之间移动一个类似球体的探针,以便探针与两个部件接触。而且我必须找到零件的接触点,测量它们的距离并根据这个距离在零件上制作圆角。我已经实现了在零件之间移动球体,但球体正在穿过零件。因此,尝试根据约束
移动我正在尝试使 Catia 产品中的操纵工具自动化。 是否存在任何命令或方法可以使用 vba 移动相对于 Catia 中的约束的零件?
或
有什么方法可以使用 vba 找到两个部分之间的冲突吗?
期待解决方案。
谢谢!!!
Here 是一个 link 可以找到冲突解决方案的地方。
好的,我明白了,你想看这里的代码:-)
计算 CATScript 中的冲突:
Sub CATMain()
' get root product of document
Dim RootProd As Product
Set RootProd = CATIA.ActiveDocument.Product
' retrieve selection object of active document
Dim objSelection As Selection
Set objSelection = CATIA.ActiveDocument.Selection
' get two selected objects
If (objSelection.Count2 <> 2) Then
MsgBox "Before running the script you must select two products to compute clash for", vbOKOnly, "No products selected"
Exit Sub
End If
Dim FirstProd As Product
Dim SecondProd As Product
Set FirstProd = objSelection.Item2(1).Value
Set SecondProd = objSelection.Item2(2).Value
' create groups for clash computation
Dim objGroups As Groups
Set objGroups = RootProd.GetTechnologicalObject("Groups")
Dim grpFirst As Group
Dim grpSecond As Group
Set grpFirst = objGroups.Add()
Set grpSecond = objGroups.Add()
' add selected products to groups
grpFirst.AddExplicit FirstProd
grpSecond.AddExplicit SecondProd
' get access to Clashes collection
Dim objClashes As Clashes
Set objClashes = RootProd.GetTechnologicalObject("Clashes")
' create new clash
Dim newClash As Clash
Set newClash = objClashes.Add()
' set new clash to be computed between two groups (two selected products)
newClash.FirstGroup = grpFirst
newClash.SecondGroup = grpSecond
newClash.ComputationType = catClashComputationTypeBetweenTwo
' compute clash
newClash.Compute
End Sub