ExtrudeFeature failure on sketch edit

ExtrudeFeature failure on sketch edit

mjordan3
Advocate Advocate
1,423 Views
10 Replies
Message 1 of 11

ExtrudeFeature failure on sketch edit

mjordan3
Advocate
Advocate

I'm having an issue where bodies created by AddByDistanceExtent fail after editing the sketch.

 

I create a new part file, create a closed profile in a new sketch, close the sketch, and run the following code to create a new solid body from the selected sketch profile.  If the sketch profile is later edited it will return an error "Profile geometry not found for this feature" and the extrusion will fail.  This happens when editing the part in the assembly environment (always), and in the part environment (most of the time, but not always).  If I double click the extrusion tree feature to re-select the sketch profile, this error does not reoccur. I've attached a test part created in this manner.  This error has occurred on three different computers with different project files.

 

There must be something I'm doing wrong and it is driving me batty. I would appreciate any help. 

 

 

'ilogic code
Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition Dim oProfile As Profile Dim oSketch As Sketch Dim oExtrude As ExtrudeFeature oProfile = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchProfileFilter, "Pick a closed sketch region...") oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, "0.25", kPositiveExtentDirection, kNewBodyOperation)

 

Thanks!

 

0 Likes
1,424 Views
10 Replies
Replies (10)
Message 2 of 11

rogmitch
Advocate
Advocate

I don't see any errors when editing the sketch in either a part or assembly file having used your code to generate the extrusion.  IV Prof 2018 2.3

 

I modified the code to run in VBA.  You could try to see if it works instead. This also works for me.

 

 

Sub Extrude_Sketch()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition

Dim oProfile As Profile
Dim oSketch As Sketch
Dim oExtrude As ExtrudeFeature

Set oProfile = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchProfileFilter, "Pick a closed sketch region...")
Set oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, "0.25", kPositiveExtentDirection, kNewBodyOperation)
End Sub

Roger Mitchell

 

0 Likes
Message 3 of 11

mjordan3
Advocate
Advocate

No dice; the VBA version did not work either.  Though I'm noticing that I'm still on Inventor Pro 2018.1.2.  I'm going to hound IT about getting me the newest update, perhaps that's the issue (for some reason the autodesk desktop app is not letting me download 2018.2.3 at the moment).  Either way, I've created a screencast that displays the issue.

 

 

0 Likes
Message 4 of 11

rogmitch
Advocate
Advocate

I can confirm I copied the steps in your  ScreenCast using the VBA code and saw no errors.  Maybe the latest update will be  the answer.

0 Likes
Message 5 of 11

mjordan3
Advocate
Advocate

I updated to Inventor Pro 2018.2.3 today and am still experiencing the error.  I've tried the following:

  • Two separate computers, on separate networks.
  • Code as Public Sub in application ivb file.
  • Using both a production and default inventor project file.
  • Using default part and assembly file templates.
  • I ran the Inventor reset utility on one computer, with no improvement.

 

Both computers are running Windows 7 x64bit.

 

I'm stumped.

0 Likes
Message 6 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support

Hello @mjordan3,

 

 

Seems editing sketch profile is not allowed for extrude feature.

 

Initially, pick a sketch and create a profile from it. By doing this, sketch can be edited in Assembly document. Try the below iLogic code.

 

Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition

Dim oProfile As Profile
Dim oSketch As Sketch
Dim oExtrude As ExtrudeFeature

oSketch = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Pick a closed sketch region...")
oProfile = oSketch.Profiles.AddForSolid
oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, "0.25", kPositiveExtentDirection, kNewBodyOperation)

Note: Selection of sketch can be done through Model tree.

 

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 7 of 11

mjordan3
Advocate
Advocate

This solves the error I was having, but the behavior breaks the add-in I was working on.  I'd wanted to make an add-in that lets a user selected multiple profiles in succession and creates new extrusion bodies for each selected profile.  This would be used primarily for multibody sheet good layouts (saving the users some time).  If the edit sketch randomly breaks the extrusions under some conditions then I guess it won't work.

 

Is there another way to access each individual profile from a selected sketch?  I tried adding the profiles within the sketch and extruding each as a new body using the following, but returns a type mismatch error:

 

Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition

Dim oProfile As Profile
Dim oSketch As Sketch
Dim oExtrude As ExtrudeFeature

oSketch = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Pick a sketch...")

For Each i In oSketch.Profiles
	oProfile = oSketch.Profiles.AddForSolid(True,oSketch.Profiles.Item(i))
	oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, "0.25", kPositiveExtentDirection, kNewBodyOperation)
Next i

  Or is there as way to set a default distance parameter in the stock extrusion dialogue from the API?

 

Thanks,

M

 

0 Likes
Message 8 of 11

mjordan3
Advocate
Advocate

I've tried adding the individual wires that make up the profile with the Profiles.AddForSolid(Combine, Curves) method, but this doesn't seem to work either.  I've also tried creating an ExtrusionDefinition instead of using the AddForSolid method, but this doesn't seem to help either.

 

Any insight?

 

Sub Main()
	
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition

	Dim oProfile As Profile
	Dim oProfileNew As Profile
	Dim oSketch As PlanarSketch
	Dim oExtrude As ExtrudeFeature
	Dim oExtrudeDef As ExtrudeDefinition

	oProfile = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchProfileFilter, "Pick a closed sketch region...")


'Use AddForSolid to get to the edges within a profile.  Should only get the first item in the Wires collection for now...
	oSketch = oProfile.Parent
	oProfileNew = oSketch.Profiles.AddForSolid(False, oProfile.Wires.Item(1).Edges)

'Try to create a new extrusion definition and use that instaed of using the AddByDistanceExtent
	oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfileNew, kNewBodyOperation)
	oExtrudeDef.SetDistanceExtent("0.25", kPositiveExtentDirection)
	oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)

End Sub
0 Likes
Message 9 of 11

rogmitch
Advocate
Advocate

I had another look at this because I could not understand why I was not seeing an error.  The difference seems to be that I was not closing my saved part before I placed it in the assembly and modified the sketch.  If I do close the part the error is present.

 

Roger Mitchell

0 Likes
Message 10 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support

@mjordan3,

 

oSketch = oProfile.Parent

Sketch may contain many profiles and need to re identify profile sketch entities.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 11 of 11

mjordan3
Advocate
Advocate

Thanks @rogmitch, you're right.  I've also noticed that if you save, close, and reopen the part the same error occurs; there is no need to be in an assembly.

 

Is this a bug in the Inventor API?  To sum up, it seems that the UI Extrude Command and the ExtrudeFeature handles profiles in different ways.

  • You can select individual profiles within a sketch with the UI Extrude Command.  When the curves that make up the profile are edited the created bodies update without issue.
  • When you select individual profiles and use them in an ExtrudeFeature (called with AddByDistanceExtent or ExtrudeFeatures.Add) the resulting solids are created.  But, if the file is closed and reopened, editing the curves that make up the profile in any way will cause the extruded body to fail.

 

I wonder if the profile object that ExtrudeFeature "sees" is destroyed when the profile is edited after the file is reopened.  Conversely, the profile that the Extrude command "sees" is persistent after the file is reopened.  I've tried using ReferenceKeys to define a persistent profile object, but that doesn't seem to work either.

 

 

@chandra.shekar., you say that

 


Sketch may contain many profiles and need to re identify profile sketch entities.

Could you explain? The Extrude command lets you select individual profiles in a sketch that contains multiple profiles, I was hoping to duplicate this functionality by use of the second line a code below... but it didn't work.

 

oSketch = oProfile.Parent
oProfileNew = oSketch.Profiles.AddForSolid(False, oProfile.Wires.Item(1).Edges)

 

 

 

0 Likes