.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to implement IPropertySource to add per-instance property?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
905 Views, 2 Replies

how to implement IPropertySource to add per-instance property?

My code is based on Kean's article "Exposing AutoCAD's Properties Palette functionality to .NET".I expand it,wrapped IPropertySource,OPMPerInstancePropertyExtension,OPMPerInstancePropertyExtensionFactory,OPMPerInstancePropertySources in C#.All thing is right except IPropertySource.
Here is the IPropertySource interface source code:
{code}
interface DECLSPEC_UUID("61D0A8E3-C792-4956-8E96-594315B95902")
IPropertySource : public IUnknown
{
BEGIN_INTERFACE
// *** IUnknown methods ****

STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;

// *** IPropertySource methods ***

// Call this when your property changes
STDMETHOD(get_Name)(THIS_ /*[out, retval]*/BSTR* pName) PURE;
// Call to get the current selection set OPM is working with, returns a SAFEARRAY
// of LONGs representing the objectIDs of the set, be sure to call VariantClear to cleanup
STDMETHOD(GetProperties)(THIS_ /*[in]*/IUnknown* pObject, /*[out, retval]*/VARIANT *pPropertyArray) PURE;
};
{code}
Here is the document of GetProperties
The pProperties array contains pointers to IDynamicProperty instances that describe additional properties of the object. If the property source object does not generate any dynamic properties, pProperties can be VT_EMPTY or an empty array.

I declared like this
{code}
[InteropServices::Guid("61D0A8E3-C792-4956-8E96-594315B95902")]
[InteropServices::InterfaceTypeAttribute(InteropServices::ComInterfaceType::InterfaceIsIUnknown)]
[InteropServices::ComVisible(true)]
public interface class IPropertySource
{
//[return: MarshalAs(UnmanagedType::BStr)]
String^ get_Name();
//[return: MarshalAs(UnmanagedType::SafeArray, SafeArraySubType=VarEnum::VT_UNKNOWN)]
array^ GetProperties([In,MarshalAs(UnmanagedType::IUnknown)]Object^ pObject);
};
{code}

Here is my implemnt of it:

{code}
public class CustomSource2 : IPropertySource
{
public string get_Name()
{
return("some name");
}
public object[] GetProperties(object pObject)
{
IAcadObject dbobj = pObject as IAcadObject;
//throw new System.Exception("The method or operation is not implemented.");
IDynamicProperty2[] ay = new IDynamicProperty2[3];
ay[0]= new CustomProp("param1", "group1");
ay[1]= new CustomProp("param2", "group1");
ay[2]= new CustomProp("param3", "group2");
return ay;
}
}
{code}
However when acad called GetProperties function,I return array of IDynamicProperty2,it does'nt work.
I think most likely error is the marshal from Object[] to VARIANT *pPropertyArray.But what is the correct marshal code?
who can help me?
Thanks! Edited by: fivegg on Nov 22, 2009 9:46 PM
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Try reposting in the ObjectARX newsgroup.

I don't have time to pick this apart, but someone there might be able to
stop something.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6293566@discussion.autodesk.com...
My code is based on Kean's article "Exposing AutoCAD's Properties Palette
functionality to .NET".I expand it,wrapped
IPropertySource,OPMPerInstancePropertyExtension,OPMPerInstancePropertyExtensionFactory,OPMPerInstancePropertySources
in C#.All thing is right except IPropertySource.
Here is the IPropertySource interface source code:
{code}
interface DECLSPEC_UUID("61D0A8E3-C792-4956-8E96-594315B95902")
IPropertySource : public IUnknown
{
BEGIN_INTERFACE
// *** IUnknown methods ****

STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;

// *** IPropertySource methods ***

// Call this when your property changes
STDMETHOD(get_Name)(THIS_ /*[out, retval]*/BSTR* pName) PURE;
// Call to get the current selection set OPM is working with, returns a
SAFEARRAY
// of LONGs representing the objectIDs of the set, be sure to call
VariantClear to cleanup
STDMETHOD(GetProperties)(THIS_ /*[in]*/IUnknown* pObject, /*[out,
retval]*/VARIANT *pPropertyArray) PURE;
};
{code}
Here is the document of GetProperties
The pProperties array contains pointers to IDynamicProperty instances that
describe additional properties of the object. If the property source object
does not generate any dynamic properties, pProperties can be VT_EMPTY or an
empty array.

I declared like this
{code}
[InteropServices::Guid("61D0A8E3-C792-4956-8E96-594315B95902")]
[InteropServices::InterfaceTypeAttribute(InteropServices::ComInterfaceType::InterfaceIsIUnknown)]
[InteropServices::ComVisible(true)]
public interface class IPropertySource
{
//[return: MarshalAs(UnmanagedType::BStr)]
String^ get_Name();
//[return: MarshalAs(UnmanagedType::SafeArray,
SafeArraySubType=VarEnum::VT_UNKNOWN)]
array^ GetProperties([In,MarshalAs(UnmanagedType::IUnknown)]Object^
pObject);
};
{code}

Here is my implemnt of it:

{code}
public class CustomSource2 : IPropertySource
{
public string get_Name()
{
return("some name");
}
public object[] GetProperties(object pObject)
{
IAcadObject dbobj = pObject as IAcadObject;
//throw new System.Exception("The method or operation is not
implemented.");
IDynamicProperty2[] ay = new IDynamicProperty2[3];
ay[0]= new CustomProp("param1", "group1");
ay[1]= new CustomProp("param2", "group1");
ay[2]= new CustomProp("param3", "group2");
return ay;
}
}
{code}
However when acad called GetProperties function,I return array of
IDynamicProperty2,it does'nt work.
I think most likely error is the marshal from Object[] to VARIANT
*pPropertyArray.But what is the correct marshal code?
who can help me?
Thanks!

Edited by: fivegg on Nov 22, 2009 9:46 PM
Message 3 of 3
Anonymous
in reply to: Anonymous

Ok,Thanks

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost