Accessing Iproperties using c#

Accessing Iproperties using c#

navbor
Enthusiast Enthusiast
1,593 Views
1 Reply
Message 1 of 2

Accessing Iproperties using c#

navbor
Enthusiast
Enthusiast

Hello All,

 

I am using some code from the June 2010 "Mod the machine" posted by Brian Erkins.

 

I keep getting an error in C# (express 2010), Please see attached screen dump.

 

I don't see any obvious difference in my code when compared to Brian's (in fact at one point I copied and pasted his code and still had the same error). Has something changed in the object model, or am i simply doing something stupid?

 

Please could someone give me some pointers. I am a newbie, trying to learn and am a little stumped with this so any assistance would be much appreciated.

 

Here is the code:

 

private void button1_Click(object sender, EventArgs e)       

{           

Inventor.Application invApp = null;           

invApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");

Inventor.Document doc = invApp.ActiveDocument;           

Inventor.PropertySet customPropSet;           

customPropSet = doc.PropertySets["Inventor User Defined Properties"];

.............

.............

Regards
Rob
-------------------------------------------
Windows 7 Pro (X64)
Intel(R) core (TM) i5-4690 CPU @ 3.50GHz
32.0 GB RAM
Nvidia Quadro K2000
Autodesk Inventor 2015 Professional Ultimate Design Suite
0 Likes
1,594 Views
1 Reply
Reply (1)
Message 2 of 2

YuhanZhang
Autodesk
Autodesk

The code is assuming that you have a document opened in Inventor, if you don't this would raise the exception. You can either open a document in Inventor manually or open a document in the C# code before acccessing its property sets.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes