MirrorFeatures.CreateDefinition is returning nothing?

MirrorFeatures.CreateDefinition is returning nothing?

Anonymous
Not applicable
567 Views
2 Replies
Message 1 of 3

MirrorFeatures.CreateDefinition is returning nothing?

Anonymous
Not applicable

Through API (currently debugging through an application that latches into our Inventor application) I am extruding a cut into a part within an assembly and everything is working fine up until when i want to mirror that cut across the XY Plane. Normally, I'd expect an invalid input error or something when something like a "createDefinition" fails, however my code below is showing my mirrorFeatureDefinition is simply not being populated by MirrorFeatures.CreateDefinition and it's not erroring out unitil it tries to "AddByDefinition" due to the mfd being nothing. I've verified that the extrude works, it can find that XY Plane and I'm able to do the mirror feature by hand. Any ideas?

My code:

            'note: my EFD is valid and the extrude is constructing...
            Dim objcol As ObjectCollection = app.TransientObjects.CreateObjectCollection()
            objcol.Add(assydoc.ComponentDefinition.Features.ExtrudeFeatures.Add(efd))
            MsgBox(objcol(1).ToString)
            Dim mfd As MirrorFeatureDefinition = assydoc.ComponentDefinition.Features.MirrorFeatures.CreateDefinition(
                objcol, assydoc.ComponentDefinition.WorkPlanes("XY Plane"), PatternComputeTypeEnum.kIdenticalCompute)
            '^ mfd is showing as null when i get to the line below...
            assydoc.ComponentDefinition.Features.MirrorFeatures.AddByDefinition(mfd)

Capture.PNG

0 Likes
Accepted solutions (1)
568 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

i tested you code and i see the same problem. I would not be supprised if this is a bug.

 

anyway when i use the hidden function:

MirrorFeatures._Add(ParentFeatures As ObjectCollection, MirrorPlaneEntity As Object, Optional AdjustToModel As Boolean = False) As MirrorFeature

with the same input then i get a mirror feature.

my code looks like this:

Dim assydoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim ef = assydoc.ComponentDefinition.Features.Item("Extrusion 1")

Dim objcol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection()
objcol.Add(ef)

Dim mirrorPlane = assydoc.ComponentDefinition.WorkPlanes("XY Plane")
assydoc.ComponentDefinition.Features.MirrorFeatures._Add(objcol, mirrorPlane)

Disclaimer:
I don't know why Autodesk decided to hide this function so i would test it extensively before using it in production. maybe there are other bugs....

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 3

sam
Advocate
Advocate

@JelteDeJong I am using vba and similar code and it is creating mirror but still gives the error. 

Code looks like below:

Set oCollection = ThisApplication.TransientObjects.CreateObjectCollection
    Call oCollection.Add(oDoc.ComponentDefinition.Features.ExtrudeFeatures.Item("ChannelExtrusion"))
    Set oPlane = oDoc.ComponentDefinition.WorkPlanes.Item(2)
    Set oMirrDef = oDoc.ComponentDefinition.Features.MirrorFeatures.Add(oCollection, oPlane)

error is:  

Run-time error '13':

Type mismatch.

Any idea what I am doing wrong here?

 

Best regards, 

sam

0 Likes