我尝试使用Autodesk.Viewing.TOOL_CHANGE_EVENT
将标记数据插入到云数据库中。但是,似乎在通过`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);
}
我不确定是否有一种方法可以在关闭标记扩展之前获得数据。
1条答案
按热度按时间hc8w905p1#
我想亚当和我在哥本哈根加速器期间和你一起解决了这个问题,对吗? 如果都解决了告诉我。