Error ilogic - Recognize bendings

Error ilogic - Recognize bendings

Anonymous
Not applicable
1,348 Views
22 Replies
Message 1 of 23

Error ilogic - Recognize bendings

Anonymous
Not applicable

Hi,

 

I use the ilogic code below to recognize if there are bendings in a sheet metal file.

The result is put in a costum iproperty (Bend exist /  No bend exist.

The code does what it has to do..

 

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

But I get the following error message while saving a assembly with a sheet metal file.

Is there anyone who can help me to solve this?

Error in rule: Bending, in document: 24783.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)).

Thank you in advance!

 

Regards,

Jeffrey

 

0 Likes
Accepted solutions (1)
1,349 Views
22 Replies
Replies (22)
Message 2 of 23

Sergio.D.Suárez
Mentor
Mentor

Hi, if you apply this rule in a sheet file and it works, check the line that says
  "b = a.ActiveDocument"
If you came to place events before saving the part, and you have opened an assembly and you save everything, the active document in this case is the assembly and you may get the error for that reason. Try changing by this other line
"b = ThisDoc.Document"


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 23

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous ,

 

Please provide sample assembly file with sheet metal parts (make sure that files are non confidential) and steps to reproduce issue.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 4 of 23

Anonymous
Not applicable

Hi,

 

@chandra.shekar.g 

 

Please find attach an sample file (pack en go).

The problem arises only once!

 

To simulate the problem you must make a change in the sheet metal file and then save the assembly again.

When the assembly is saved it will not happen again until a change is made in the sheet metal file.

 

@Sergio.D.Suárez Unfortunately this does not help.

 

Thanks for the help 😉

 

Regards,

 

Jeffrey

0 Likes
Message 5 of 23

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous ,

 

Change iLogic code like below. It make sure that document is sheet metal document.

 

Public Sub Main()
	Dim a As Inventor.Application
	a = ThisApplication
	
	Dim doc = ThisDoc.Document
	If doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then 
		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
	Else
		Exit Sub 
	End If 
	
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 6 of 23

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Make these changes and I find Inv 2018, please watch the video

 

 

what inventor's version do you have?

 

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

Dim b As PartDocument
 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 

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 7 of 23

bradeneuropeArthur
Mentor
Mentor

I know that piece of code, ha ha....

Smiley Happy

 

Is it working now or shall I send you an update!

 

Regards,

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 8 of 23

Anonymous
Not applicable

@chandra.shekar.g 

I receive new errors whit this code. But thanks your help!

 

@Sergio.D.Suárez  

@bradeneuropeArthur 

If I use you code everything works perfectly except for one thing.

When saving the template file I get an error.. (see pictures below).

 

But if I just save the template and use it then it works well.

Should this still be resolved or is this error innocent?

 

Error Ilogic 1.pngError Ilogic 2.png

I truly appreciate your time and effort

 

Regards,

Jeffrey

 

0 Likes
Message 9 of 23

bradeneuropeArthur
Mentor
Mentor

Hi,

 

You talk about the code above here ONLY?

Or is there more code in your file?

 

Regards,

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 10 of 23

Anonymous
Not applicable

@bradeneuropeArthur 

 

The ilogic code from @Sergio.D.Suárez is the only code in the template.

 

Regards,
Jeffrey

0 Likes
Message 11 of 23

bradeneuropeArthur
Mentor
Mentor

I will give it a short test/look.

 

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 12 of 23

bradeneuropeArthur
Mentor
Mentor

is the template a "sheet metal part" or a "normal part"?

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 13 of 23

Anonymous
Not applicable

@bradeneuropeArthur 

 

It's a sheet metal template..

 

Regards,

Jeffrey

0 Likes
Message 14 of 23

bradeneuropeArthur
Mentor
Mentor

Are you running the code above "on save"?

 

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 15 of 23

Anonymous
Not applicable

Hi,

 

Before save document (please see picture below.)

 

Ilogic trigger.png

 

Regards,

Jeffrey

0 Likes
Message 16 of 23

Sergio.D.Suárez
Mentor
Mentor

hi how are you, a small detail, have you noticed that the initial files that you have shared are read only? in the video modify this because otherwise it does not allow me to save the files, maybe it can give you problems if one is reading and the other is not.


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 17 of 23

Anonymous
Not applicable

@Sergio.D.Suárez 

 

Very good and how are you?

I think this is because I use vault professional..

 

Regards,

Jeffrey

0 Likes
Message 18 of 23

bradeneuropeArthur
Mentor
Mentor

Do you have permission to write and edit the template file in the specific directory (Template Directory)?

Because the file wants to write on save.

better is to trigger if the file requires a update and not to run it always on save if not necessary!!

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

Message 19 of 23

Anonymous
Not applicable

Ì have permission two write the file in the template direction.

I check the file out and then I have write permission.

 

Okay, but that wil not solve the error which I get while saving the template?

perhaps I can change the event trigger to: Part geometry change?

 

Regards,

Jeffrey

0 Likes
Message 20 of 23

bradeneuropeArthur
Mentor
Mentor

Hi,

 

I am investigating the issue.

For me the code runs fine!

For my understanding:

The template file location is a vault workspace location, right?

Is the location in the workspace directory or outside the workspace directory?

Seems to have to do with the permissions of vault security or directory security.

 

Could you make a screenshot of your vault browser with the Project directory and the template directory/

Are you able to save the file anywhere else with succes or not?

Regards,

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