Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assembly Hole Feature Depth Bug

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
ianteneth
769 Views, 10 Replies

Assembly Hole Feature Depth Bug

Version: Inventor Professional 2020.2

Question: Is the depth property of an assembly hole feature implemented in the API? Or am I running into some other issue?

 

I am running into an error when I try to get the depth of an assembly hole feature (ie. a hole feature that is in the assembly and not in a part). It appears that this section of code has not yet been implemented. Below is the error message.

Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))

Below is a screenshot of an example assembly with hole features in the assembly.

Annotation 2019-11-23 113646.png

 

Below is a code snippet that will try to get the depth of the hole features in the assembly.

Sub Main()
	Dim assembly As AssemblyDocument = ThisDoc.Document	
	For Each hole As HoleFeature In assembly.ComponentDefinition.Features.HoleFeatures
		MessageBox.Show(hole.Depth) 'Crashes here.
	Next hole
End Sub

 

I did a little searching before and this might be related to this issue, but I am not sure.

https://forums.autodesk.com/t5/inventor-customization/depth-value-for-the-hole-is-missing-from-paren... 

10 REPLIES 10
Message 2 of 11

@ianteneth,

 

Please provide non confidential file to test the behavior?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 3 of 11
WCrihfield
in reply to: ianteneth

Remembe that within the () of a MessageBox.Show(), it is expecting a certain order of things within.

The first section is usually "String" type data.

You may have to define this value as a string before it will show up like you want.

Try this:

Sub Main()
	Dim assembly As AssemblyDocument = ThisDoc.Document	
	For Each hole As HoleFeature In assembly.ComponentDefinition.Features.HoleFeatures
Dim oDepth As String
oDepth = hole.Depth.ToString MessageBox..Show(oDepth,"Hole Depth") Next hole End Sub

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 11
WCrihfield
in reply to: ianteneth

Remember that within the () of a MessageBox.Show(), it is expecting a certain order of things within.

The first section is usually a "String" type data (message).  And the second section is the 'Title' (also String).

You may have to define this value as a string before it will show up like you want with the MessageBox.

Try This:

Sub Main()
	Dim assembly As AssemblyDocument = ThisDoc.Document	
	For Each hole As HoleFeature In assembly.ComponentDefinition.Features.HoleFeatures
                Dim oDepth As String
                oDepth = hole.Depth.ToString
		MessageBox.Show(oDepth,"Hole Depth")
	Next hole
End Sub


Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 11
ianteneth
in reply to: WCrihfield

@WCrihfieldThanks for the feedback! I have modified the code to show that the Messagebox.Show() method is not causing the error. This code yields the same error as I mentioned before.

 

@chandra.shekar.gI have attached a zipped folder containing an example assembly for you to test.

 

Annotation 2019-11-26 094913.png

 

Sub Main()
	Dim assembly As AssemblyDocument = ThisDoc.Document	
	For Each hole As HoleFeature In assembly.ComponentDefinition.Features.HoleFeatures
		Dim holeDepth = hole.Depth 'Crashes here.
	Next hole
End Sub
Message 6 of 11
WCrihfield
in reply to: ianteneth

either do:

holeDepth = hole.Depth

or:

Dim holeDepth As Double

holeDepth = hole.Depth

If using "Dim" it is expecting you to define its type, not its value.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 11
ianteneth
in reply to: WCrihfield

@WCrihfield I updated the code to your recommendations (See below). It still crashes in the same way. I don't think the issue is the the variable instantiation. Thanks anyways!

 

And also, I forgot to mention that this issue was originally discovered in the C# api. So it is not limited to iLogic.

 

Sub Main()
	Dim assembly As AssemblyDocument = ThisDoc.Document	
	For Each hole As HoleFeature In assembly.ComponentDefinition.Features.HoleFeatures
		Dim holeDepth As Double
		holeDepth = hole.Depth ' Crashes here 
	Next hole
End Sub
Message 8 of 11

@ianteneth,

 

To address this issue, a change request (INVGEN - 35947 - Depth of hole feature in Assembly document throws exception) is created with engineering team.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 9 of 11
etaCAD
in reply to: ianteneth

Just an assumption: Is there a valid depth value when the hole is a through hole?

Andreas
etaCAD

Message 10 of 11
WCrihfield
in reply to: etaCAD

Good question.  Although retrieving the Depth of a hole that goes through multiple parts in an assembly file currently creates an error, as stated above.  Within a normal part file, you can create a hole feature, set to Through All, and when you retrieve its depth by iLogic, it returns a number equal to the thickness of the part (when both starting face & ending face are flat).

Though it is often forgotten that when features are created within a Part file, then attempting to access & use those features to support further processing within the assembly file, you almost always will need to create & work with a 'proxy' of that feature.  That way you're not modifying the original part, but instead are working with a copy/representation of that feature, created within the Assembly.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 11 of 11
ianteneth
in reply to: ianteneth

This has reportedly been fixed in the 2021.1 update. I haven't tested it yet.

 

 

Screenshot 2020-11-01 203226.png

https://knowledge.autodesk.com/support/inventor/learn-explore/caas/CloudHelp/cloudhelp/2021/ENU/Inve... 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report