I have a wall from which I put the coordinates into "Edge" classes. Edge has the properties start and end which represent start and end point of one edge of the wall. Due to this being in forge coordinates, I do not know how long my wall really is. There is a measurement tool which can do this but how do I use it programatically to determine the length of my edges.
Actual Result: Edges in Forge coordinates
Expected Result: Edges in m
const vertexbuffer = new Autodesk.Viewing.Private.VertexBufferReader(geometry);
let event = new VertexBufferEvent();
vertexbuffer.enumGeomsForObject(dbid, event);
parts.push(new Part(event.getCollection(), dbid));
/**
* This event is called when Autodesk.VertexBufferReader finds a line.
* Line coordinates are saved as an Edge
* @param x0
* @param y0
* @param x1
* @param y1
* @param viewport_id
*/
handle(x0, y0, x1, y1) {
let start = new Point(x0, y0, 0);
let end = new Point(x1, y1, 0)
let edge = new Edge(start, end)
this.edgeCollection.push(edge);
}
onLineSegment(x0, y0, x1, y1, viewport_id) {
this.handle(x0, y0, x1, y1)
}
getCollection() {
return this.edgeCollection
}
Note: I am not looking to acquire the length property in the propertydb
You probably need to apply the
viewer.model.getUnitScale()
to the length information on the model.EDIT
getUnitScale
returns the scale factor of model's distance unit to meters.And you should be using
model.getInstanceTree().getNodeBox()
for the bounding box, in your case, if you pass dbId1
should return the bounding box of the entire model. As you model is inmm
, then you multiply bu.getUnitScale
to convert tom
.EDIT 2
For 2D sheets you need an extra transformation. For the
onLineSegment
you can use something like: