Modifying custom Iproperties in C#

Modifying custom Iproperties in C#

navbor
Enthusiast Enthusiast
510 Views
1 Reply
Message 1 of 2

Modifying custom Iproperties in 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"]; 

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

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

 

Thanks Rob

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
511 Views
1 Reply
Reply (1)
Message 2 of 2

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

Sorry, I was a little rash replying just now. Actually the string of the property set name is correct. You are using its Display Name.

 

After checking the snapshot, I think the problem is no any document is opened. So ActiveDocument is null. Could you give a check?

 

Again, I suggest looking for propertyset by its internal name which is not localized. 

0 Likes