We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Can't get material change

WalterWhite
Contributor

Hi there,

I use "ACAPI_Notify_CatchNewElement" to catch the modify of the element.

 

 

ACAPI_Notify_CatchNewElement(nullptr, ElementEventHandlerProc);
ACAPI_Notify_InstallElementObserver(ElementEventHandlerProc);

 

 

When I change the material attribute which has already been used at current surface,the observer can't get change.

figure1 shows the material current use.

figure2 shows change material.

However, When I change the material's texture, I can't get the change in "ElementEventHandlerProc".

So how should I do can get the change?

f1.png

f2.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Hi!

There are two different cases I can make out from your question:
1. Detect if some material changed. (Not possible with ElementObservers)

2. Detect if the material assignment of some element is changed. (You get a APINotifyElement_Change notification for this with ElementObservers)

I think you want case 1 correct?
I came up with a technique on how this might be possible. I use it for something else so I'm not 100% sure it works for this case as well. So try with care.
Here's a rough sketch:
- Make sure "Save each step" is enabled in the Data Safety settings of the AC Work Environment

- Use the Project Notification "APINotify_TempSave"

- Now you can check on every action whether your material changed (API_Attribute stuff)
  - this now is triggered on almost any action in AC so be careful to not use to much time to decide whether to act on it!

Let me know if it works for you as well 🙂

View solution in original post

2 REPLIES 2
Solution

Hi!

There are two different cases I can make out from your question:
1. Detect if some material changed. (Not possible with ElementObservers)

2. Detect if the material assignment of some element is changed. (You get a APINotifyElement_Change notification for this with ElementObservers)

I think you want case 1 correct?
I came up with a technique on how this might be possible. I use it for something else so I'm not 100% sure it works for this case as well. So try with care.
Here's a rough sketch:
- Make sure "Save each step" is enabled in the Data Safety settings of the AC Work Environment

- Use the Project Notification "APINotify_TempSave"

- Now you can check on every action whether your material changed (API_Attribute stuff)
  - this now is triggered on almost any action in AC so be careful to not use to much time to decide whether to act on it!

Let me know if it works for you as well 🙂

Hi bschwb,

Thanks a lot!

Forgive me leaving a long time to reply you.I try the method you post and it really works.