Determine Feature Relationships via API

Determine Feature Relationships via API

ForrestJudd
Advocate Advocate
1,334 Views
3 Replies
Message 1 of 4

Determine Feature Relationships via API

ForrestJudd
Advocate
Advocate

I'm trying to find a way to determine all children and parents for a given Part feature, similar to the feedback provided by the Relationships dialog:

 

FeatureRelationships.jpg

 

I can find the Parent sketch easily enough for sketched features, but in the above example I have the following additional dependencies:

 

  • Extrusion 1 due to Sketch 4 being started on one of the faces of Extrusion 1
  • Extrusion 2 due to an edge from Extrusion 2 being projected onto Sketch 4

 

Is there no simple way via the API to determine these relationships?  The only thing I can think of is to do this:

 

For sketched features:

  • Determine the reference for the sketch plane
  • For each entity on the sketch determine if it is projected, and if so the feature from which it is projected

For placed features (e.g. fillet)

  • Determine the feature inputs (face, edge, etc)
  • For each input determine the associated features (not quite sure how to do this)

 

Is there no easier way to determine these relationships?  I was hoping with the new Relationship browser in 2017 that there would be a straightforward API call but I can't find it.

0 Likes
1,335 Views
3 Replies
Replies (3)
Message 2 of 4

wayne.brill
Collaborator
Collaborator

Hi Forest,

 

A colleague in Inventor Engineering has this reply:

 

>> >>

We have not exposed the APIs to directly return a part feature’s parents and children, this is still a wish, users need to parse the relationships by themselves.  Below are some situations that I think the user can consider:

 

For sketch-based features(ExtrudeFeature etc.), users can get the profile that used to create the feature, and then get the sketch the profile is from, and the

PartFeautre->Proflie->Sketch->
        

          i) Face->CreatedByFeature
          ii) WorkPlane->DrivenBy(the work plane can depend on multiple objects, <sketch, work plane, face etc.>, need to parse each of them.)

 

For feature/body-based features, users need to parse one by one to get its  parents:

      

         i. If the feature-based feature has definition object, usually you can get the input Brep geometries for it(like the ShellFeature.Definition.InputFaces), when get the Brep geometries then use the Face.CreatedByFeature(Edge.Faces returns the related Face objects) to get the parent feature. Sometimes users need to roll back the End of Part to get the input geometries.
      

        ii. If the feature-based feature has no definition object, like HoleFeature, users need to parse it with its properties that can indicate which Brep/sketch geometries it depends on. Like the HoleFeature.PlacementDefinition can tell which Face/sketch it depends on.

 

       iii. For the pattern features users can easily find its ParentFeature property and then track all the parents, or if it patterns solids(check PatternOfBody) users can get the parent surface bodies.

 

      iv. For CombineFeature/MoveFeature users can find the surface bodies they depend on.

 

For derived features, their parents are the derived documents.

 

For FreeformFeature, its parents always is the latest part feature before it in UI, I guess this is a defect in UI. Its parents should be nothing I think.

 

For surface features, they can return the geometries they depend on, so seems easy to get their parents.

<< <<

 

 

Thanks,

Wayne

 

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

Maxim-CADman77
Advisor
Advisor

You've written "I can find the Parent sketch easily enough for sketched features".

Could you please share the way you've meant?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 4 of 4

Maxim-CADman77
Advisor
Advisor

Here is an iLogic code to get entities dependencies for all IPT sketches:

Sub Main

Dim oPartDoc As PartDocument=ThisDoc.Document

question =MessageBox.Show("There are " & oPartDoc.ComponentDefinition.Sketches.Count & " sketches in this IPT." & vbCrLf & "Show detailed sketch entity statistics now?", "Sketch QTY",MessageBoxButtons.YesNo,MessageBoxIcon.Question)

	If question = vbNo Then
	
Exit Sub
	
	Else

Dim SkIndex As Integer=1

For Each oSketch As PlanarSketch In oPartDoc.ComponentDefinition.Sketches

	Dim SkMsg As String=""
	Dim SkDepEntIndex As Integer=1

	For Each SkDepEntity In oSketch.Dependents
		SkEntTpEnum = oSketch.Dependents.Item(1).Type
		
		Select Case SkEntTpEnum
		Case 83898624
		SkEntTp="Profile"
		Case 83910912
		SkEntTp="part Extrude feature"		
		Case 83914240
		SkEntTp="part Revolve feature"
		Case=83912192
		SkEntTp="part Hole feature"
		Case 83924736				
		SkEntTp="Sketch"
		Case 67119408
		SkEntTp="Face"
		Case Else 
		SkEntTp="type definition for this object enumerator to be added..."
		End Select	
		
		'Try 
		'If oSketch.Dependents.Item(1).Name.ToLower.contains("feature") Then 'Browser name 
		
			SkMsg=SkMsg+(SkDepEntIndex & ": " & SkEntTpEnum & " (" &SkEntTp & ")" & vbCrLf)
			
		'End If
		'Catch
		'End Try
		
		SkDepEntIndex=SkDepEntIndex+1
	Next
MessageBox.Show(SkMsg, SkIndex & ": """ & oSketch.Name & """ has " & oSketch.Dependents.Count & " dep.entities:")
SkIndex=SkIndex+1
Next

	End If 

End Sub



Yet I still can't see the way to get info regarding which Feature was created on which Sketch.

Could anybody please give me some hint?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes