VBA - iProperty value

VBA - iProperty value

Jef_E
Collaborator Collaborator
3,604 Views
3 Replies
Message 1 of 4

VBA - iProperty value

Jef_E
Collaborator
Collaborator

Hi there,

 

I'm trying to read a certain iProperty, so I can check if my part/assembly is a valid file to edit via code.

This is what i get, but when i'm debugging it kills me at:

 

oPropSet = oDoc.Item("Inventor Document Summary Information")

 

What do i need to change?

I also tried inserting this code instead of the text, same result.

 

{D5CDD502-2E9C-101B-9397-08002B2CF9AE}

My code:

 

 ' Get the active document.
Dim oDoc As Document
oDoc = _invApp.ActiveDocument

' Get a reference to the "Inventor Document Summary Information" PropertySet
Dim oPropSet As PropertySet
oPropSet = oDoc.Item("Inventor Document Summary Information")

' Get the Category property.
Dim oCat As [Property]
oCat = oPropSet.Item("Category")

MsgBox(oCat.Value())

Thanks for the help!

Inventor 2013

Visual Studio 2010



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Accepted solutions (1)
3,605 Views
3 Replies
Replies (3)
Message 2 of 4

Jef_E
Collaborator
Collaborator
Accepted solution

I found the error.

 

This:

oPropSet = oDoc.Item("Inventor Document Summary Information")

Should be this:

oPropSet = oDoc.PropertySets.Item("Inventor Document Summary Information")

Code:

' Get the active document.
Dim oDoc As Document
oDoc = _invApp.ActiveDocument

' Get a reference to the "Inventor Document Summary Information" PropertySet
Dim oPropSet As PropertySet
oPropSet = oDoc.PropertySets.Item("Inventor Document Summary Information")

' Get the Category property.
Dim oCat As [Property]
oCat = oPropSet.Item("Category")

MsgBox(oCat.Value)


Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
Message 3 of 4

MechMachineMan
Advisor
Advisor
You are forgetting to call the collection in which the property set belongs to; a specific property set is not found directly on the document class, but instead within a PropertySets collection which belongs to the document;

ie;

ThisApplication.ActiveDocument.PropertySets.Item("Inventor Document Summary Information").Item("Category").Value

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 4 of 4

Jef_E
Collaborator
Collaborator

Hi,

 

Thanks for the reply, I had just found what was wrong 🙂 thanks anyway!



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes