0

I am trying to update my Revit model using APIs. for which I have already had APIs where they accept the 3D vector position where I want my asset or object to be added. The problem here is when I am doing a hittest

this.viewer.clientToWorld(evt.clientX, evt.clientY, true);

the position which I get here seems working on well to place the object on the viewer but when I send the same position to my Revit API the object appears to add away from my actual click

so the thing which I want to understand here is what I am doing wrong is Revit software has some other coordinate system that I need to convert from my position vector?

I have tried to calculate global offset too but even that didn't work well

var offset = viewer.model.getData().globalOffset

the value for offset which I get is

 {x: -36.83258967447005, y: 3.198711699197691, z: 45.28371391552952}

so the position/intersection point which I get from the hit test I did

const worldCoords = hittest.point.clone().sub(offset);
Ronak Shetiya
  • 960
  • 6
  • 27
  • Please provide more details around what you tried with `globalOffset` that didn't work. Was there a `globalOffset` at all or was it `(0, 0, 0)`? – Rahul Bhobe Apr 14 '21 at 12:28
  • @RahulBhobe I updated my question – Ronak Shetiya Apr 14 '21 at 13:53
  • Check out this answer which again refers two other answers. You will have to account for both translation (offset) and scale (units) and generate appropriate transformation from viewer to model. https://stackoverflow.com/a/51877789/11057988 – Rahul Bhobe Apr 14 '21 at 14:38
  • @RahulBhobe thank you for referring this, I went through this before posting the question here so could u please tell me how do I use the scale thing can u provide any reference for that too ?> – Ronak Shetiya Apr 14 '21 at 15:19
  • Unfortunately I do not have sample code for this. I have asked internally if someone has. Independently, you might find help sooner on stack overflow if you post the value of `getUnitScale()`. And the minimal code showing how you generated and applied the transformation in Revit API. And your expected vs actual results. – Rahul Bhobe Apr 15 '21 at 05:12

0 Answers0