Assembly Circular Pattern/Mirror of Hole Feature failing at add by definition line.

Assembly Circular Pattern/Mirror of Hole Feature failing at add by definition line.

A.Acheson
Mentor Mentor
612 Views
6 Replies
Message 1 of 7

Assembly Circular Pattern/Mirror of Hole Feature failing at add by definition line.

A.Acheson
Mentor
Mentor

Has anyone any idea why the circular pattern features  add by definition line is failing within an assembly. Is this supported by the API? Sample assembly and part attached. The hole is created and the create definition works I think! Using Inventor 2020 so maybe newer versions this works. 

 

AAcheson_0-1677352813452.png

 

 

' the part document variables
Dim Doc As AssemblyDocument = ThisApplication.ActiveDocument
Dim CompDef As AssemblyComponentDefinition = Doc.ComponentDefinition

Try
	CompDef.Features.HoleFeatures(1).Delete
Catch
End Try

'Prompt user To Select cylinderical face
Dim StartFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Select starting Face")

'Prompt user to select the starting point.
Dim StartingAxis As WorkAxis = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkAxisFilter, "Select Hole Center Axis")

'Prompt user to select the starting point.
Dim RevolveAxis As WorkAxis = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkAxisFilter, "Select Revolve Axis")

'Get user input.
Dim HoleDiameter As Double = InputBox("Enter hole diameters", "Enter hole diameters as a decimal", 1)
Dim HoleDepth As Double = InputBox("Enter hole depth as a decimal. ", "Enter hole depth", 1)

'Create a new sketch on the X-Y work plane.
Dim Sketch As PlanarSketch = CompDef.Sketches.Add(StartFace)

'Create an object collection for the hole center points.
Dim HoleCenters As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

'Add two points as hole centers.
HoleCenters.Add(Sketch.AddByProjectingEntity(StartingAxis))

'Create the hole feature.
Dim HFeature As HoleFeature = CompDef.Features.HoleFeatures.AddDrilledByDistanceExtent(HoleCenters, HoleDiameter,HoleDepth, kPositiveExtentDirection)

'Create an object collection for the hole center points.
Dim ParentFeatures As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

ParentFeatures.Add(HFeature)

Dim HolesPatternDef As CircularPatternFeatureDefinition = CompDef.Features.CircularPatternFeatures.CreateDefinition(ParentFeatures, RevolveAxis, False, 2,"180 Deg",False)

Dim HolesCircularPattern As CircularPatternFeature = CompDef.Features.CircularPatternFeatures.AddByDefinition(HolesPatternDef)

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Accepted solutions (2)
613 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

This seems to be an issue for a while.

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/type-mismatch-error/td-p/8854370

 

On further research it looks like the older .add method is still working but not supported in the API. It was discontinued in 2017 according to this article

 

https://help.autodesk.com/view/INVNTOR/2017/ENU/?caas=caas/blog/adndevblog.typepad.com/manufacturing...

 

So with this knowledge I was able to find the older add method and then added the extra PatterncomputeTypeEnum Option. 

Dim circularPat As CircularPatternFeature = CompDef.Features.CircularPatternFeatures.Add(oParentFeatures, RevolveAxis, True, "2", "180 Deg", True,PatternComputeTypeEnum.kIdenticalCompute)

This works but seems a hacky way to use these standard part methods in the Assembly. 

 

The mirror features continues to be an issue in the same way. the add method works but has errors, if the user manually through the built in dialogue changes the PatternComputeTypeEnum.kIdenticalCompute then it recovers. 

 

Here is a link to the same issues in the  mirrorfeatures "CreateDefinition" and "AddByDefinition" method.

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/mirrorfeatures-createdefinition-is-r...

 

@MjDeck  What is the correct way to use the new type of "CreateDefinition" and "AddByDefinition" ? Can a sample be provided if additional options are needed? The API Help doesn't have such samples and this functionality would be convenient. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 7

MjDeck
Autodesk
Autodesk
Accepted solution

Hi Alan,
 Thanks for reporting this. It looks like the CreateDefinition method never worked in assemblies. It will return a null reference (that is Nothing in VBA and iLogic). Then AddByDefinition fails because it has no actual input.
I created internal issue INVGEN-67552 for this.
It is OK to use the Add method as a workaround.
(Note that your sample code has a small problem that will cause it to fail even with the Add method. Unit names are case-sensitive, so you have to use "180 deg" or "360 deg".)


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 4 of 7

A.Acheson
Mentor
Mentor

Thanks Mike for logging this as a defect, much appreciated. Do you know if this fix will be available to all earlier releases as an update?

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 7

MjDeck
Autodesk
Autodesk

Hi Alan - It's likely that we won't provide the fix for 2020 and earlier. Please let us know if you run into any problems with using the Add method. Since CreateDefinition is not working in this case, looks like we have to support the Add method.


Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 7

A.Acheson
Mentor
Mentor
Accepted solution

Hi Mike, Thanks for clarifying.

 

What s working so far is these methods. Any idea as to why  the methods need  "_" to be added?

If Choice = True Then
	Dim Mirror As MirrorFeature = CompDef.Features.MirrorFeatures._Add(objcol, Revolve)
Else
	Dim circularPat As CircularPatternFeature = CompDef.Features.CircularPatternFeatures._Add(objcol, Revolve, True, 2, "180 deg", True)
'	Dim circularPat As CircularPatternFeature = CompDef.Features.CircularPatternFeatures.Add(objcol, Revolve, True, 2, "180 deg", True,PatternComputeTypeEnum.kIdenticalCompute) ' Also works
End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 7

MjDeck
Autodesk
Autodesk

_Add is a very old version of the method. Internally, it just sets the computeType argument and calls Add. You should be able to use the newer version Add for both mirror and circular patterns.

Here's the arguments to Add for mirror features:
MirrorFeatures_Add.png


Mike Deck
Software Developer
Autodesk, Inc.