I am attempting to insert markups data into a cloud database by utilizing Autodesk.Viewing.TOOL_CHANGE_EVENT
. However, it appears that this event is triggered before the markups data is extracted via `markupsExtension.generateData()
//Make sure the extentions loaded
viewer?.current?.loadModel(path.urlPath, {}, function onSuccess() {
viewer?.current?.loadExtension("Autodesk.Viewing.MarkupsCore");
viewer?.current?.loadExtension("Autodesk.Viewing.MarkupsGui");
});
React.useEffect(() => {
viewer?.current?.addEventListener(
Autodesk.Viewing.TOOL_CHANGE_EVENT,
(x) => {
if (x.active && x.toolName === "markups.core") {
getAllMarkupsFromDatabase(viewer.current);
} else if (!x.active && x.toolName === "markups.core") {
//here the event close before getting the data
saveMarkupsToDatabase(viewer.current);
}
}
);
}, [isGeometryLoaded]);
//Save the markups data.
async function saveMarkupsToDatabase(viewer: any) {
const markupsExtension = await viewer.loadExtension(
"Autodesk.Viewing.MarkupsCore"
);
const markupsData = await markupsExtension.generateData();
console.log({ markupsData });
//Save to database
localStorage.setItem("markups", markupsStringData);
}
I am uncertain if there is a way to obtain the data prior to closing the markups extension.
2
Answers
Solved,
I think Adam and I solved this with you, during the Copenhagen Accelerator, right ?
Let me know if it’s all solved.