access the sketch consumed by an feature

access the sketch consumed by an feature

Anonymous
Not applicable
1,576 Views
8 Replies
Message 1 of 9

access the sketch consumed by an feature

Anonymous
Not applicable

i Know how to acces  all features in other  and i know how to access all sketches in other but is posible to acces to the sketch of a feature ?

0 Likes
Accepted solutions (2)
1,577 Views
8 Replies
Replies (8)
Message 2 of 9

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Anonymous 

I assume you mean the sketch containing the profile for the feature?

For example the extruded profile in an extrude feature.

 

You'll have to get the profile and then its parent.

 

Dim oFeature As PartFeature = ThisDoc.Document.ComponentDefinition.Features(1)
Dim profileSketch As PlanarSketch = oFeature.Profile.Parent
MsgBox(profileSketch.Name)
Message 3 of 9

Anonymous
Not applicable

yes, i mean that , english is not mi habitual lenguage so i dont know how to explain some things of inventor . The code you put dosent works with out some modifications ,but the essence of the aswers yes, it helps me to solve mi problem ,

0 Likes
Message 4 of 9

Anonymous
Not applicable

and other problem is that it makes error message "No se encuentra el miembro público 'Profile' en el tipo 'HoleFeature'." how can i aboit that?

0 Likes
Message 5 of 9

JhoelForshav
Mentor
Mentor

Hi @Anonymous 

HoleFeatures doesn't have profiles. They only have a sketch with points in it. It's easily accessed like through the HoleFeature.Sketch property.

 

Example:

Dim oFeature As HoleFeature = ThisDoc.Document.ComponentDefinition.Features.HoleFeatures(1)
Dim oSketch As PlanarSketch = oFeature.Sketch
MsgBox(oSketch.Name)

 

0 Likes
Message 6 of 9

Anonymous
Not applicable

there is any way to take the sketch independently if is a extrusion or a hole or any thing . i want to take the sketch to check the constrains

 

0 Likes
Message 7 of 9

JhoelForshav
Mentor
Mentor
Accepted solution

Maybe something like this?

 

'Get the feature the way you want.
Dim oFeature As PartFeature = ThisDoc.Document.ComponentDefinition.Features("Extrusion1")
Dim oSketch As PlanarSketch If TypeOf (oFeature) Is HoleFeature oSketch = oFeature.Sketch ElseIf TypeOf (oFeature) Is RevolveFeature _ Or TypeOf (oFeature) Is SweepFeature _ Or TypeOf (oFeature) Is EmbossFeature _ Or TypeOf (oFeature) Is CoilFeature _ Or TypeOf (oFeature) Is ExtrudeFeature oSketch = oFeature.Profile.Parent End If MsgBox(oSketch.Name)

I didn't include Rib or Loft because they are more complex than just the one sketch...

0 Likes
Message 8 of 9

Anonymous
Not applicable

and a Rib ? 

0 Likes
Message 9 of 9

JhoelForshav
Mentor
Mentor
'Get the feature the way you want.
Dim oFeature As PartFeature = ThisDoc.Document.ComponentDefinition.Features("Rib1")

Dim oSketch As PlanarSketch

If TypeOf (oFeature) Is HoleFeature
	oSketch = oFeature.Sketch
ElseIf TypeOf (oFeature) Is RevolveFeature _
	Or TypeOf (oFeature) Is SweepFeature _
	Or TypeOf (oFeature) Is EmbossFeature _
	Or TypeOf (oFeature) Is CoilFeature _
	Or TypeOf (oFeature) Is ExtrudeFeature
	oSketch = oFeature.Profile.Parent
ElseIf TypeOf (oFeature) Is RibFeature
	oSketch = oFeature.Definition.ProfileCurves(1).Parent
End If

MsgBox(oSketch.Name)