对装配中组件进行镜像
来源:互联网 发布:美剧网络犯罪调查 编辑:程序博客网 时间:2024/04/20 06:11
大家新年好!
本想开年写点啥,正好今天遇到一位用户询问我,如何对装配中组件进行镜像。前面我们知道,API提供了零件中镜像特征或实体的方法,但看上去没有装配中组件镜像的方法。不过如果观察Inventor本身的镜像,可以发现,其实首先是对原零件做了个衍生件,然后插入这个衍生件,根据镜像面做变换。最难的是这个镜像变换。我没看到API给我们写了现成的。所以从网上找到算法,写了个小例子。
这个例子假定装配中拾取了一个工作面,它将对第一个组件进行围绕这个面进行镜像。希望对大家有所帮助。
Sub MirrorPartInAss() Dim oAssDoc As AssemblyDocument Set oAssDoc = ThisApplication.ActiveDocument 'mirror plane Dim oMirrorWP As WorkPlane Set oMirrorWP = oAssDoc.SelectSet(1) Dim oPlane As Plane Set oPlane = oMirrorWP.Plane 'get normal of the plane Dim oNormalX As Double oNormalX = oPlane.Normal.X Dim oNormalY As Double oNormalY = oPlane.Normal.Y Dim oNormalZ As Double oNormalZ = oPlane.Normal.Z 'create the mirroring matrix Dim oMirrorMatrix As Matrix Set oMirrorMatrix = ThisApplication.TransientGeometry.CreateMatrix() Dim oMatrixData(15) As Double oMatrixData(0) = 1 - 2 * oNormalX * oNormalX oMatrixData(1) = -2 * oNormalX * oNormalY oMatrixData(2) = -2 * oNormalX * oNormalZ oMatrixData(3) = 0 oMatrixData(4) = -2 * oNormalX * oNormalY oMatrixData(5) = 1 - 2 * oNormalY * oNormalY oMatrixData(6) = -2 * oNormalZ * oNormalY oMatrixData(7) = 0 oMatrixData(8) = -2 * oNormalX * oNormalZ oMatrixData(9) = -2 * oNormalZ * oNormalY oMatrixData(10) = 1 - 2 * oNormalZ * oNormalZ oMatrixData(11) = 0 oMatrixData(12) = 0 oMatrixData(13) = 0 oMatrixData(14) = 0 oMatrixData(15) = 1 Call oMirrorMatrix.PutMatrixData(oMatrixData) 'get the first component Dim oOcc As ComponentOccurrence Set oOcc = oAssDoc.ComponentDefinition.Occurrences(1) 'multiply with the transformation of the parent component oMirrorMatrix.PostMultiplyBy oOcc.Transformation Dim oParentPartPath As String oParentPartPath = oOcc.Definition.Document.FullFileName ' Create a new part file to derive the part in. Dim oPartDoc As PartDocument Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _ ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject)) ' Create a derived definition for the part. Dim oDerivedPartDef As DerivedPartTransformDef Set oDerivedPartDef = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.CreateTransformDef(oParentPartPath) ' Create the derived part. Call oPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Add(oDerivedPartDef) 'save the derived part. Call oPartDoc.SaveAs("c:\temp\mirrorPart.ipt", False) 'add the derived part as a component Call oAssDoc.ComponentDefinition.Occurrences.Add(oPartDoc.FullFileName, oMirrorMatrix) oPartDoc.Close 'activate the assembly document oAssDoc.ActivateEnd Sub
0 0
- 对装配中组件进行镜像
- solidworks二次开发:在装配体中,对选择的零件进行配合装配
- 对图像进行水平镜像和垂直镜像!
- javascript,组件对像切换
- 用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- [转]用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- [转]用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- 用rsync对网站进行镜像备份
- 对bitmap进行旋转和镜像操作
- 心理学-性格
- cocos2dx之一些宏的作用
- 小明传奇1
- Weblogic 配置代理服务器
- NYOJ 845 无主之地1
- 对装配中组件进行镜像
- zeoslib:取得数据库中某张表的主关键字
- Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_MAMapServices", referenced from: o
- 同步软键盘自定义工具条
- 拓扑排序
- linux下system函数错误返回-1 错误原因NO child processes
- 企业信息化建设的方方面面
- 我懂得了自己对夜雨迷恋的根源
- treegrid级联勾选或深度级联勾选扩展:两种扩展