Recognize bending in sheet metal parts

Recognize bending in sheet metal parts

Anonymous
Not applicable
5,442 Views
36 Replies
Message 1 of 37

Recognize bending in sheet metal parts

Anonymous
Not applicable

Hi,

 

Is it possible with VBA or ilogic that Inventor can recognize if a sheet metal part is just flat or that a bending exist?

I would like an automatic Iproperty of choice to be filled in if there is a bend in the plate part..

This would make sorting much easier for me.

 

I hope someone can help me with this.
Thanks in advance.

 

Regards.
Jeffrey

0 Likes
Accepted solutions (2)
5,443 Views
36 Replies
Replies (36)
Message 21 of 37

bradeneuropeArthur
Mentor
Mentor
Accepted solution

The code works fine..

I have added it to you part.

please check.

 

what version of inventor do you use?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 22 of 37

Anonymous
Not applicable

Hi,

 

The code works now..

Thanks you very much!

 

I have two more questions..

1.       The bending property does not update when I remove the bendings of the part or when I add one (Not even when I run the ilogic rule again). Once the property is filled in, it will no longer be modified. How can I solve this?

 

2.      Is it posible to run this code in a top level assembly and that it completes this property in all sheet metal files?

 

Regards,

Jeffrey

 

0 Likes
Message 23 of 37

bradeneuropeArthur
Mentor
Mentor
could you please mark the first question as solved for administrative reasons!

I will take a look at the further questions.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 24 of 37

bradeneuropeArthur
Mentor
Mentor

Thanks,

What do you mean with:

 

I have two more questions..

The bending property does not update when I remove the bendings of the part or when I add one (Not even when I run the ilogic rule again). Once the property is filled in, it will no longer be modified. How can I solve this?

Should the property to be empty or filled with "Not bended" or what.

 

Is it possible to run this code in a top level assembly and that it completes this property in all sheet metal files?

if the above question is answered than yes...

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 25 of 37

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Please dot the following "on save":

 

Public Sub Main()
Dim a As Inventor.Application
a = ThisApplication

Dim b As PartDocument
 b = a.ActiveDocument
'Dim b As Inventor.Document
'b= thisdoc.document
Dim sm As SheetMetalComponentDefinition
sm = b.ComponentDefinition

MsgBox (sm.Bends.Count)
Dim customProp As Inventor.Property
On Error Resume Next
customProp = b.PropertySets.Item(4).Add("Bend Exist", "Bending")

If Err.Description Then
	Err.Clear
End If
customProp = b.PropertySets.Item(4).Item("Bending")

If sm.Bends.Count > 0 Then

customProp.Value = "Bend Exist"

Else If sm.Bends.Count = 0 Then	

customProp.Value = "No Bend Exist"

End If
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 26 of 37

Anonymous
Not applicable

When i have a part with a bending and I run the code then it works well.

If I remove the bending afterwards and run the code again.. then nothing happens (The field is not emptied).

But I think you added this part now in the new code above this post??

 

The second question was already clear?

I can add tis rule in the sheetmetal template for new parts but for existing parts I need an other solution.

So I would like to run the code for a complete assembly that I'm working on at this moment...

 

Regards,

Jeffrey

0 Likes
Message 27 of 37

Anonymous
Not applicable

Hello,

 

The Ilogic rule works perfect now!

My last question is how can I run this rule in the top level assembly and that it fills in the property to all underlying sheet metal parts.

 

Regards,

Jeffrey

0 Likes
Message 28 of 37

bradeneuropeArthur
Mentor
Mentor

Regards,

could you please mark a " the second question as Solution as solved" for administrative reasons.

I will take a look at the additional question.

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 29 of 37

bradeneuropeArthur
Mentor
Mentor

Normally you would run this module before save.

Do you know to do that?

than the file is always up to date and you don't need a loop.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 30 of 37

Anonymous
Not applicable

Yes, I know how to set this up Smiley Happy

But in this case all the files already exist so that's not a option for now.

 

Regards,

Jeffrey

0 Likes
Message 31 of 37

bradeneuropeArthur
Mentor
Mentor

Then try the following.

Public Sub main()

Dim a As Application
 a = ThisApplication

Dim b As AssemblyDocument
 b = a.ActiveDocument

Dim d As ComponentOccurrence
Dim E As AssemblyComponentDefinition
 E = b.ComponentDefinition

Dim f As PartDocument


For Each d In e.Occurrences.AllLeafOccurrences
If d.DefinitionDocumentType = kPartDocumentObject Then
 f = d.Definition.Document
 sm = f.ComponentDefinition

MsgBox (sm.Bends.Count)


If Err.Description Then
	Err.Clear
End If
customProp = f.PropertySets.Item(4).Item("Bending")

If sm.Bends.Count > 0 Then

customProp.Value = "Bend Exist"

Else If sm.Bends.Count = 0 Then	

customProp.Value = "No Bend Exist"

End If
End If
Next
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 32 of 37

Anonymous
Not applicable

I get the following error:

 

Het openbare lid Bends voor type PartComponentDefinition is niet gevonden.

Englisch translation: The public member Bends for type PartComponentDefinition has not been found.

0 Likes
Message 33 of 37

bradeneuropeArthur
Mentor
Mentor

Then try this.

I haven't tested.

 

Public Sub main()

Dim a As Application
Dim b As AssemblyDocument
Dim d As ComponentOccurrence
Dim E As AssemblyComponentDefinition
Dim sm As SheetMetalComponentDefinition
Dim f As PartDocument

a = ThisApplication
b = a.ActiveDocument
E = b.ComponentDefinition

For Each d In e.Occurrences.AllLeafOccurrences
If d.DefinitionDocumentType = kPartDocumentObject Then
f = d.Definition.Document
 
If f.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
sm = f.ComponentDefinition MsgBox (sm.Bends.Count) If Err.Description Then Err.Clear End If customProp = f.PropertySets.Item(4).Item("Bending") If sm.Bends.Count > 0 Then customProp.Value = "Bend Exist" Else If sm.Bends.Count = 0 Then customProp.Value = "No Bend Exist" End If End If End If Next End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 34 of 37

Anonymous
Not applicable

Hi,

 

Now I get the following error:

De conversie van tekenreeks  naar type Boolean is ongeldig.

Englisch: The conversion of string to Boolean type is invalid.

 

I am very grateful for all the time you put into this!! Smiley Wink

 

Regards,

Jeffrey

0 Likes
Message 35 of 37

bradeneuropeArthur
Mentor
Mentor
Graag gedaan.
Zal er snel weer naar kijken, ok?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 36 of 37

Anonymous
Not applicable

@bradeneuropeArthur

 

Hoi,

 

Het is alweer een tijdje geleden maar ik heb nog een probleem met de code.

Het tellen van de buigingen gaat probleemloos maar wanneer ik bijvoorbeeld een las samenstelling wil saven waarin onderdelen zitten met deze Ilogic code krijg ik onderstaande foutmelding. 

Wanneer ik het onderdeel waarin deze code zit verwerkt zelf op sla krijg je deze melding niet.

 

Error in rule: Bending, in document: 22214.ipt

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: Interface wordt niet ondersteund (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Enig idee hoe ik deze fout er uit kan krijgen?

 

Alvast bedankt.

 

Met vriendelijke groet,

Jeffrey

0 Likes
Message 37 of 37

SometimesInventorMakesMeAngry
Advocate
Advocate

Any luck fixing this? I have the same problem. I can't even do the simplest things like start and end a main subroutine.

 

Edit: nvmd. I had straight vb code checked, so I just wrapped it in a Module End Module block. But now it doesn't recognize Inventor.Application as a valid type even after adding Imports Inventor.

0 Likes