0

I am dynamically aggregating models in the Viewer (coming from multiple BIM files). Basically, I initialize the viewer, and then LoadDocument and LoadModel for each model that user chooses to view, dynamically.

These are mostly NVC files (what I used for testing), which are sharing the coordinate system. Models getting dynamically loaded and getting 'stitched' correctly.

However, coordinate system is getting screwed up when the second model gets loaded - not always but in some cases (in v6.3 - haven't checked previous versions). When this happens, I can notice the followings:

  1. When I click 'home' icon in the viewer, it doesn't show the full aggregated model but only shows the first loaded model in the center and rest go outside screen.
  2. When I click an element to select, it selects something else (with an offset), and some cases selects nothing (meaning, clicked coordinates has been interpreted incorrectly).

I have tried multiple combinations and this problem seems to happen when first loaded model is not occupying full size of the aggregated model (say, one floor of the building).

I figured out a solution though. After loading the models (every time when user choose some), if I 'hide' all models and 'show' them again, it fixes the problems with click and AGGREGATED_SELECTION event.

This is not a nice user experience because I want to be able to load the models in the background while user is moving around the previously aggregated model-set. If I hide/show after loading the new one, it will be annoying to user.

Is there a way to 'reset' the coordinate system of the viewer (to the same effect what happens when hide/show the models)?

I would appreciate some help to get around this issue.

Thanks Bandu

8
  • Try disable the offsets like this: var loadOptions = { globalOffset: { x: 0, y: 0, z: 0 } // to align the models }; and let us know how you go Dec 14, 2018 at 3:01
  • Hi Bryan, it is not an alignment issue. They are perfectly aligned. Yes. I am setting the globalOffset. Thanks
    – Bandu W
    Dec 14, 2018 at 3:16
  • Further tests reveled that my previous workaround is not reliable either (hiding/showing). It only works sometimes.
    – Bandu W
    Dec 14, 2018 at 3:18
  • take a look at these hidden APIs for multi-model, that might give you a clue. forge.autodesk.com/blog/highlighting-clashes-multi-model Dec 14, 2018 at 5:36
  • Hi Michael, Thanks. I tried your 'reset view' code but it doesn't solve the issue. When I hide all models except one, selection works (it selects what I click). But when there are more than one model, it selects something different from the element I clicked. I tried with both 'sharedPropertyDb' and without - I don't think it makes a difference here.
    – Bandu W
    Dec 14, 2018 at 14:08

1 Answer 1

2

ok, so there is a massive offset, causing a precision issue. Which is why you are seeing lots of 'jittering' of the camera.

To fix this... we need to correct the massive offset, by returning all the geometry closer to origin manually. (or fixing the original navisworks file).

First, let's roughly figure out the offset value...

Hold down ALT-key and click anywhere on an object. This sets a green dot, the pivot point. Then use viewer.navigation.getPivotPoint() to get the x,y,z value. (details: https://github.com/wallabyway/markupExt/issues/2).

You should see an xyz value like this... Z.Vector3 {x: 1296285.515098644, y: 14995636.431742325, z: 364.26238179027337}

Now, adjust set the global offset using this value, to correctly move all the models closer to 0,0,0. like this...

line 70:

var modelOptions = {
    sharedPropertyDbPath: doc.getPropertyDbPath(),
    globalOffset: {x:1296285.515098644, y: 14995636.431742325, z:0}
};
viewer.loadModel(svfUrl, modelOptions, onLoadModelSuccess);

`

This reverses the effect of this big offset. The result is the geometry stops flickering and the camera movement stops 'jittering' due to precision issues.

Let me know if that works for you. Michael

ps. you can pull the 'exact' global-offset out of the small side-file AECModelData.json, see blog: forge.autodesk.com/blog/add-revit-levels-and-2d-minimap-your-3d

2
  • Thanks Michael. That solved the problem. So, if I grab the offset from the first model and use it for other models (instead of using 0,0,0), this won't happen. I will restructure my code accordingly.
    – Bandu W
    Dec 20, 2018 at 2:56
  • Incidentally, you can retrieve the globalOffset value before loading the viewer, using a neat trick... Download the small AECModelData.json file, and pull the globalOffset out of there. It works for Navis and IFC files. See here for details: forge.autodesk.com/blog/… Mar 26, 2020 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.