我必须在两个部件之间移动一个像球体一样的探头,使探头与两个部件接触。我必须找到零件的接触点,测量它们的距离,并根据这个距离在零件上做一个圆角。我已经实现了在部件之间移动球体,但球体正在穿过部件。所以试图在约束条件下移动
我正在尝试自动化Catia产品中的操作工具。 是否有任何命令或方法可以使用vba在Catia中移动关于约束的部分?
或
有没有办法用vba找到两个部分之间的冲突?
期待解决方案。
谢谢!!!
答案 0 :(得分:0)
Here是一个链接,您可以在其中找到冲突的解决方案。
好的,我明白了,你想在这里看到代码: - )
计算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