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

SubEntity in SDK sample can't work.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
masterhe3000
753 Views, 2 Replies

SubEntity in SDK sample can't work.

I try to run SubEntity sample in autocad2007/8/9,but Property Palette can't display the properties of the sub-entity selected.Can somebody help me? Thanks!

2 REPLIES 2
Message 2 of 3
Balaji_Ram
in reply to: masterhe3000

Sorry, This is a known issue.

To my understanding, the sample was not fixed.



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
Balaji_Ram
in reply to: masterhe3000

Hi,

 

I have replied to your other thread.

Posting the same here for completeness and it might help others in future.

 

<<<<

Thanks to my colleague Gopinath Taget who got this sample working with help from the engineering team.

 

Here are the changes and the sample project :

 

 

The key is to inherit from IAcadSubEntity in the IDL file for your interface:

 

interface ICrank : IAcadSubEntity

 

And in the implementation header, Inherit from the IAcadBaseSubEntityImpl and IOPMPropertyExtensionImpl templates like this:

 

//----- CCrank

class ATL_NO_VTABLE CCrank :

public CComObjectRootEx<CComSingleThreadModel>,

public CComCoClass<CCrank, &CLSID_Crank>,

public ISupportErrorInfo,

public IAcadBaseSubEntityImpl<CCrank, &CLSID_Crank, ICrank, &IID_ICrank, &LIBID_AsdkSliderCrankDbLib>,

public IOPMPropertyExtensionImpl<CCrank>

 

Also make sure that the inherted templates are properly mapped like this:

 

BEGIN_COM_MAP(CCrank)

COM_INTERFACE_ENTRY(ICrank)

COM_INTERFACE_ENTRY(IDispatch)

COM_INTERFACE_ENTRY(ISupportErrorInfo)

COM_INTERFACE_ENTRY(IConnectionPointContainer)

COM_INTERFACE_ENTRY(IRetrieveApplication)

COM_INTERFACE_ENTRY(IAcadSubEntity)

COM_INTERFACE_ENTRY(IAcadBaseSubEntity)

COM_INTERFACE_ENTRY(IOPMPropertyExtension)

END_COM_MAP()

 

Finally, implement the GetResourceInstance and GetDisplayName methods of the IOpmPropertyExtension/IOpmPropertyExtensionImpl interfaces like this:

 

virtual HINSTANCE GetResourceInstance()

{

HINSTANCE hi = _AtlBaseModule.GetResourceInstance();

HINSTANCE dllHi = _hdllInstance;

return hi;

}

 

STDMETHODIMP GetDisplayName(

DISPID dispID,

BSTR *pBstr)

{

if (dispID == 0x401) { // magic dispID meaning object itself

if (pBstr==NULL)

return E_POINTER;

*pBstr = ::smileyfrustrated:ysAllocString(L"TheCrank");

return S_OK;

}

return IOPMPropertyExtensionImpl<CCrank>::GetDisplayName(

dispID, pBstr);

}

 

The proper implementation of GetDisplayName method is vital for the subentity OPM to work.

 

I am attaching the sample with these modifications to the Crank subentity. Similar modifications need to be made to the other sub entities as well.

>>>>



Balaji
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report

”Boost