How to implement IOPMPropertyExpander2 in .NET

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to implement a dynamic property for an entitytype in my .NET ExtensionApplication.
So far using several online examples I've managed to implement a 'default' dynamic property with a string, double or integer value using the IDynamicProperty2 interface.
Then I got a step further using the IDynamicEnumProperty for a dropdownlist.
I got these interfaces working implementing them in a C# interface refering to the COM imports with the specific GUID's
Also a specific group for the properties in the OPM was possible implementing the IAcPiCategorizeProperties interface which removed some difficulty specifying the interface myself in my C# interfaces.
Now the last hurdle is using the IOPMPropertyExpander2 so that the in OPM a specific dynamic property (Point3d) can be expanded into the X,Y and Z values like the Start X, Start Y and Start Z of a line and the button to pick a point becomes available.
At least, that's what I understand from the documentation.
Problem is that I can't find any examples or help for the implementation of the IOPMPropertyExpander2 in C#.
From some experimenting I've come to this interface definition:
[ComImport(), Guid("d0f45feb-71d5-44ea-B1A0-6E2F27B2085D"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] public unsafe interface IOPMPropertyExpander2 { void GetElementValue( [In]int dispID, [In, MarshalAs(UnmanagedType.IUnknown)]object pUnknown, [In] uint dwCookie, [In, Out, MarshalAs(UnmanagedType.Struct)]ref object varData); void SetElementValue( [In]int dispID, [In, MarshalAs(UnmanagedType.IUnknown)]object pUnknown, [In] uint dwCookie, [In, Out, MarshalAs(UnmanagedType.Struct)]ref object varData); void GetElementStrings([In]int dispID, [In, MarshalAs(UnmanagedType.IUnknown)]object pUnknown, [In] uint dwCookie, [Out]out IntPtr pCaStringsOut, [In, Out]ref IntPtr pCaCookiesOut); void GetElementGrouping([In]int dispID, [In, MarshalAs(UnmanagedType.IUnknown)]object pUnknown, [In, Out, MarshalAs(UnmanagedType.I2)]ref short groupingNumber); void GetGroupCount([In]int dispID, [In, MarshalAs(UnmanagedType.IUnknown)]object pUnknown, [In, Out, MarshalAs(UnmanagedType.I4)]ref long nGroupCnt); }
(The full contents of the interface definitions are included)
This seems to work, because when I implement it on my CustomPointPropertyClass at least the GetElementStrings method is triggered, but I've got no C++ knowledge, so I can't figure out what to return here to make the OPM expand the property in multiple values.
My interpretation of the help files is that this method specifies the different sub-elements.
I've been struggling with it for a while now but have come to the conclusion that I need some help.
Now for the questions:
- Is my definition of the GetElementStrings in my C# interface correct?
- How do i implement it so that i can specify a X, Y and Z coordinate?
- Will AutoCAD automagically show the point-picker and if not, how can I accomplish that?.
A couple of assumptions for the next steps:
1. when the different elements are defined the GetElementValue is called for each of the defined elements giving me the chance to specify the values. 2. when the value of an element is changed the SetElementValue is called
Kind regards & thanks in advance,
Sietse Wijnker
Oh in addition, the dynamic properties are based on the example from Kean Walmsley. A big thanks to Kean for all the examples and information on how to extend AutoCAD with .NET!