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: 

Change Flange Direction via API

9 REPLIES 9
Reply
Message 1 of 10
MegaJerk
1081 Views, 9 Replies

Change Flange Direction via API

I am having a heck of a time cracking this one, despite the fact that I assume that there is something small and simple that I’m just missing. Is there an appropriate way to change the flange direction on a Flange Feature that has been created (on a sheet metal part) using a user selected edge using the API? As of now, the code that I have seems obvious enough:

Sub ExtrusionDir()
  ' TEST VBA CODE

  Dim oDoc As PartDocument
  Set oDoc = ThisApplication.activeDocument
  
  Dim oDef As PartComponentDefinition
  Set oDef = oDoc.ComponentDefinition
  
  Dim oFlangeFeatures As FlangeFeatures
  Set oFlangeFeatures = oDef.Features.FlangeFeatures
  
  Dim oFlangeFeature As FlangeFeature
  Set oFlangeFeature = oFlangeFeatures.Item(1)
  
  Dim oFlangeDef As FlangeDefinition
  Set oFlangeDef = oFlangeFeature.Definition
  
  Dim oExtent As DistanceHeightExtent
  Set oExtent = oFlangeDef.HeightExtent
     
  oExtent.FlangeDirection = 20994


    ' PartFeatureExtentDirectionEnum:
    'kNegativeExtentDirection  = 20994
    'kPositiveExtentDirection  = 20993
    'kSymmetricExtentDirection = 20995

End Sub

 

but simply changing the FlangeDirection property results in errors and bad times. According to the API documentation Flange Direction is a “Property that gets and sets the direction of the flange.” Despite being listed clearly as Read Only & Get / Settable.

So with that, do any of you have a solution for this wee problem? 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
9 REPLIES 9
Message 2 of 10
philippe.leefsma
in reply to: MegaJerk

I can't even run the code, the line to affect flange direction fails. I think it is an issue with the setter of FlangeDirection property.

 

flange.png

 

I will log a change request and let you know the reference from the escalated ADN case.

 

I don't see a workaround for that at the moment, sorry for the bad news,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 10
MegaJerk
in reply to: philippe.leefsma

It is good to know that I am not 100 percent crazy. Thank you for looking into this! 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 4 of 10

The issue seem to persist... 😞 

On creating a Flange and passing the Unfoldmethod to the flangedefinition has no effect on the flangefeature...

The Flangedefinition itself has the overwritten unfoldmethod....

Are there any updates on this? Testing with the 2014 (r18) Inventor. is this fixed by later versions?

BR,

Daniel

Message 5 of 10
MegaJerk
in reply to: daniel.balogh

Just tried to do this in Inventor 2015 SP1 Update 1, and I'm still getting the same error...

Autodesk mods, is there a way to know if an issue is resolved or even being worked on? Is there some sort of public ticket system that people can see? 

This type of error (extent flipping) is certainly not limited to just the flange feature, but also plagues other sheetmetal features (with the exception of the Lofted Flange oddly enough)! 

It would really be nice to have this fixed... 




If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 6 of 10
philippe.leefsma
in reply to: MegaJerk

Unfortunately there is no public access to our issue database.

 

If you are an ADN partner, you could log a case in our system and provide a business case which may impact the priority of a fix.

 

Sorry for the bad news.

 

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 7 of 10
daniel.balogh
in reply to: MegaJerk

Hi,

 

in my case (creating a FlangeFeature by API)  I found a workaround setting the Unfoldmethod-Property. After creating the Flangefeature I can set the desired property in a separate sub, getting the Feature by Name from the SheetmetalComponentDefinition.FlangeFeatures(Name).Definition and setting it's property.

So it seems to work on "existing" features but not at the time adding the Feature by Definition. 

This might not help on iLogic but perhaps someone else is finding this post...

BR,

Daniel

Message 8 of 10
MegaJerk
in reply to: daniel.balogh

Got a code snippet to share? 

It would be helpful if you posted it. 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 9 of 10

Hi,

 

I can't really strip out a working snippet for this. Actually I do call the modification in after the creation (I guess - but may be wrong - it has something to do with the closing of the transaction).

 

here some PseudoCode:

  

Public Class DummyForm
    'Click-Eventhandler of a Control
    Sub ButtonClick()
        Dim e As EdgeCollection '=... Select Edges with Interaction
        DummyClass.CreateFlange(e)
        'after creation set the unfoldmethod...
        DummyClass.SetUnfoldMethod("myUnfoldMethodName") 'Unfoldmethod has to exist either locally or in library
    End Sub
End Class

Public Class DummyClass
    Private Shared flangefeature As FlangeFeature = Nothing
    Private Shared ReadOnly Property cd As SheetMetalComponentDefinition
        Get
            'Assume activeDoc is SheetmetalDoc
            Return TryCast(iApp.ActiveDocument, PartDocument).ComponentDefinition
        End Get
    End Property

    Public Shared Sub CreateFlange(edges As EdgeCollection)
        If cd Is Nothing Then Return

        Dim features As SheetMetalFeatures = cd.Features
        Dim ffeatures As FlangeFeatures = features.FlangeFeatures

        Dim fd As FlangeDefinition = ffeatures.CreateFlangeDefinition(edges, "90 deg", "25 mm")
        'Set up feature, like
        'fd.BendRadius...
        flangefeature = ffeatures.Add(fd)

    End Sub

    Public Shared Sub SetUnfoldMethod(name As String)
        If cd Is Nothing Then Return
        If flangefeature Is Nothing Then Return

        flangefeature.Definition.UnfoldMethod = cd.UnfoldMethods(name)
        flangefeature = Nothing
    End Sub

End Class
Message 10 of 10
daniel.balogh
in reply to: MegaJerk

Hi,

 

I discovered the SetDistanceHeightExtent-Method of the flangedefinition object (inventor 2016, Interop version 20 - not tested on earlier versions).

You can use this to acheive a direction change:

 

 

fd.SetDistanceHeightExtent(fd.HeighExtent.Distance, PartFeatureExtentDirectionEnum.kPositiveExtentDirection, HeightDatumTypeEnum.kHeightDatumOuter)

where you should check the current Direction before and use the desired opposite...

 

For sake of completeness, you can change other properties as well by "disconnecting" and reassign to the feature:

 

            Dim co As CornerOptions = ffd.CornerOptions.Copy 'ffd=myExistingFlangeFeature.Definition

            co.CornerReliefShape = CornerReliefShapeEnum.kRoundCornerReliefShape
            co.CornerReliefSize = "New Value, can be String/Double, whatever"
            ffd.CornerOptions = co 'reassign the copied Object to the Definition

 

However, it seems you cannot assign values to some Properties directly, rather you have to redefine it's parent...

HTH,

Daniel

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

Post to forums  

Autodesk Design & Make Report