cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Implement new method View.GetIntentOrDefault(...)

Implement new method View.GetIntentOrDefault(...)

For drawing automation you need to get the intents from the model. Therefore we have the method View.GetIntent(...)

but this method throws an exception if the intent was not found. This happens to me a lot because my models are also automated and faces are regularly suppressed. Which breaks my  drawing automation. 

Can we get a function that would not throw an exception but returns a default value (Nothing). Something like the Enumerable.FirstOrDefault(...) method.

This is the extension method that I use for these situations: (I didn't implement all the optional parameters but you get the idea.)

 

''' <summary>
''' Same as the default iLogic methode but returns nothing if the intent is not found.
''' (instead of throwing an exception)
''' </summary>
<Runtime.CompilerServices.Extension() >
Public Function GetIntentOrDefault(view As IManagedDrawingView, modelEntityName As String, pointIntent As PointIntentEnum) As GeometryIntent
	Dim intent = Nothing
	Try
		intent = view.GetIntent(modelEntityName, pointIntent)
	Catch ex As Exception
	End Try
	Return intent
End Function

 

 

5 Comments
Yijiang.Cai
Autodesk
Status changed to: Future Consideration

Many thanks for posting the idea to us, and tracked as [INVGEN-76273]

MjDeck
Autodesk

@JelteDeJong , we can implement this. But I recommend adding logic to check parameters from the model (the ones that control feature suppression) before calling View.GetIntent.

JelteDeJong
Mentor

@MjDeck I agree that it would be better to check the parameter if possible. Sometimes, a feature is suppressed by a (long) iLogic rule instead of a parameter. (Of course, I could set a parameter at the end of that rule and read it) Or a face disappears because the sheet gets too small. The bottom line is that I sometimes run into situations that are not that predictable. Then View.GetIntentOrDefault is a solution. Because I can check if  I get a default(null/Nothing) value and handle it accordingly.

MjDeck
Autodesk

To handle more cases, you can directly access feature suppression and other things from the model using the IStandardObjectProvider interface.
Here's sample code to get the suppression status of a hole feature in a component part:

Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Sheet:1")
Dim VIEW1 = Sheet_1.DrawingViews.ItemByName("VIEW1")

Dim modelDoc = VIEW1.ModelDocument
Dim modelObjects = StandardObjectFactory.Create(modelDoc)

If modelObjects.Feature.IsActive("Part341:1", "Hole1") Then
  Dim hole1Face = VIEW1.GetIntent("Part341:1", "Hole1Face")
  Logger.Info("hole1Face intent type = {0}", hole1Face.IntentType)
End If
dan_szymanski
Autodesk
Status changed to: Implemented

This idea has been implemented within Autodesk Inventor 2026. Please review the Inventor 2026 What's New article here, for more information regarding how you may leverage it. Special thanks to everyone who cast a vote for this capability.

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

Submit Idea