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

Problem with dynamic properties and custom entities

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
674 Views, 5 Replies

Problem with dynamic properties and custom entities

Here I come again. I have a problem in implementing dynamic properties. I added several dynamic properties to the AcDbSpline entity, and it worked well. The following code is used to map dynamic properties.

OPM_DYNPROP_OBJECT_ENTRY_AUTO(MyDyProps, AcDbSpline)

When I select splines, the properties showed up, and I can check and modify them. Then I derived a custom entity from AcDbSpline (let's name it MyCustEnt), and several static properties were added to the  MyCustEnt, and the problem arised. When I select the AcDbSpline, everything is fine, which means the static properties were added correctly. When I select the MyCustEnt, both dynamic properties (mapped to AcDbSpline) and static properties (mapped to MyCustEnt) showed up in the Property Inspector. But I never mapped the dynamic properties to MyCusEnt. Is it because that MyCusEnt is derived from AcDbSpline?

So, the question is, how can I disable the dynamic properties in the Property Inspector of MyCusEnt.

sc1.png

sc2.png

  

Labels (1)
5 REPLIES 5
Message 2 of 6
Alexander.Rivilis
in reply to: Anonymous


@Anonymous wrote:

 

So, the question is, how can I disable the dynamic properties in the Property Inspector of MyCusEnt.

 

 

  


As far as remember you have to return E_POINTER in method Connect of dynamic property class if selected MyCusEnt.

For example:

STDMETHODIMP CMyDynProps::Connect (IDynamicPropertyNotify2 *pSink) {
// isDisableProp - toggle for disable/enable dynamic property
	if ( pSink == NULL   || isDisableProp)
		return (E_POINTER) ;
	m_pNotify =pSink ;
	m_pNotify->AddRef () ;
	return (S_OK) ;
}

 

And what do you do if selected some AcDbSpline and some MyCusEnt?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 6
Anonymous
in reply to: Alexander.Rivilis

Oh, I missed that part. I think I know how to do it now. One more thing,  how can I get objects from IDynamicPropertyNotify2::GetCurrentSelectionSet mehtod?  I'm new to ATL and COM, "SAFEARRAY" is a little strange to me. Thank you.

Message 4 of 6
Alexander.Rivilis
in reply to: Anonymous

int SelectionSet_To_ObjectIdArray(VARIANT *l_selection, AcDbObjectIdArray &ids)
{
  HRESULT l_hr;
  ids.removeAll();
  try {
    UINT l_dim = ::SafeArrayGetDim(V_ARRAY(l_selection));
    if (l_dim == 1)
    {
      LONG l_lbound = 0, l_ubound = 0;
      ::SafeArrayGetLBound(V_ARRAY(l_selection), 1, &l_lbound);  
      ::SafeArrayGetUBound(V_ARRAY(l_selection), 1, &l_ubound);
      ids.setPhysicalLength(l_ubound-l_lbound+1);
      IUnknown *l_unkn = 0;
      for (LONG l_idx = l_lbound; l_idx <= l_ubound; l_idx++)
      {
        l_hr = ::SafeArrayGetElement(V_ARRAY(l_selection), &l_idx, &l_unkn);

        if (SUCCEEDED(l_hr))
        {
          if (l_unkn != NULL) {
            IAcadObject *l_base = 0;
            if (!SUCCEEDED (l_unkn->QueryInterface(IID_IAcadObject,(void **)&l_base))) {
              continue;
            }
            AcDbObjectId  l_oid;
            LONG_PTR l_long = 0;
            if (SUCCEEDED(l_base->get_ObjectID(&l_long))) {
              l_oid.setFromOldId(l_long);
              ids.append(l_oid);
            }
            l_base->Release();
          }
        }
      }
    }
  } catch(...) {  }
  ::VariantClear(l_selection);
  return ids.length();
}

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 6
lena.talkhina
in reply to: Anonymous

Hello  @Anonymous 

Welcome to Autodesk Community!

If you find some posts are useful, don't forget to accept it as a solution.

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.



Лена Талхина/Lena Talkhina
Менеджер Сообщества - Русский/Community Manager - Russian

Message 6 of 6
Anonymous
in reply to: Alexander.Rivilis

It perfectly works. Thank you.

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

Post to forums  

Technology Administrators