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

Add Custom Properties Sheet metal extends - Assembly contex

Hi!

 

I'm trying to create two custom properties (Flat Pattern Extends: With and Length) in sheet metal parts within main assembly.

I tried another code, but it's only create the properties in the main assembly, not in the parts.

 

Now, I'm trying this code below, but it's not working yet.

 

Any help?

Thanks.

 

SyntaxEditor Code Snippet

Dim openDoc As Document
openDoc = ThisApplication.activedocument
Dim docFile As Document
'Is Assembly?
If openDoc.DocumentType = 12291 Then

    For Each docFile In openDoc.AllReferencedDocuments
        'Is Sheet Metal File? (assuming it has FP already)
        If docFile.SubType.Equals("{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then
    
                'if yes, Assuming it has a Flat Pattern deffined
            Dim smComp As SheetMetalComponentDefinition 
            smComp = docFile.ComponentDefinition
            
            If smComp.HasFlatPattern = True Then
                    
                    'CREATE With and Length as user properties (NOT WORKING)
                        Dim Prop_Length As String
                        Dim Prop_With As String
                        
                        oCustomPropertySet = ThisDoc.Document.PropertySets.Item _
                    ("Inventor User Defined Properties")
                        
                        oCustomPropertySet.Add("Custom", Prop_Length)
                        oCustomPropertySet.Add("Custom", Prop_With)
                            
                    'Adds Flat Pattern extends (Length and With) as a custom propertie (ready to use in a Part List Column) (NOT WORKING)
                        docFile.oCustomPropertySet.Item("Design Tracking Properties").Item("Custom", "Length").Value = "=<Sheet Metal Length>"
                        docFile.oCustomPropertySet.Item("Design Tracking Properties").Item("Custom", "Width").Value = "=<Sheet Metal Width>"
                    'THIS LINE IS TO ABLE THE Thickness PARAMETER TO GET READY TO EXPORT IN EACH SHEET METAL PART    (WORKING)            
                        docFile.ComponentDefinition.Parameters("Thickness").ExposedAsProperty = True 
                    
            Else    
                MessageBox.Show("No Flat Pattern Info ", "INFO!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)        
            End If    
        Else
            MessageBox.Show("Not a SM Part", "INFO!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
        End If
    Next

Else
MessageBox.Show("This is not an Assembly", "File Type Mismatch!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
End If

 

 

CCarreiras

EESignature