MirrorFeature

MirrorFeature

Anonymous
Not applicable
368 Views
5 Replies
Message 1 of 6

MirrorFeature

Anonymous
Not applicable
I am trying to use the Mirror Feature function within Inventor 10. Does anyone have a small sample of code, in VB, showing this function working, in particular how to define the ParentFeatures as ObjectCollection?
0 Likes
369 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Here is a sample that creates an extrude feature and then a mirror feature
using the extrude.

Sanjay-

Public Sub Mirror()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))

' Set a reference to the component definition.
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition

' Create a new sketch on the X-Y work plane.
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))

' Set a reference to the transient geometry object.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry

' Draw a rectangle
Dim oRectangleLines As SketchEntitiesEnumerator
Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _
oTransGeom.CreatePoint2d(-1, 0), _
oTransGeom.CreatePoint2d(-4, -3))

' Create a profile.
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid

' Create a base extrusion 1cm thick.
Dim oExtrude As ExtrudeFeature
Set oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent( _
oProfile, 1, kNegativeExtentDirection,
kJoinOperation)

Dim oParentFeatures As ObjectCollection
Set oParentFeatures =
ThisApplication.TransientObjects.CreateObjectCollection

oParentFeatures.Add oExtrude

Dim oYZPlane As WorkPlane
Set oYZPlane = oCompDef.WorkPlanes.Item(1)

Dim oMirror As MirrorFeature
Set oMirror = oCompDef.Features.MirrorFeatures.Add(oParentFeatures,
oYZPlane)

End Sub


wrote in message news:5012205@discussion.autodesk.com...
I am trying to use the Mirror Feature function within Inventor 10. Does
anyone have a small sample of code, in VB, showing this function working, in
particular how to define the ParentFeatures as ObjectCollection?
0 Likes
Message 3 of 6

Anonymous
Not applicable
Thanks Sanjay. I still have a problem in that I wish to Mirror the entire model.

I wish to have code that achieves the equivalent of the interative commands:

'Mirror Feature'
'Mirror the Entire Solid'
'Remove Original'
'Mirror Plane' & selecting the YZ Plane from the Origin

Hoping that you can help

Alistair
0 Likes
Message 4 of 6

Anonymous
Not applicable
I've modified the code to mirror the solid instead of the extrude feature.
Also, the original is not retained by setting the 3rd argument of
MirrorFeatures.Add to True.

Sanjay-


Public Sub Mirror()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))

' Set a reference to the component definition.
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition

' Create a new sketch on the X-Y work plane.
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))

' Set a reference to the transient geometry object.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry

' Draw a rectangle
Dim oRectangleLines As SketchEntitiesEnumerator
Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _
oTransGeom.CreatePoint2d(-1, 0), _
oTransGeom.CreatePoint2d(-4, -3))

' Create a profile.
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid

' Create a base extrusion 1cm thick.
Dim oExtrude As ExtrudeFeature
Set oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent( _
oProfile, 1, kNegativeExtentDirection, kJoinOperation)

Dim oParentFeatures As ObjectCollection
Set oParentFeatures =
ThisApplication.TransientObjects.CreateObjectCollection

oParentFeatures.Add oCompDef.SurfaceBodies.Item(1)

Dim oYZPlane As WorkPlane
Set oYZPlane = oCompDef.WorkPlanes.Item(1)

Dim oMirror As MirrorFeature
Set oMirror = oCompDef.Features.MirrorFeatures.Add(oParentFeatures,
oYZPlane, True)

End Sub



wrote in message news:5015857@discussion.autodesk.com...
Thanks Sanjay. I still have a problem in that I wish to Mirror the entire
model.

I wish to have code that achieves the equivalent of the interative commands:

'Mirror Feature'
'Mirror the Entire Solid'
'Remove Original'
'Mirror Plane' & selecting the YZ Plane from the Origin

Hoping that you can help

Alistair
0 Likes
Message 5 of 6

Anonymous
Not applicable
Thanks Sanjay,

Worked a treat. If only the API helpfiles could include such useful information.

Alistair
0 Likes
Message 6 of 6

Anonymous
Not applicable
Isn't this forum the API helpfile? 😉

LOL

--
T. Ham
Mechanical Engineer
CDS Engineering BV

Dual Pentium XEON 2.2 Ghz
2 GB SDRAM
NVIDIA QUADRO4 700 XGL (Driver = 77.18)
18 GB SEAGATE SCSI Hard Disc
3Com Gigabit NIC

Windows 2000 Professional SP4
Autodesk Inventor Series 9 SP4
Autodesk Inventor Series 10 SP2
--

wrote in message news:5017197@discussion.autodesk.com...
Thanks Sanjay,

Worked a treat. If only the API helpfiles could include such useful
information.

Alistair
0 Likes