Object Properties Manager

OPM

Object Properties Manager is a COM-based feature that examines properties of objects and provides an interface for editing and adding properties to the object(s). The properties palette uses COM to communicate with the object(s) in question, and requires the use of C++ to expose particular interfaces that control the display of the properties in the palette.

By implementing Object Properties Manager, you can display custom properties for both native and custom objects and enhance their appearance in the Properties palette.

The OPM example has a props file. It should be enough if you update it with the location of FxARX SDK. Then, you should not have problems to build the projects 

 

The solution contains 3 projects:

  • OPMCustomEntity : contains the custom entity and the command that will create the custom entity. First, we have to create a custom entity.

  • OPMComEntity : contains the COM interfaces that are used to wrap the object properties fields on the Properties palette. To support properties the OPMComEntity project is a must.

  • OPMDynamicProperties : contains the implementation of the dynamic properties. OPMDynamicProperties  is optional if anybody wants to associate dynamic properties then this project is required else we can work with above 2 projects only.

 

Run the example:

  1.  Please, build the projects and make sure the COM wrapper (OPMComEntity) is registered. Just a reminder, the module can be registered automatically when you load the app if ARES Commander is running with admin rights.

  2. Load the modules in this order: OPMCustomEntity, OPMComEntity, OPMDynamicProperties.

  3. Execute command WHEEL, and open the properties palette:

(in green the areas that are shown by the OPM) if you play with the geometry fields you will see how the wheel is updated.

 

Some information about the projects :

OPMCustomEntity is probably very similar to your custom entity projects. One thing that you have to take in account is that you need to override custom entity method subGetClassID( CLSID* pClsid ) to point to the GUID of the COM interface:

 

Acad::ErrorStatus CWheel::subGetClassID( CLSID* pClsid ) const {     assertReadEnabled();     *pClsid = CLSID_COMWheel;     return Acad::eOk; }

 

OPMComEntity project is an ATL project. So, probably it is better if you have some experience in ATL. Actually that project was generated using the VS Wizard for ATL. Then classes were extended with OPM functionality and the project adapted to include FRX acrxEntryPoint and acrxGetApiVersion. Please take a look at COMWheel/cpp files, they were generated with the ATL wizard. We added some static properties using the wizard like radius, location, NumberOfSpokes. Which we implemented in the cpp file:

 

STDMETHODIMP CCOMWheel::put_NumberOfSpokes( SHORT newVal ) {     try     {         Acad::ErrorStatus es;         AcAxObjectRefPtr<CWheel> pWheel( &m_objRef, AcDb::kForWrite, Adesk::kTrue );         if ( (es = pWheel.openStatus()) != Acad::eOk )             throw es;         USES_CONVERSION;         pWheel->setNumSpokes( newVal );     }     catch ( const Acad::ErrorStatus )     {         return E_FAIL;     }     return S_OK; }

 

Please, follow next AutoCAD documentation to have extended information about how to add static properties: https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-2DF3B939-E79E-46F6-9055-ED153E36E68C

 

OPMDynamicProperties contains the dynamic properties of the wheel: Brand and Warranty. Please take a look at the file WheelDynamicProperties.cpp. In this case, we get/store the data from the XDATA. The following lines shows how the dynamic properties are mapped to the custom entity

OPM_DYNPROP_OBJECT_ENTRY_AUTO( CWheelBrand, CWheel ); OPM_DYNPROP_OBJECT_ENTRY_AUTO( CWheelWarranty, CWheel );

Please, follow the next Autocad documentation to have extended information about how to add dynamic properties: https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-7F2A8AF5-6929-4673-A1D6-156BAF2CD3A1 and   https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-033F137D-49E4-416D-B59A-F1712295EBA8

 

Tools palette

Please read the following documentation: Custom Tool Palettes