Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How To Mirror a Sketch Using VBA Macro ?

Anonymous

How To Mirror a Sketch Using VBA Macro ?

Anonymous
Not applicable

Hello. I am trying to mirror a drawing sketch around a line automatically (I mean without my intervention). But I couldn't find any objects, properties or methods. All of these objects are used for mirror a feature not a drawing sketch. Can anyone help me please. thanks. 

0 Likes
Reply
Accepted solutions (1)
910 Views
4 Replies
Replies (4)

Anonymous
Not applicable

Any ideas ?

0 Likes

HermJan.Otterman
Advisor
Advisor

the mirrored sketchlines are still sketch lines with some constraints on it. so there is no "mirror" property or so..

do you realy need to mirror the sketch? or can you mirror the extruded feature of it? then you would get a mirror feature that you could do something with

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Anonymous
Not applicable

Thank you for your answer. I tried what you told me but something went wrong I think. When I mirror the feature it mirrors all of the features. How can I mirror just 1 feature.

 

I am using this code :

set surfacebodie = oPartDocument.ComponentDefinition.SurfaceBodies.Item(1)

then this surfacebodie selects all of the bodies. What else can I use.

0 Likes

HermJan.Otterman
Advisor
Advisor
Accepted solution

with this code you should be able to mirror a feature "Extrusion3" around the XZ-Workplane

 

    Private Sub Main

        Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
        Dim oPartComDef As PartComponentDefinition = oPartDoc.ComponentDefinition
        'Dim oFeatures As Features = oPartComDef.Features

        Dim oCollection As ObjectCollection
        oCollection = ThisApplication.TransientObjects.CreateObjectCollection

		'this is the XZ-plane 
        Dim oPartPlane1 As WorkPlane
        oPartPlane1 = oPartComDef.WorkPlanes.Item(2)
		
		'put a feature (or more) in the object collection
        oCollection.Add(oPartComDef.Features("Extrusion3"))

		'create a mirror definition
        Dim mirrorDefinition As MirrorFeatureDefinition
        mirrorDefinition = oPartComDef.Features.MirrorFeatures.CreateDefinition(oCollection, oPartPlane1, PatternComputeTypeEnum.kIdenticalCompute)

        'create the feature
        Dim mirfeature As Inventor.MirrorFeature
        mirfeature = oPartComDef.Features.MirrorFeatures.AddByDefinition(mirrorDefinition)

    End Sub
If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan