02-06-2015
01:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-06-2015
01:45 AM
I created a simple VBA sample to "mirror" 2D sketch, it can work for simple 2D sketch, you can start with it to add more code to make it work better, to run it you should first open a part document and select a planar object which can be used as the mirror tool:
Sub MirroSketchInPartSimpleSample()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oMirrorPlaneEntity As Object
Set oMirrorPlaneEntity = oDoc.SelectSet(1)
Dim oCompDef As PartComponentDefinition
Set oCompDef = oDoc.ComponentDefinition
Dim oSk As PlanarSketch, oMirrorSk As PlanarSketch
Dim oCol As ObjectCollection
Set oCol = ThisApplication.TransientObjects.CreateObjectCollection
For Each oSk In oCompDef.Sketches
If oSk.PlanarEntity.Type = kWorkPlaneObject Then
Dim oMirrorFeature As MirrorFeature, oMirrorWP As WorkPlane
oCol.Clear
oCol.Add oSk.PlanarEntity
Set oMirrorFeature = oCompDef.Features.MirrorFeatures.Add(oCol, oMirrorPlaneEntity)
Set oMirrorWP = oCompDef.WorkPlanes(oCompDef.WorkPlanes.Count)
Set oMirrorSk = oCompDef.Sketches.Add(oMirrorWP)
oSk.CopyContentsTo oMirrorSk
ElseIf oSk.PlanarEntity.Type = kFaceObject Then
Dim oWPForSourceSk As WorkPlane
Set oWPForSourceSk = oCompDef.WorkPlanes.AddByPlaneAndOffset(oSk.PlanarEntity, 0, True)
oCol.Clear
oCol.Add oWPForSourceSk
Set oMirrorFeature = oCompDef.Features.MirrorFeatures.Add(oCol, oMirrorPlaneEntity)
Set oMirrorWP = oCompDef.WorkPlanes(oCompDef.WorkPlanes.Count)
Set oMirrorSk = oCompDef.Sketches.Add(oMirrorWP)
oSk.CopyContentsTo oMirrorSk
End If
Next
End Sub
Please let me if you have more questions on this.
If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.

Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.