Hello,
I have create some custom object for ACad. It is work fine, I can manipulate it's data via ARX module.
Now I want to adding ability of manipupate object data via ACAD object property inspector. I have create a COM wrapper object, it is working, I can access the object data via VBA. I have try a lot but can not expose it's property via ACAD's Object Property Inspector.
I here by include these header of the COM Wrapper object, please help me to solve that.
Thank a lot.
#pragma once
#include "resource.h"
#include "dynprops.h"
#include "axtempl.h"
#include "tchar.h"
#include "iSSWrapper.h"
#define DISPID_TEXTSTRING 0x00000001
//----- CKMTRBMarkWP
class ATL_NO_VTABLE CKMTRBMarkWP :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CKMTRBMarkWP, &CLSID_KMTRBMarkWP>,
public ISupportErrorInfo,
public IOPMPropertyExtensionImpl<CKMTRBMarkWP>,
public IOPMPropertyExpander,
public IAcadEntityDispatchImpl<CKMTRBMarkWP, &CLSID_KMTRBMarkWP, IKMTRBMarkWP, &IID_IKMTRBMarkWP, &LIBID_KMTiSSWrapperLib>
//- Please do not remove the following line. It is here to make the Visual Studio ATL Wizards
//- running properly. The class will not compile but is required by Visual Studio to recognize
//- this class as being an ATL class
//- Uncomment the following line when you want to use the ATL Wizards to add a member or method
//- to its interface.
//,public IDispatchImpl<Ighfghgfh, &IID_IIghfghgfh, &LIBID_adskArxProject1Lib>
{
public:
CKMTRBMarkWP () {
}
DECLARE_REGISTRY_RESOURCEID(IDR_KMTRBMARKWP)
DECLARE_NOT_AGGREGATABLE(CKMTRBMarkWP)
BEGIN_COM_MAP(CKMTRBMarkWP)
COM_INTERFACE_ENTRY(IKMTRBMarkWP)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IOPMPropertyExtension)
COM_INTERFACE_ENTRY(ICategorizeProperties)
COM_INTERFACE_ENTRY(IPerPropertyBrowsing)
COM_INTERFACE_ENTRY(IOPMPropertyExpander)
COM_INTERFACE_ENTRY(IAcadBaseObject)
COM_INTERFACE_ENTRY(IAcadBaseObject2)
COM_INTERFACE_ENTRY(IAcadObject)
COM_INTERFACE_ENTRY(IAcadEntity)
COM_INTERFACE_ENTRY(IRetrieveApplication)
END_COM_MAP()
//----- ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct () {
return (S_OK) ;
}
void FinalRelease () {
}
//IAcadBaseObjectImpl
virtual HRESULT CreateNewObject (AcDbObjectId &objId, AcDbObjectId &ownerId, TCHAR *keyName);
//IAcadBaseObject2Impl
STDMETHOD(ForceDbResident)(VARIANT_BOOL *forceDbResident) ;
STDMETHOD(CreateObject)(AcDbObjectId ownerId =AcDbObjectId::kNull, TCHAR *keyName =NULL);
STDMETHOD(AddToDb)(AcDbObjectId &objId, AcDbObjectId ownerId =AcDbObjectId::kNull, TCHAR *keyName =NULL);
//IOPMPropertyExtension
BEGIN_OPMPROP_MAP()
//----- Use the OPMPROP_ENTRY/OPMPROP_CAT_ENTRY macros for each of your properties
OPMPROP_ENTRY(0, 0x00000001, PROPCAT_Text, 0, 0, 0, _T(""), 0, 1, IID_NULL, IID_NULL, "")
END_OPMPROP_MAP()
//IOPMPropertyExtensionImpl
virtual HINSTANCE GetResourceInstance () {
HINSTANCE hi = _AtlBaseModule.GetResourceInstance();
HINSTANCE dllHi = _hdllInstance;
return hi;
}
//IOPMPropertyExpander
STDMETHOD(GetElementValue)(/*[in]*/DISPID dispID, /*[in]*/DWORD dwCookie, /*[out]*/VARIANT *pVarOut);
STDMETHOD(SetElementValue)(/*[in]*/DISPID dispID, /*[in]*/DWORD dwCookie, /*[in]*/VARIANT VarIn);
STDMETHOD(GetElementStrings)(/*[in]*/DISPID dispID, /*[out]*/OPMLPOLESTR __RPC_FAR *pCaStringsOut, /*[out]*/OPMDWORD __RPC_FAR *pCaCookiesOut);
STDMETHOD(GetElementGrouping)(/*[in]*/DISPID dispID, /*[out]*/short *groupingNumber);
STDMETHOD(GetGroupCount)(/*[in]*/DISPID dispID, /*[out]*/long *nGroupCnt);
public:
//IKMTRBMarkWP
STDMETHOD(get_BarNumber)(/*[out, retval]*/ BSTR* pVal);
STDMETHOD(put_BarNumber)(/*[in]*/ BSTR newVal);
} ;
OBJECT_ENTRY_AUTO(__uuidof(KMTRBMarkWP), CKMTRBMarkWP)
Solved! Go to Solution.
Solved by tuankm01. Go to Solution.
What do you do to test your code, what do you expect to happen, and what actually happens?
You're more likely to get help if you provide detailed answers to the three questions I asked.
Dear Owen,
Thank you very much for your concerning.
1. I have load the files into Autocad (dbx and arx), I have create the custom object by my command.
2. I wish that the custom object property is show in Autocad property inspector, in this case is bar number property.
3. Currently the property only modify by arx code or via COM in VBA IDE.
Please refer to my attcahed image for more information
Thank you very much,
From your screen shot, it looks like you clicked the cursor on the entity. That step is important for someone to understand the problem. One possible reason for your issue is that your COM class is not properly registered. Have you performed that step?
Dear Owen,
Thanks for your keen to help. I think the COM module is already self register. I can reference the COM object in the VBA IDE and change the BarNumber property (which I want to show in the Autocad Property Inspector but it not) from this.
Please refer to the attached.
Regards,
It sounds like you are not sure whether your module is registered. Try registering your COM module manually (use regsvr32) to see if that resolves your problem.
Dear Owen,
After checking my code again, I found that I have not point the object classid in the subGetClassID function to the COM object class id. After correct it work perfectly.
Thank for your help.
Regards,