Access iProperties of ActiveDocument

Access iProperties of ActiveDocument

Anonymous
Not applicable
1,833 Views
11 Replies
Message 1 of 12

Access iProperties of ActiveDocument

Anonymous
Not applicable

I am trying to write an iLogic rule that when I have one file open it will open a second file I specify and grab some of its iProperties.  I can find and open the file just fine, but I am having trouble finding a way to access its iProperties.  I have been researching and I saw this article:

 

http://help.autodesk.com/view/INVNTOR/2014/ENU/?guid=GUID-8CAEA21E-A604-4D0A-8F06-3FA5B693CE6B

 

Which looked to me like I could specify the second file's fileName and get its iProperties, but that doesn't seem to work.  I keep getting a null / blank value.  I then thought I could specify the active document and do something like:

 

SyntaxEditor Code Snippet

doc.PropertySets.Item("Project").Item("Description").Value

 

But that didn't work either.  Does anyone know how to access the iProperties of one document from another?

 

I'm stumped.

0 Likes
Accepted solutions (1)
1,834 Views
11 Replies
Replies (11)
Message 2 of 12

MechMachineMan
Advisor
Advisor
http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html

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

MechMachineMan
Advisor
Advisor
In the call that you use to open the 2nd document, make it something like

oDoc2 = ThisApplication.Documents.Open(...)

Then you can use oDoc2 to access that document you opened.

--------------------------------------
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
0 Likes
Message 4 of 12

Owner2229
Advisor
Advisor

Hi,

I'm using this one, as you can get the iProperties without opening the file:

Dim sTS As String = oDoc.FullFileName 'or just "C:/File.ipt"
Dim FNamePos As Long = InStrRev(sTS, "\", - 1)
Dim docFName As String = Mid(sTS, FNamePos + 1, Len(sTS) - FNamePos)
Dim Val1 As String = iProperties.Value(docFName, "Project", "Part Number")

 

On the other side, if I try to use this one, I'm getting blank parametes:

 

Dim Val1 As String = iProperties.Value(oDoc, "Project", "Part Number")
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 5 of 12

MechMachineMan
Advisor
Advisor
Umm. You can't fetch iProperties unless the document is open (albeit it may
be invisibly) or you are using AppreticeServer to access them.

--------------------------------------
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
0 Likes
Message 6 of 12

Owner2229
Advisor
Advisor

Yay, my fault, I'm running it from assembly, so in my case the document truly is open.

Sorry for disinformation.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 7 of 12

Anonymous
Not applicable

So I've tried both of those, but everything is returning a null.

 

To test it out my code opens the file, then I attempt the two methods by trying to pull the revision number and diplaying it in a messagebox:

 

'...open dialog box, user selects a file "strFile" 

Dim assemDoc As DrawingDocument
assemDoc = ThisApplication.Documents.Open(strFile)

Dim myProp As String

myProp = iProperties.Value(IO.Path.GetFileName(strFile),"Project", "Revision Number")
'Below MsgBox results in  "Method 1: '' "
MessageBox.Show("Method 1: "+ myProp , "Testing")

'Then I try specifying the filename explicitly just to be sure there isn't something dumb with using the GetFileName function above, but same results
myProp = iProperties.Value("X8053D27.idw","Project", "Revision Number")
MessageBox.Show("Method 2: "+ myProp, "Testing")

'Here is method 2 being tried, same result as before.
myProp = oIPT.PropertySets.Item("Project").Item("Revision Number").Value

MessageBox.Show("Method 3: "+ myProp , "Testing")

All of these methods end up resulting in an empty string being returned when I know that the revision on that file is Rev "A"

 

 

0 Likes
Message 8 of 12

MechMachineMan
Advisor
Advisor

You mean to say that your IDW's Sheet Revision Number is not being pulled in by the call to the iProperties?

 

There is a difference in the 2 fields. The revision that shows up in this window (and in revision tables; "Sheet Revision Number", and not an iProperty) vs the iProperty "Revision Number".

 

TEMP1.PNG

 


--------------------------------------
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
0 Likes
Message 9 of 12

Anonymous
Not applicable

I'm trying to get the iProperty:

 

Capture.PNG

0 Likes
Message 10 of 12

MechMachineMan
Advisor
Advisor
Did you leave out lines of code, or is that your whole rule?

--------------------------------------
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
0 Likes
Message 11 of 12

MechMachineMan
Advisor
Advisor
Accepted solution
You have the wrong PropertySet being accessed;

MsgBox(ThisApplication.ActiveDocument.PropertySets.Item("Inventor Summary Information").Item("Revision Number").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 12 of 12

Anonymous
Not applicable

That was it exactly!  Thank you so much!  

 

0 Likes