Change lofted flange output type

Change lofted flange output type

wcurtisJM53W
Participant Participant
576 Views
7 Replies
Message 1 of 8

Change lofted flange output type

wcurtisJM53W
Participant
Participant

Using Inventor 2019, I have a sheet metal part with a lofted flange that creates a simple cone.  I want to create iLogic that changes the lofted flange "output type" trait back and forth between Die Formed and any kind of Press Brake.  I created the following code, which successfully changes from Press Brake to Die Formed, but it fails to change from Die Formed to Press Brake.

 

 

Imports Inventor
Sub Main
	Dim oCone As LoftedFlangeFeature = Feature.InventorFeature("PlateCone")
	Dim oConeDef As LoftedFlangeDefinition = oCone.Definition.Copy
	
	Dim bChange As Boolean = False
	
	If PressBrake AndAlso oConeDef.OutputType = LoftedFlangeOutputTypeEnum.kDieFormedLoftedFlange Then
		oConeDef.SetOutputType(LoftedFlangeOutputTypeEnum.kPressBrakeChordToleranceLoftedFlange, "0.1 in")
		
		bChange = True
	ElseIf Not PressBrake AndAlso Not oConeDef.OutputType = LoftedFlangeOutputTypeEnum.kDieFormedLoftedFlange Then
		oConeDef.SetOutputType(LoftedFlangeOutputTypeEnum.kDieFormedLoftedFlange)
		
		bChange = True
	End If
	
	If bChange Then
		oCone.Definition = oConeDef
		
		InventorVb.DocumentUpdate()
	End If
End Sub

 

 

"PressBrake" is a boolean parameter.

 

Thanks.

 

0 Likes
577 Views
7 Replies
Replies (7)
Message 2 of 8

wgraham
Advocate
Advocate

The ElseIf portion of your logic looks kind of odd as essentially a negative of the first if.  Does it work if you do a simple else instead?  There's nothing in this code showing the value of PressBrake changing.  If set originally to true with a kDieFormedLoftedFlange it would trip the change.  If PressBrake doesn't change and is still set to true, it would fail on the kPressBrakeChordToleranceLoftedFlange for the first logic check and fail on Not True = False on the second logic check.

0 Likes
Message 3 of 8

wcurtisJM53W
Participant
Participant

This is a cross of two boolean tests, comparing the value of PressBreak against the current output type.  If they already match, I don't want to change anything and trigger an unnecessary update.  So there are four possible outcomes.

 

  • PressBrake is true, Output Type is any Press Brake (do nothing)
  • PressBrake is true, Output Type is Die Formed (change to Press Brake)
  • PressBrake is false, Output Type is any Press Brake (change to Die Formed)
  • PressBrake is false, Output Type is Die Formed (do nothing)

My logical tests don't explicitly show the "do nothing" results.

 

Also, I've tested (with message boxes, since removed) for properly navigating the logical test and running the right code.  The program takes the expected path, runs the "SetOutputType" code without error, but has no visible effect when changing from Die Formed to Press Brake.

0 Likes
Message 4 of 8

wgraham
Advocate
Advocate

The code shown picks between two options.  Actually possible variations are for all Inventor output types is 8.

 

PressBrake = True & OutputType = kDieFormedLoftedFlange

PressBrake = False & OutputType = kDieFormedLoftedFlange

PressBrake = True & OutputType = kPressBrakeChordToleranceLoftedFlange

PressBrake = False & OutputType = kPressBrakeChordToleranceLoftedFlange

PressBrake = True & OutputType = kPressBrakeFacetAngleLoftedFlange

PressBrake = False & OutputType = kPressBrakeFacetAngleLoftedFlange

PressBrake = True & OutputType = kPressBrakeFacetDistanceLoftedFlange

PressBrake = False & OutputType = kPressBrakeFacetDistanceLoftedFlange

 

Based on a quick test in VBA, did notice that the first time running it showed visual change but adjusting the chord tolerance made it more noticeable.

0 Likes
Message 5 of 8

djguiVEC2U
Participant
Participant

From the testing I just did, I noticed that Inventor just can't create a PressBrake from an active DieFormed Lofted Flange. As knowing if this is an Inventor bug or a "feature" is not of my issue, I offer you this solution

 

You can quickly delete the feature and create a new one from oConeDef as show in the below code

 

If bChange Then
            oCone.Definition = oConeDef
            oDoc.Update()
ElseIf pbchange = True Then
     oCone.Delete(True, True, True)
     oDoc.ComponentDefinition.Features.Add(oConeDef)
End If

 

Just add the pbchange boolean in your first if checking if its a DieFormed

 

  If PressBrake AndAlso oConeDef.OutputType = LoftedFlangeOutputTypeEnum.kDieFormedLoftedFlange Then
            oConeDef.SetOutputType(LoftedFlangeOutputTypeEnum.kPressBrakeChordToleranceLoftedFlange, "0.1 in")
pbchange = True

 

NOTE THAT THIS MAY **** EVERYTHING UP IF YOU HAVE ANY FURTHER DEPENDANCE ON THIS CONE

 

0 Likes
Message 6 of 8

wcurtisJM53W
Participant
Participant
That's true, but I'm okay with changing to any kind of Brake because the user can then change to another variety of Brake by editing the feature using Inventor's native tools. If I can get it to change from Die Formed to any Press Brake, and back, that will be a victory.
0 Likes
Message 7 of 8

wcurtisJM53W
Participant
Participant

Right, that's why I would like to avoid this approach.  It's likely that users will have already modeled with this cone, adding bevels and holes and such, and then our fab shop will decide that they want it presented the other way.  I would like to minimize the impact on downstream features as much as possible.

 

0 Likes
Message 8 of 8

djguiVEC2U
Participant
Participant

Well if you think about it
PressBrake creates a polygon

DieFormed creates a diameter,

 

It likely that if someone referenced the geometry of the pressbrake, the reference will be broken when changing to a die formed. 

I think the best way would be to use the base sketch for further reference. Like if you have to use it in assembly, use the sketch for constraint, because the sketch won't be affected by the change.

That's my take on it, it's probably always going to create errors, but you probably know more than me the problem it creates for you

 
0 Likes