Hello
Can anyone help me to create a plane and mirror a solid?
I am planning to have the following workflow:
Plane creation:
Through the z-axis and at an angle of 7,5° to the XZ-Plane
Naming the plane - Mirror Plane
Turning off the plane visibility
Mirror solid:
Add mirrored solid to the existing solid
Here is a sample ao the code...
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oCol As ObjectCollection
oCol = ThisApplication.TransientObjects.CreateObjectCollection
'This does not work...
oCol.Add(oDoc.ComponentDefinition.SurfaceBodies(1))
'Here I want to create a new plane
Dim oPlane As WorkPlane
oPlane = oDoc.ComponentDefinition.WorkPlanes(1)
Dim oMirror As MirrorFeature
oMirror = oDoc.ComponentDefinition.Features.MirrorFeatures.Add(oCol, oPlane, False, kOptimizedCompute)
I have also attached a simplified part file where the code has been copied inti the iLogic browser
Best regards
Kari
Solved! Go to Solution.
It was solved like this (this code was used in iLogic):
Sub Main()
Dim invApp As Inventor.Application = Nothing
invApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
' Get the part document.
Dim partDoc As Inventor.PartDocument
partDoc = invApp.ActiveDocument
'Get the part component definition
Dim oPartDef As Inventor.PartComponentDefinition
oPartDef = invApp.ActiveDocument.ComponentDefinition
' Get the X-Z-Plane work plane.
Dim oxzPlane As Inventor.WorkPlane
oxzPlane = oPartDef.WorkPlanes.Item(2)
'Get the Z-Axis
Dim ozAxis As Inventor.WorkAxis
ozAxis = oPartDef.WorkAxes.Item(3)
'Create the mirror plane (15° is sat as default)
Dim oPlane4 As Inventor.WorkPlane
oPlane4 = oPartDef.WorkPlanes.AddByLinePlaneAndAngle(ozAxis, oxzPlane, 15 / 2 / 180 * System.Math.PI)
'Turn off the visibility of the mirror plane
oPlane4.Visible = False
'Get the object collection
Dim oCol As Inventor.ObjectCollection
oCol = invApp.TransientObjects.CreateObjectCollection
oCol.Add(partDoc.ComponentDefinition.SurfaceBodies(1))
'Mirror the feature
Dim oMirror As Inventor.MirrorFeature
oMirror = partDoc.ComponentDefinition.Features.MirrorFeatures.Add(oCol, oPlane4, False)
'This can be activated if the mirrored feature is to
'be a new solid
'oMirror.NewBodyOperation = True
ThisDoc.Save
End Sub
Can't find what you're looking for? Ask the community or share your knowledge.