Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a plane and mirror solid

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
1000 Views, 1 Reply

Create a plane and mirror solid

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

 

1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report