Mirrored Part But Link To Original Part

Mirrored Part But Link To Original Part

isocam
Collaborator Collaborator
365 Views
3 Replies
Message 1 of 4

Mirrored Part But Link To Original Part

isocam
Collaborator
Collaborator

Can anybody help?

 

I have the following VBA macro that mirrors a part (ipt)

 

Public Function CreateMirrorPart()
    Dim oDoc As PartDocument

    Set oDoc = ThisApplication.ActiveDocument

    Dim oCol As ObjectCollection

    Set oCol = ThisApplication.TransientObjects.CreateObjectCollection

    oCol.Add oDoc.ComponentDefinition.SurfaceBodies(1)

    Dim oPlane As WorkPlane

    Set oPlane = oDoc.ComponentDefinition.WorkPlanes(1)

    Dim oMirror As MirrorFeature

    Set oMirror = oDoc.ComponentDefinition.Features.MirrorFeatures.Add(oCol, oPlane, True, kOptimizedCompute)

    oMirror.NewBodyOperation = True
End Function

 

I want to modify the VBA macro so that the mirrored part automatically updates if the original part is modified.

 

Can anybody update the above macro to allow me to do that?

 

Many thanks in advance!!!!

 

Darren

0 Likes
366 Views
3 Replies
Replies (3)
Message 2 of 4

k14348
Advocate
Advocate

Hi,

    Hope below code solve your issue.

Option Explicit

Public Function CreateMirrorPart()
    
    'Create Mirror Part and remove orginal part.
    
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument

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

    oCol.Add oDoc.ComponentDefinition.SurfaceBodies(1)

    Dim oPlane As WorkPlane
    Set oPlane = oDoc.ComponentDefinition.WorkPlanes(1)

    Dim oMirror As MirrorFeature
    Set oMirror = oDoc.ComponentDefinition.Features.MirrorFeatures.Add(oCol, oPlane, False, kOptimizedCompute)

    oMirror.NewBodyOperation = True

End Function

 

-Karth

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

I believe in your "Set oMirror = " line, the "Add" portion should be ".AddByDefinition(oMirrorFeatureDefinition)"

They you would, of course, have to define the oMirrorFeatureDefinition, before that line.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

@isocam 

I also think that if you want the original to always be the same as the mirrored one, you should have this code name the feature.  Then earlier in the code, check to see if it already exists, if so, either delete & recreate it, or edit its definition.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes