如何获取与用户选择的面关联的零件中的螺纹在装配图中的坐标等信息?
问题如标题所示。本来可以通过CreateGeometryProxy来创建特征的代理对象,进而获取该代理对象上的螺纹在装配图中的坐标,但是在Inventor 2012(或者之前的版本)中,得到的代理对象的坐标竟然是零件图里的坐标,所以必须想出了一个补救办法。我想到的办法是将零件图里的坐标转换成装配图里的坐标,也许有人早已经想到过这个办法。下面的VBA例子代码仅供参考:Sub test0()' Assuming the user selected a face in assembly
Dim fproxy As faceProxy
Set fproxy = ThisApplication.ActiveDocument.SelectSet.Item(1)
Dim cocc As ComponentOccurrence
Set cocc = fproxy.ContainingOccurrence
Dim pc As PartComponentDefinition
Set pc = cocc.Definition
Dim OccToAssMatric As Matrix
Set OccToAssMatric = cocc.Transformation
Dim oBasePoint As Point
Dim assDef As AssemblyComponentDefinition
Set assDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim threadFt As Object
If pc.Features.ThreadFeatures.Count > 0 Then For Each threadFt In pc.Features.ThreadFeatures
getinfoforthread threadFt.ThreadInfo, OccToAssMatric, assDef
Next
End If
If pc.Features.HoleFeatures.Count > 0 Then For Each threadFt In pc.Features.HoleFeatures
If threadFt.Tapped = True Then
getinfoforthread threadFt.TapInfo, OccToAssMatric, assDef
End If
Next
End If
If pc.Features.RectangularPatternFeatures.Count > 0 Then
Dim rf As RectangularPatternFeature
For Each rf In pc.Features.RectangularPatternFeatures
For Each threadFt In rf.ParentFeatures
If threadFt.Type = kHoleFeatureObject Then
If threadFt.Tapped = True Then
getinfoforthread threadFt.TapInfo, OccToAssMatric, assDef
End If
End If
Next
Next
End If
End SubSub getinfoforthread(tf As Object, OccToAssMatric As Matrix, assDef As AssemblyComponentDefinition)
Dim oBasePoint As Point
For Each oBasePoint In tf.ThreadBasePoints
Debug.Print CStr(oBasePoint.x) + "," + CStr(oBasePoint.y) + "," + CStr(oBasePoint.Z)
oBasePoint.TransformBy OccToAssMatric
Debug.Print CStr(oBasePoint.x) + "," + CStr(oBasePoint.y) + "," + CStr(oBasePoint.Z)
Call assDef.WorkPoints.AddFixed(oBasePoint)
Next
Dim dir As Vector
Set dir = tf.ThreadDirection
Debug.Print CStr(dir.x) + "," + CStr(dir.y) + "," + CStr(dir.Z)
dir.TransformBy OccToAssMatric
Debug.Print CStr(dir.x) + "," + CStr(dir.y) + "," + CStr(dir.Z)
End Sub文章来源:http://blog.csdn.net/barbarahan
Invertor二次开发 路过!!!
不发表意见…… 活到老学到老 路过!!!
帮顶…… 顶......
楼下跟上..... (*^__^*) 嘻嘻…… 顶!!!!!!!!!!!!!!!!!!!!!!!!! 顶!!!!!!!!!! 顶!!!!!!!!!! 路过!!!
帮顶…… 路过!!!
帮顶…… (*^__^*) 嘻嘻…… 路过!!!
帮顶…… (*^__^*) 嘻嘻…… 顶!!!!!!!!!!!!!!!!!!!!!!!!! 顶......
楼下跟上..... 路过!!!
帮顶……