Hi,
I have a user scenario where they want to modify PMI information. Specifically, after loading a SCS file in webview, they want to modify a certain PMI text content in the file and save it in the SCS file. Can this be achieved?
Hi,
I have a user scenario where they want to modify PMI information. Specifically, after loading a SCS file in webview, they want to modify a certain PMI text content in the file and save it in the SCS file. Can this be achieved?
Hello,
The short answer is no, this cannot be done. PMI is not treated as a text object, per se, in the Web Viewer. It is actually rendered as a 3D mesh. Further, changes made in the Web Viewer cannot be saved directly in the Stream Cache file itself.
Thanks,
Tino
OK, I understand, thanks.
I have a plan now. Could you please help me check if it is feasible
1: Obtain current PMI data
2: Prepare the modified mesh data
3: Delete the old PMI and create a new one
async function getMeshInstanceDataFromNode(nodeId) {
// 1. 获取节点的MeshData副本
const meshDataCopy = await viewer.model.getNodeMeshData(nodeId);
// 2. 将 MeshDataCopy 转换为 MeshData
const meshData = new Communicator.MeshData();
// 这里需要将 meshDataCopy 的顶点、法线、面等数据复制到 meshData
// 伪代码示例(具体API可能需要根据实际数据结构调整)
meshDataCopy.faces.forEach(face => {
meshData.addFaces(face.vertices, face.normals);
});
// 3. 创建Mesh,得到MeshId
const meshId = await viewer.model.createMesh(meshData);
// 4. 创建MeshInstanceData
const meshInstanceData = new Communicator.MeshInstanceData(meshId);
// 5. 设置变换矩阵(可选)
const matrix = viewer.model.getNodeMatrix(nodeId);
meshInstanceData.setMatrix(matrix);
return meshInstanceData;
}
const refOnTopoItems = await viewer.model.getPmiTopologyReferences(nodeId)
async function replacePmi(oldPmiId, newMeshInstanceData, pmiType, pmiSubType, refOnTopoItems, parentNodeId) {
// 删除旧PMI节点
await viewer.model.deleteNode(oldPmiId);
// 创建新的PMI实例
const newPmiId = await viewer.model.createPmiInstance(
newMeshInstanceData,
pmiType,
pmiSubType,
refOnTopoItems,
parentNodeId
);
return newPmiId;
}
The main difficulty I’m thinking of now is how to obtain the modified mesh data. For example, how to change the PMI data that was previously obtained with a value of 6 to 7, and so on
Thanks
Not really sure what you mean in the quote referenced above. If you’ve created a new PMI mesh, wouldn’t you have a reference to the mesh data?
Sorry, my previous description wasn’t very clear. The mesh data reference does exist. The main issue now is how to create a new PMI mesh, since I haven’t found a way to modify the mesh data of an existing PMI. For example, when a user wants to update the PMI’s value or text content, I’m not sure how to handle that.
Indeed, this is the limitation with editing text in the Web Viewer. As mentioned in one of my previous post on this thread, text is a geometrical mesh and not a text object. The mesh is composted of a points/face array and individual texts/glyphs cannot be easily identified in the array.
Thank you for your explanation. From what I understand, the mesh data of the PMI cannot be modified.