Solved Unable to update Alembic path in xref

I have the following code which was able to get the path but can't update the path

flags = c4d.SCENEFILTER_MERGESCENE | c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS

active_doc = c4d.documents.GetActiveDocument()
merge_status = c4d.documents.MergeDocument(active_doc, target_scene, flags)
assert(merge_status)
# Model[c4d.ID_CA_XREF_FILE]
obj_name_to_search = 'Model'
xref = active_doc.SearchObject(obj_name_to_search)
alembic_path = xref.GetParameter(c4d.ID_CA_XREF_FILE, c4d.DESCFLAGS_GET_NONE)
print(alembic_path)
status = xref.SetParameter(c4d.ID_CA_XREF_FILE, animated_alembic_file, c4d.DESCFLAGS_SET_PARAM_SET)
assert(status)
if True:
    c4d.documents.SaveDocument(active_doc,
                            target_scene,
                            c4d.SAVEDOCUMENTFLAGS_0,
                            c4d.FORMAT_C4DEXPORT)

Hi @nicholas_yue , thanks for reaching out us.

With regard to your question please be aware that C4DAtom::SetParameter() has to be called with DESCFLAGS_SET_USERINTERACTION flag to set ID_CA_XREF_FILE.

Best, Riccardo

@r_gigante said in Unable to update Alembic path in xref:

DESCFLAGS_SET_USERINTERACTION

Using DESCFLAGS_SET_USERINTERACTION there was a prompt in my script.

Update XRef (Yes) or replace (No)?

How do I respond (Yes) in my script ?

Cheers

Unfortunately, there is no built-in way to control MessageBox within Cinema4D.

The only way for you is to install a 3rd party python package, here a possible one https://github.com/asweigart/pyautogui.

Cheers,
Maxime.

@m_adam said in Unable to update Alembic path in xref:

Unfortunately, there is no built-in way to control MessageBox within Cinema4D.

The only way for you is to install a 3rd party python package, here a possible one https://github.com/asweigart/pyautogui.

Cheers,
Maxime.

But I am running the script with c4dpy, there is no UI.

Is there something I can call in c4dpy to tell the current active session to default to "Yes", it seems that c4dpy defaults to "No"

Cheers

I know, it's not what you expected but there is for the moment no way to automate this using Cinema 4D API.

Cheers,
Maxime.