How can I mirror the solids in partfile? I'm able to select all the surfacebodies (Componentdefinition.surfacebodies) but, I'm not able to mirror them. Thx.
Open a part document with a solid feature, and try below VBA sample:
Sub MirrorSolidTest() Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim oCol As ObjectCollection Set oCol = ThisApplication.TransientObjects.CreateObjectCollection oCol.Add oDoc.ComponentDefinition.SurfaceBodies(1) Dim oPlane As WorkPlane Set oPlane = oDoc.ComponentDefinition.WorkPlanes(1) Dim oMirror As MirrorFeature Set oMirror = oDoc.ComponentDefinition.Features.MirrorFeatures.Add(oCol, oPlane, False, kOptimizedCompute) End Sub
It works fine but I need to take it a step further that means:
Starting conditions: I have Solid1
End conditions: To have Solid1 and Solid2 which is the mirror of Solid1.
Thx.
To create a new solid body for the mirror feature, please use below code:
Sub MirrorSolidTest() Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim oCol As ObjectCollection Set oCol = ThisApplication.TransientObjects.CreateObjectCollection oCol.Add oDoc.ComponentDefinition.SurfaceBodies(1) Dim oPlane As WorkPlane Set oPlane = oDoc.ComponentDefinition.WorkPlanes(1) Dim oMirror As MirrorFeature Set oMirror = oDoc.ComponentDefinition.Features.MirrorFeatures.Add(oCol, oPlane, False, kOptimizedCompute) oMirror.NewBodyOperation = True End Sub
I know this thread is already a few years old but I used the exact same code to mirror a part. The mirror plane is supposed to be one surface of my part so that the mirrored part touches the original part. The code worked out well but after modification of the part the mirror plane seems to be different (or the same... the new part is shorter than the old one). When I mirror my part now there is a gap between the original and the mirrored part. Why is that?
Can you share a data and code to reproduce the problem for us to look into it?