Assembly instance property API reference Inventor 2022

Assembly instance property API reference Inventor 2022

bradeneuropeArthur
Mentor Mentor
1,860 Views
5 Replies
Message 1 of 6

Assembly instance property API reference Inventor 2022

bradeneuropeArthur
Mentor
Mentor

Hi,

 

How to change edit the "Assembly Instance Properties" of child files via the API?

 

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
Accepted solutions (1)
1,861 Views
5 Replies
Replies (5)
Message 2 of 6

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Found:

Public Sub main()

Dim a As Inventor.Application
Set a = ThisApplication

Dim b As AssemblyDocument
Set b = a.ActiveDocument

Dim c As AssemblyComponentDefinition
Set c = b.ComponentDefinition

Dim occ As ComponentOccurrence
Set occ = c.Occurrences.Item(1)

MsgBox occ.OccurrencePropertySets.Item(1).Item(1).Name

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

Message 3 of 6

nmunro
Collaborator
Collaborator

Your code will work if the user has already added an Instance property to the first occurrence in the assembly. In a more general application, you should add another step to ensure the occurrence has a valid Instance property set to work with. The following code works on a newly created assembly where no occurrences have had Instance Properties added via the Inventor UI.

 

Public Sub main()

Dim a As Inventor.Application
Set a = ThisApplication

Dim b As AssemblyDocument
Set b = a.ActiveDocument

Dim c As AssemblyComponentDefinition
Set c = b.ComponentDefinition

Dim occ As ComponentOccurrence
Set occ = c.Occurrences.Item(1)

' ensure the default occurrence property set is enabled
' this property set has the same internal name (GUID)
'   as the custom property set for a document
occ.OccurrencePropertySetsEnabled = True

' get the property set and add a property
Dim instancePropSet As PropertySet
Set instancePropSet = occ.OccurrencePropertySets(1)
Dim instanceProp As Property
Set instanceProp = instancePropSet.Add("World", "HelloProperty")

'show instance prop data
MsgBox instanceProp.Name & ": " & instanceProp.Value

End Sub

 

        


https://c3mcad.com

Message 4 of 6

CattabianiI
Collaborator
Collaborator

Just to avoid headaches if you get your hands dirty on the subject, at the moment there is this known bug that should be fixed in the next release:
INVGEN-50622: OccurrencePropertySetsEnabled = True throws an exception if the assembly file is readonly.
beta program link

 

Message 5 of 6

bradeneuropeArthur
Mentor
Mentor

Have you already reported it to the development team?

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 6 of 6

CattabianiI
Collaborator
Collaborator

I reported it in the beta program forum (that's the small link above) and they gave me that issue ID.