How to change the CornerReliefShape of a sheet metal corner

How to change the CornerReliefShape of a sheet metal corner

Anonymous
Not applicable
789 Views
6 Replies
Message 1 of 7

How to change the CornerReliefShape of a sheet metal corner

Anonymous
Not applicable

Hi everyone,

 

   I meet with a problem about the CornerReliefShape recently.

   I want to change all the CornerReliefShape to "ArcWeld" for all the corners in the one sheet metal with vba.

   But when i try to change the vaule of the CornerReliefShape directly ,the programe cause a error.

   Here is my vba code ,someone can help me?

Many thanks!

 

 VBA Code:

Public Sub test()

 Dim oPartDoc As PartDocument
 Set oPartDoc = ThisApplication.ActiveDocument

 Dim oSheetMetalCompDef As SheetMetalComponentDefinition
 Set oSheetMetalCompDef = oPartDoc.ComponentDefinition
 Dim oFeature As PartFeature
 For Each oFeature In oSheetMetalCompDef.Features
   Select Case oFeature.Type
      Case kCornerFeatureObject
        Dim oCornerFeature As CornerFeature
        Set oCornerFeature = oFeature
       oCornerFeature.Parameters.Item(1).Value = 0.78
       oCornerFeature.Parameters.Item(5).Value = 0.65
       oCornerFeature.Definition.CornerOptions.CornerReliefShape = kArcWeldCornerReliefShape
   End Select
Next
End Sub
001.jpg

 

 

001.jpg

 

 

 

0 Likes
790 Views
6 Replies
Replies (6)
Message 2 of 7

MechMachineMan
Advisor
Advisor
Use either oCornerFeature.Definition.CornerOptions.CornerReliefShape = CornerReliefShapeEnum.kArcWeldCornerReliefShape OR oCornerFeature.Definition.CornerOptions.CornerReliefShape = 28425
CornerReliefShapeEnum Enumerator 
Description 
Constants identifying the corner relief shape.
Methods 
Name  Value  Description  
kArcWeldCornerReliefShape 28425 Constants identifying arc weld corner relief shape. 
kDefaultCornerReliefShape 28422 Constants identifying default corner relief shape. 
kFullRoundCornerReliefShape 28428 Constants identifying full round corner relief shape. 
kIntersectionCornerReliefShape 28427 Constants identifying intersection corner relief shape. 
kLinearWeldReliefShape 28421 Constants identifying linear weld corner relief shape. 
kNoReplacementCornerReliefShape 28426 Constants identifying no replacement corner relief shape. 
kRoundCornerReliefShape 28417 Constants identifying round corner relief shape. 
kRoundWithRadiusCornerReliefShape 28429 Constants identifying intersection corner relief shape. 
kSquareCornerReliefShape 28418 Constants identifying square corner relief shape. 
kTearCornerReliefShape 28419 Constants identifying tear corner relief shape. 
kTrimToBendReliefShape 28420 Constants identifying trim to bend relief shape. 

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 7

Anonymous
Not applicable

Hi Justin,

 

    Thank you very much for your quickly reply!

    I have tried the two methods you supported, but the programe still cause a error("object doesn't support this acction"), here is my test model(Inventor version:2016) wiht  vba code, could you please help me to have a look what is the problem.

    Thank you  again!

error message.JPG

 

0 Likes
Message 4 of 7

xiaodong_liang
Autodesk Support
Autodesk Support
Hi tkyjl,

I can reproduce this issue. It looks a problem to me. Unfortunately, I have not got a workaround. I will log this issue with engineer team.
Message 5 of 7

Anonymous
Not applicable

liang gong,

 

  Thank you very much for your quickly reply.

  I will find another way such as alarm message to the users instead of modifing the model directly.

 

Thank you again

0 Likes
Message 6 of 7

xiaodong_liang
Autodesk Support
Autodesk Support
The number of the issue I logged is #115603:API failed to change the CornerReliefShape of a sheet metal corner
0 Likes
Message 7 of 7

MegaJerk
Collaborator
Collaborator

I had this same problem with the BendReliefShape for any sort of bend on a sheet metal part. There is a note that this is not possible via the API in the Inventor 2012 API Help document

"This property is writable when the BendOptions object is transient (not associated with a feature). You can set the desired value before using the BendOptions object as input to create a sheet metal feature. When the BendOptions object has been obtained from an existing feature this property is read-only."

and judging by your problem, it looks like it applies to all feature options.

While I was unable to access the bend shape outright, I was able to at least invoke the dialog on each bend depending on a set of conditions. I have remade this code for you in the hopes that you can use it to make a workaround that will better suit your needs.

NOTE: This code must be ran from an ASSEMBLY

Public Sub UpdateBends()

  Dim oDoc As Document
  
  If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
    Exit Sub
  Else
    Set oDoc = ThisApplication.ActiveDocument
  End If
  
  Dim oCommandMgr As Inventor.CommandManager
  Set oCommandMgr = ThisApplication.CommandManager
  
  Dim oControlDef As ControlDefinition
  Dim oControlDefCommand As String
  
  Dim oDocumentsEnumerator As DocumentsEnumerator
  Set oDocumentsEnumerator = oDoc.AllReferencedDocuments
  
  Dim oDocOccs As ComponentOccurrences
  Set oDocOccs = oDoc.ComponentDefinition.Occurrences
  
  Dim oDocument As Document
  For Each oDocument In oDocumentsEnumerator
   
    Dim oCompOcc As ComponentOccurrence
    For Each oCompOcc In oDocOccs.AllReferencedOccurrences(oDocument)
      If oCompOcc.Suppressed = False Then
          oCompOcc.Edit
          Exit For
      End If
    Next
    
    If oDocument.DocumentType = kPartDocumentObject Then
      If oDocument.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
        Debug.Print (oDocument.DisplayName)
        Dim oDocCompDef As ComponentDefinition
        Dim oFeatures As SheetMetalFeatures
        Dim oFeature As PartFeature
        
        Dim oCornerFeature As CornerFeature
        Dim oCornerDefinition As CornerDefinition
        Dim oCornerOptions As CornerOptions
        Dim oCornerFeatureProxy As CornerFeatureProxy
        
        Set oDocCompDef = oDocument.ComponentDefinition
        Set oFeatures = oDocCompDef.Features
  
        If oFeatures.Count > 0 Then
          For Each oFeature In oFeatures
  
            If oFeature.Type = kCornerFeatureObject Then
              Set oCornerFeature = oFeature
            End If
  
            If Not oCornerFeature Is Nothing And oFeature.Suppressed = False Then
              Set oCornerDefinition = oCornerFeature.Definition
              Set oCornerOptions = oCornerDefinition.CornerOptions
              If oCornerOptions.CornerReliefShape <> kArcWeldCornerReliefShape Then
              
                oControlDefCommand = "SheetMetalCornerEditCtxCmd"
                Call oCompOcc.CreateGeometryProxy(oFeature, oCornerFeatureProxy)
                Call ThisApplication.ActiveDocument.SelectSet.Select(oCornerFeatureProxy)
                
                If oControlDefCommand <> "" Then
                    Set oControlDef = oCommandMgr.ControlDefinitions.Item(oControlDefCommand)
                    Call oControlDef.Execute2(True)
                    Call ThisApplication.ActiveDocument.SelectSet.Clear
                End If
                
                oControlDefCommand = ""
                
              End If
            End If
          Next
        End If
      End If
    End If
    Call oCompOcc.ExitEdit(kExitToPrevious)
  Next
  If oDoc.SelectionPriority <> kComponentSelectionPriority Then
      oDoc.SelectionPriority = kComponentSelectionPriority
  End If
End Sub












xiaodong.liang : Could you also put in a ticket so that ALL features can be updated after they have been created and are out of their transient state? It would be a nice improvement and way more consistent. 



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

GitHub