Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Clean-Up of Sheet Metal Styles / Unfold Methods / Materials

matthew.claxton
Explorer

Clean-Up of Sheet Metal Styles / Unfold Methods / Materials

matthew.claxton
Explorer
Explorer

I am attempting to clean up existing sheet metal parts that contain bad data relating to sheet metal styles, materials, and unfold rules.  These are all embedded locally in each part, and am looking to purge / delete this outdated data.  I can find my way around the INV 2013 API with little issue, but am running into a few speed bumps.  Three main questions.

 

1) I am receiving errors when trying to run the following code.  Is the "UpdateFromGloal" method not avaliable for the sheet metal sytles object?  According to the API documentation, this should be supported (see attached snapshot).

 

Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument

Dim smDef As SheetMetalComponentDefinition
Set smDef = oPartDoc.ComponentDefinition

Dim oStyle As SheetMetalStyle

' Clean up old sheet metal styles from part
For Each oStyle In smDef.SheetMetalStyles
    If Not oStyle.StyleLocation = kLibraryStyleLocation Then
            oStyle.UpdateFromGlobal
    End If
Next

 

 

2) Same issue, but in attempting to use the "UpdateFromGlobal" method with the UnfoldMethod object.  Is this also not a valid method for this object? (see attached snapshot)

 

3) Deleting materials from being locally embedded in parts.  Receiving the same error as above, but this time it is shown when attempting to delete materials that are not in-use.  Again, API documentation shows this as a valid call.  (error shapshot attached)

 

Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument

' Define material
Dim oMaterial As material

' Clean up embedded materials in local part
For Each oMaterial In oPartDoc.Materials
    If Not oMaterial.InUse Then
        oMaterial.Delete
    End If
Next

 

 

Any insight would be much appreciated!

 

 

 

0 Likes
Reply
562 Views
3 Replies
Replies (3)

xiaodong_liang
Autodesk Support
Autodesk Support
Hi matthew.claxton,

Can I understand all codes are tested with Inventor 2013? it is a version that we are not supporting now, but I gave a quick test in 2015. it looks the 1 and 2 codes can work, while 3 failed. but what I tested with is a empty sheet metal, so for code 3, the failure might because I am deleting the materials in the library.

anyway, could you share a test sheet metal ? I can diagnose for 1-3 together.
0 Likes

matthew.claxton
Explorer
Explorer

Yes, all API calls are being used within INV 2013.  The good thing is we are planning an upgrade to 2015 at the end of the year, so the fact that these are functional within this version is great.

 

I've attached a sample part, as well as the XML which contains a snapshot of the materials in our Content Center.

 

Thank you for the assistance.

0 Likes

xiaodong_liang
Autodesk Support
Autodesk Support
Hi,

Sorry for late response.

with your file, the 1st code also failed in Inventor 2015. but this style is InUse I also tested with a sheet metal style that is NOT InUse, it does not either work. I doubt I missed something. I will a bit more time to investigate.
0 Likes