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: 

Control Sheet Metal Cut Direction

25 REPLIES 25
Reply
Message 1 of 26
JBerns
1342 Views, 25 Replies

Control Sheet Metal Cut Direction

Community,

 

I have a sheet metal part with a cut.

 

2023-09-22_12-23-08.png

 

I am trying to control cut direction (Positive, Negative, or Symmetric).

 

All attempts to modify the cut definition result in errors.

For example:

System.NotImplementedException: 'Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))'

 

I have tried Enumerators and numbers.

I have tried changing Extent, ExtentType, and SetThroughAllExtent, but all result in errors.

 

	' Set extents to Through All Negative
	Call oCutDefinition.SetThroughAllExtent(kNegativeExtentDirection)
	Call oCutDefinition.SetThroughAllExtent(20994)

 

Is it possible to change a sheet metal cut feature direction using API/iLogic?

 

I have attached a part with my code for your to review.

 

I look forward to hearing of a solution.

 

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Labels (1)
25 REPLIES 25
Message 2 of 26
J-Camper
in reply to: JBerns

@JBerns,

 

While it may seem like you can change things because it has derived class Methods, the CutFeature.Definition Object  is Read Only.  The methods are only accessable when you create a new definition, before it is used to create a Cut Feature.  If you look up, for example, the ExtrudeFeature.Definition Object, it is Read/Write, and can be edited.

 

Unfortunately, you would have to re-create the cut feature to change the Definition.

Message 3 of 26
JBerns
in reply to: J-Camper

@J-Camper,

 

So an Extrusion feature can be changed, but a  Cut feature can't?

 

If that is the case, I hope the Development team can add this in a future version.

 

I'll visit the IdeaStation.

 

In the meantime, I will test getting the existing Cut feature info, delete the Cut feature preserving the Profile sketch, and then recreating the Cut feature. That seem like a lot of work.

Maybe I will do an Extrusion with distance = Thickness rather than messing around with a Cut feature.

 

Thanks again for the feedback. I will mark your reply as the solution if no one else has a better solution.

 

Regards,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 4 of 26
J-Camper
in reply to: JBerns

@JBerns,

 

Yeah I've never compiled a full list of Read-only vs Read/Write Feature Definitions.  BoundaryPatch Definitions are also read-only but Move Definitions are Read/Write.  [As 2 other examples]  It is just something I know to check because I ran into it before, when working with boundary patch features.

 

You can still use the ThroughAll extent type with a Cut Extrusion.

 

 

Message 5 of 26
JBerns
in reply to: JBerns

Is it possible to delete a feature without deleting the associated sketch?

I have tried all the Delete methods I can find and they all delete the sketch.

 

Based on above discussion to "change" cut direction, I need to delete the existing cut feature and recreate it. I hope I can preserve the sketch so that it need not be drawn each time.

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 6 of 26
WCrihfield
in reply to: JBerns

That's odd.  You should just be able to use something like CutFeature.Delete method, and specify True to all 3 of the optional inputs.  I was thinking that Delete method was common amongst most of the common types of features.  You are saying that those specifications within the Delete method are not working for you?

Edit:  Tried the SheetMetalComponentDefinition.DeleteObjects(oCollection, True, True, True) method?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 26
JBerns
in reply to: JBerns

Please disregard delete feature and preserve sketch request. I found the answer in API Help.

The IntelliSense suggestions weren't working when in the iLogic editor.

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 8 of 26
JBerns
in reply to: JBerns

@J-Camper,

 

Using the link you provided, I could only verify that 4 of the 17 sheet metal features had read-write definitions.

 

I could not find a Definition property for those features marked with ??

 

JBerns_0-1695834937066.png

 

 Since 95% of our designs use sheet metal parts, this could severely impact automation.

 

As I understand the workflow now for editing sheet metal parts with RO feature definitions, I will have to:

  1. delete the feature while preserving the sketch
  2. change the feature definition
  3. recreate the feature

Would you agree?

 

I hope this limited editing ability will be addressed in a future version of Inventor.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 9 of 26
J-Camper
in reply to: JBerns

@JBerns,

 

I only looked up 1 of the ?? features in your list and found that there doesn't even seem to be a Method to add a ContourRollFeture under the ContourRollFeatures Object.  It appears as though you can only access exiting features Properties.  I'm not sure why the API is so limited for most of the sheet metal features.

Your workflow seems to be correct.  I would just add that for complex parts, you may need to preserve and re-associate child features that are dependent on previous features you re-create this way.  It might be beneficial to look into non-sheetmetal features that might have RW definitions and provide similar results, like substituting Extrude[cut] for Cut features.

 

I'm not sure if it would be more or less work for some of your parts to include both options as separate features and create ModelStates to suppress/unsuppress features you want for different applications.  Your Automation would then just determine which ModelState to activate and adjust and Parameters necessary

Message 10 of 26
WCrihfield
in reply to: JBerns

The idea of some feature definitions being ReadOnly, and some Read/Write doesn't seem entirely correct.  The Definition property of the feature may be ReadOnly, which would simply mean that you can not set another definition type object as its value, but that does not necessarily mean that you can not go into the existing definition and make changes to its properties, then update the model.  Just pointing that little detail out.  Editing features by code can be more complicated than it seems like it should be, because when looking at a code screen, it is difficult to keep a lot of other things in mind.  For instance, sometimes when you do something manually, a dialog will pop-up letting you know that the edit will not work, and/or may offer you the opportunity to accept the changes, or edit the feature again.  You don't get that when doing it by code...it will simply fail.  Sometimes when doing it manually, you must simply accept the result, even though there may still be problems going on, and sometimes the problem is not even that edit, it is something else, but it is warning you about the existing errors anyways.  Sometimes there are two or more errors, and you must fix 2 things before the error warning will go away, but when fixing the first thing, it warns you that there is still an error, but the error might not be associated with what you just changed.  Doing these things by code, you give up on those user interface helpers, and little nuances that make sense, but may be a bit unpredictable.  Just thinking through the keyboard. 😉

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 11 of 26
JBerns
in reply to: WCrihfield

@J-Camper / @WCrihfield,

 

Thanks for the quick reply and feedback. I am clearly not editing the definition correctly if some of these properties are editable.

 

So given a contour flange, would it be possible to edit the Width Extents Direction and Width Extent Distance?

JBerns_0-1695838185111.png

 

I found a solution by @JelteDeJong that edits the Offset Direction:

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/contour-flange-offset-direction/td-p... 

 

Regards,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 12 of 26
J-Camper
in reply to: JBerns

@JBerns,

 

I may have spoken a bit out of turn earlier.  The definition being Read/Write would indicate you can't set the definition equal to another, but the Read only Definition may still have properties that are read/write.

 

The best way to find out is to try but, since the ExtentDirection Property under the Definition is Read/write, I would assume you could use the SetDistaceExtent Method to control distance and direction.  Otherwise you should be able to set the ExtentDirection Property and the associa

Message 13 of 26
JBerns
in reply to: JBerns

Here is the code I used to explore a contour flange built with default settings:

 

Dim f As ContourFlangeFeature = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFeatureFilter, "")
Dim fDef As ContourFlangeDefinition = f.Definition
break

' Report feature definition
Try
	MsgBox("Contour Flange Info: " & _
	vbCrLf & vbCrLf & _
	"DefaultWidthExtent: " & fDef.DefaultWidthExtent.Type.ToString & vbCrLf & _
	"DefaultWidthExtentType: " & fDef.DefaultWidthExtentType.GetTypeCode.ToString & vbCrLf & _
	"ExtentDirection: " & fDef.ExtentDirection.ToString & vbCrLf & _
 _	' "GetWidthExtent: " & fDef.GetWidthExtent.ToString & vbCrLf & _
 _	' "GetWidthExtentType: " & fDef.GetWidthExtentType.ToString & vbCrLf & _
 _	' "SetDistanceExtent: " & f.SetDistanceExtent.tostring & vbCrLf & _
	"MiterGap: " & fDef.MiterGap.ToString & vbCrLf & _
	"Operation: " & fDef.Operation.ToString & vbCrLf & _
 _	' "SetCenteredDefaultWidthExtent: " & fDef.SetCenteredDefaultWidthExtent & vbCrLf & _
 _	' "SetCenteredWidthExtent: " & fDef.SetCenteredWidthExtent & vbCrLf & _
 _	' "SetDistanceExtent: " & fDef.SetDistanceExtent & vbCrLf & _
 _	' "SetEdgeDefaultWidthExtent: " & fDef.SetEdgeDefaultWidthExtent & vbCrLf & _
 _	' "SetEdgeWidthExtent: " & fDef.SetEdgeWidthExtent & vbCrLf & _
 _	' "SetFromToDefaultWidthExtent: " & fDef.SetFromToDefaultWidthExtent & vbCrLf & _
 _	' "SetFromToWidthExtent: " & fDef.SetFromToWidthExtent & vbCrLf & _
 _	' "SetOffsetDefaultWidthExtent: " & fDef.SetOffsetDefaultWidthExtent & vbCrLf & _
	"", , _
	"DEBUG")
Catch ex As Exception
	MsgBox("Error: " & ex.Message)
End Try
BREAK

 

 

I was hoping to edit offset direction, extent direction, and extent distance.

So far, only success with offset direction using Jelte's code.

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 14 of 26
JBerns
in reply to: JBerns

Found access to the Extent Distance property:

f.Definition.DefaultWidthExtent.Distance.Expression = "2.0 in"

The Distance and Expression properties were not suggested by the IntelliSense tool when typing in the iLogic Editor. Used Visual Studio debugging to discover these. Maybe could have used Object Browser in the VBA Editor.

 

Now to change the extent direction. These all produce errors:

Call f.Definition.DefaultWidthExtent.Direction(PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
Call f.Definition.DefaultWidthExtent.Direction(kPositiveExtentDirection)

f.Definition.DefaultWidthExtent.Direction = PartFeatureExtentDirectionEnum.kPositiveExtentDirection
f.Definition.DefaultWidthExtent.Direction = kPositiveExtentDirection

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 15 of 26
J-Camper
in reply to: JBerns

@JBerns,

 

Does this work, with fDef As As ContourFlangeDefinition, or f.Definition?:

 

fDef.SetDistanceExtent( "2.0 in", PartFeatureExtentDirection.kPositiveExtentDirection ) 

 

Otherwise you could try the ContourFlangeDefinition.ExtentDirection Property 

 

 

Message 16 of 26
WCrihfield
in reply to: JBerns

Hi @JBerns.  Just got back here after a lot of other stuff.  Looking at your last post, and seeing that you are now trying to change the extent direction made me curious about why you are not simply using the other property by that name (ContourFlangeDefinition.ExtentDirection), which is a Read/Write property, and has a value from the PartFeatureExtentDirectionEnum.   But I did find it interesting that you found that (most likely hidden) property.  There are only a couple Get methods, but there are a bunch of Set type methods available to the ContourFlangeDefinition object, so it just seems like one of them should be able to serve your needs, without needing to dig into hidden properties through VS.  For instance, the ContourFlangeDefinition.SetDistanceExtent method lets you specify both distance and direction.  The ContourFlangeDefinition.SetWidthOffsetDefaultWidthExtent method, and the ContourFlangeDefinition.SetWidthOffsetWidthExtent method do also.  Plus the distance can be either a direct numerical value, or a String, which would be evaluated like setting the Expression of a parameter, so that makes it easier to avoid automatic units conversions.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 17 of 26
JBerns
in reply to: JBerns

@J-Camper,

Your code example is close for creating the contour flange. Just needed to add 'Enum'.

 

fDef.SetDistanceExtent( "2.0 in", PartFeatureExtentDirectionEnum.kPositiveExtentDirection ) 

 

Again, this works for creating the contour flange. It cannot be used to edit the contour flange.

 

System.NotImplementedException: 'Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))'

 

Regarding switching from a Cut feature to an Extrude feature, Extrude does not support Cut Normal.

 

JBerns_0-1696003510932.png

 

I appreciate the suggestions though.

 

Regards,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 18 of 26
J-Camper
in reply to: JBerns

@JBerns,

 

Sorry about leaving off the "Enum" suffix.  Did you try setting the fDef.ExtentDirection Property of an exsting feature?  The online help resource says it is a read/write property.

 

I see the limitation with the Extrude[Cut] feature in your application.  The Cut feature definitely seams like the ideal feature for that application.  I don't work with sheet metal, so I didn't even realize Normal extrusion was possible from a single sketch.

Message 19 of 26
JBerns
in reply to: JBerns

@WCrihfield,

 

I have been able to create a contour flange or cut feature, but there are definite limitations to editing existing features.

 

For example this code can create the contour flange feature, but can only change the extent direction.

''' CREATE '''
oCFDef.ExtentDirection = PartFeatureExtentDirectionEnum.kPositiveExtentDirection
Call oCFDef.SetDistanceExtent(5, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)

' code to create contour flange normally here. Removed for brevity.

''' EDIT '''
oCF.Definition.ExtentDirection = PartFeatureExtentDirectionEnum.kNegativeExtentDirection  '<<== SUCCESS
call oCF.Definition.SetDistanceExtent(5, PartFeatureExtentDirectionEnum.kNegativeExtentDirection) '<<== ERROR - See below

System.NotImplementedException: 'Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))'

 

When exploring the available properties in Visual Studio, it seems that all of the 'Set...' properties are missing.

 

JBerns_1-1696006592716.png

 

I have attached my part that creates the sheet metal part contour flange and then attempts to edit the feature.

Perhaps you or @J-Camper can find something I have overlooked.

 

I appreciate all the feedback provided.

 

 

Regards,

Jerry

 

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 20 of 26
J-Camper
in reply to: JBerns

@JBerns,

 

I changed Line 213 to set Direction through ".Definition.ExtentDirection"

 

I split the SetDistanceExtent @ Line 223 into two parts:

  1. Set distance through ".Definition.DefaultWidthExtent.Distance.Value" [.Expression can be used, but the code was just feeding in value so I followed that]
  2. Set Direction through ".Definition.ExtentDirection"

I got it functioning with minimal changes to produce no errors and attached the working code from my downloaded file. [I did change the template to one that I have]

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

Post to forums  

Autodesk Design & Make Report