Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

read iproperty values using VB.net

18 REPLIES 18
Reply
Message 1 of 19
andrew_canfield
2287 Views, 18 Replies

read iproperty values using VB.net

Hello 

 

The link below shows how to read iproperties using iLogic  - what's the equivalent in VB.net?

 

https://adndevblog.typepad.com/manufacturing/2018/04/accessing-iproperties-through-ilogic-code.html

 

Tried a few things without success...

iproperty read.JPG

 

Regards

 

Andrew

18 REPLIES 18
Message 2 of 19

Hi, here is an example. First I think you should specify the inventor application. As I cannot prove it at this time I have created an ilogic rule, which is based on the language of vb.net
Under the simple rule I have left you a thread where you can consult the information.
I hope it is useful for you. regards

 

Dim invapp = ThisApplication


Dim doc As Document = invapp.ActiveDocument
Dim oProp As String
oProp = doc.PropertySets.Item("Inventor Summary Information").Item("title").Value
MsgBox(oProp)

 

https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html


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

Message 3 of 19

Hello & thanks

 

I'm trying to access iproperty information from idw's using Apprentice - thinking this will be faster than waiting for the drawing to open in Inventor. It's only to see which iproperties are present within the file.

The code used was copied from mod the machine & edited after to a different iproperty but the error message relates to a 3d driver?

 

Regards

 

Andrew

 

 

Message 4 of 19

there's more info :

https://forums.autodesk.com/t5/inventor-customization/extract-iproperties-without-opening-the-file/m...

 

the MA24-4 zip file has a list of iproperties..

Message 5 of 19
jjstr8
in reply to: andrew_canfield

If you're intending to get the "Title" property, you have it backwards.  You're setting it.  It may be throwing an exception if Title doesn't already have a value.

 

...
Title = oProperty.Value
MessageBox.Show(Title)
Message 6 of 19
andrew_canfield
in reply to: jjstr8

Some bit are working! 🙂

 

Design Tracking Properties will edit.

 

Next is finding the path to custom iproperties - there's a reference but it'e VBA...

 

propertyset1.JPGpropertyset2.JPG

 

Message 7 of 19
jjstr8
in reply to: andrew_canfield

In your latest post, you're referencing the PropertySet class as if it's a static class, not your PropertySet object

customProp = customPropSet.Item("TITLE_LINE_1).Value

If you're meaning to set the property to TextBox3.Text then keep the second equals.  I didn't follow what you were doing.

 

Just a couple of suggestions.  It would be good practice to check PropertySetExists on the collection before getting a property set so you don't throw an exception.  Since an exception is thrown if you try to access a property that doesn't exist and there's no "PropertyExists" method, I also find it helpful to "for each" the properties collection and add them to a custom collection (I've used List<T> when T is a custom class with the name and value as the only properties).  Once you have your list, you can work off of that instead of having exception handling for every property you're dealing with.

Message 8 of 19
andrew_canfield
in reply to: jjstr8

Hello

I have some success 🙂 - thanks.

But i was testing using a 2016 idw & the code fails on a 2018 idw.

Not sure how to change the .net version (or if this is even the right action) of the solution?

NetVersion.JPG

 

Regards

 

Andrew

Message 9 of 19
jjstr8
in reply to: andrew_canfield

I'm not sure what the error would be.  It shouldn't be due to your .NET target framework version.  I'm assuming you're using Inventor 2018 and the IDW opens in Inventor without issues.  

Message 10 of 19
andrew_canfield
in reply to: jjstr8

Hello

Just about to restart the m/c 

Will make sure 2018 is loaded first.

Think it might be using apprentice 2016 & not 2018.

Not too sure how to tell the difference. The test file is the same - just a save copy as in 2018 for the second version.

 

Regards

 

Andrew

 

Message 11 of 19

Restarting, using 2018 make no difference - swap the code in 2 places to see the 2016 file & not the 2018 file works for 2016 but not 2018...

2016 working:

2016-1.JPG

2018 - unspecified error

2018-1.JPG

 

Regards

 

Andrew

 

Message 12 of 19
jjstr8
in reply to: andrew_canfield

The only thing I can think of is to check your reference to Apprentice under Reference Manager is VS.  I'm using Inventor 2017, so when I hover over Autodesk Inventor's Apprentice Object Library in the COM section, I see it points to C:\Program Files\Autodesk\Inventor 2017\Bin\bin32\RxApprentice.tlb

Message 13 of 19
andrew_canfield
in reply to: jjstr8

Thanks - it's working.

I think installing Inventor view has helped but not sure if it's required - thought 'Apprentice' was installed with Inventor?

Uninstalling the Anti Virus helped too - why it effect 2018 & not 2016, mystery.

Running ccleaner - possibly helped

Running the profile reset tool helped too.

 

Regards

 

Andrew

Message 14 of 19

Hi Andrew,

You don't really need Apprentice to read and write iProperties from Inventor-files. iProps is all MS-Technology, so Windows brings everything you need. (The Macro in the attached Excel-File is made for a 32-Bit-VBA-client - which afaik is still standard even in newer, 64-Bit editions of Excel). To get it to run in a 64-Bit Excel-VBA-client there need to be made some changes in the code. (Save everything in Excel before trying: If it's the wrong version, it wil crash!)

Greetings, Bert

 

Message 15 of 19

Thanks

I'll need to figure out how to run the macro for 64 bit excel - it really custom iproperties which will need editing - can these still be seen without Apprentice?

 

Regards

 

Andrew

Message 16 of 19

Short answer: Yes it can, but i need to put some effort in it to adapt it. But before i need to update to a current version of excelMyself 😕 . So long i can only offer you the .ivb file underneath wich contains the 64-Bit versions of the Windows system-function calls used in the excelfile i posted before. Maybe you can put the puzzle together yourself 😉

 

FYI: the macro inside runs in Inventor's (64-Bit) - VBA-Client, but bypasses Inventor to perform some cheats! 🙂

 

Message 17 of 19

I think I've a choice between wrestling with VBA or vb.net (visual studio) &  guess investment in vb.net is the way forward, but:

https://adndevblog.typepad.com/manufacturing/2014/07/using-apprentice-from-a-windows-service.html

 

the above is the error appearing & I need to look up what a Windows service is - i didn't think this project would be such a challenge!

 

Regards

 

Andrew

Message 18 of 19

Hi Andrew,
the link you posted shows some Apprentice-related issues. My point was to ignore Apprentice and use the Windows API instead: Take a look at
https://docs.microsoft.com/en-us/windows/win32/api/coml2api/nf-coml2api-stgopenstorageex ,
https://docs.microsoft.com/en-us/windows/win32/api/propidl/nn-propidl-ipropertysetstorage ,
https://docs.microsoft.com/en-us/windows/win32/api/propidl/nn-propidl-ipropertystorage , and so on.
There, you should find every information you need.

Greetings,

Christian


Message 19 of 19

Many Thanks for sharing this - there's been a lot of work done.

excel-iprop.jpg

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report