Load and run extensions on forge viewer - autodesk-forge

I need to go back to home default view on Forge Viewer, after a few times go for searching and follow some tutorials to load extension i have something like this
let res =  _viewer.loadExtension('Autodesk.GoHome')
        if(res){
           _viewer.getExtension('Autodesk.GoHome', (gohome)=>{
               gohome.active()
           })
It not work for me and have an error like "gohome is not a function" ?. Did i do something wrong ?

You have a race condition problem in your code.
I will not get into details here, but briefly speaking, things like "gohome is not a function" usually means that you use an object before it was fully created/initialized.
Try changing your code into:
_viewer.loadExtension('Autodesk.GoHome').then(
(gohome) => {
gohome.active();
})
This should solve the problem.

Related

Problems with forceDoubleSided setting

I need to activate the profile setting forceDoubleSided in order to display properly a model derivated from a Revit project that has mirrored external references.
Using the latest version of the Forge Viewer, I set the profile settings in the config parameter when I call new GuiViewer3D(container, config) and, while the model is loading, the materials property "side" = 2 (THREE.DoubleSide) and it looks good.
The problem is when the model has loaded, or after have used the cutting plane extension, because the materials "side" is then reset to 0 (THREE.FrontSide) so the model stops looking correctly.
As a workaround, in the GEOMETRY_LOADED_EVENT and CUTPLANES_CHANGE_EVENT events I am executing _viewer.impl.setDoubleSided(true, _viewer.model) every time.
It seems like a bug in the viewer... is there a better approach to handle this problem?
That does sound like a bug. Let me notify the engineering team, and thanks for reporting it! For now, please continue manually overriding the "sidedness" as needed.

viewer.impl.disableRollover(true); not working

Seems like something changed in Forge's library as suddenly viewer.impl.disableRollover(true); has stopped working.
Would anyone kindly confirm or deny this?
Try that:
viewer.disableHighlight(true)
Keep in mind that every method under viewer.impl. is NOT part of the public API and is subject to change from one version to another.

why does console.log not output in chrome?

Recently I read a query about "What does console.log do" and I read an answer, tried using it and found that despite the answer stating that it outputs to the console in googles browser, I just tried it and I get no output.
I did try this code:
function put(p){
if ( window.console && window.console.log ) {
console.log(p); // console is available
}else{
alert(p);
}
}
BUT... I get neither console output or alert and furthermore .log is a Math property, what gives with that?
Make sure that in the Developer Tools the Filter in the console section is set to All or Logs...
I had a similar experience where I couldn't see any of my console.log output and it was because the console was set to filter on Errors only... All the log entries were there - they just weren't visible.
Bonus marks: you can also Ctrl + Click to select multiple filters (Errors + Logs for example).
Press F12 and look at in Developer Tools: Console. I tried your code just now, works fine for me -- Chrome version 30.0.
Since you're after console logging, not mathematical logarithms, perhaps you could stop going on about there being similarly-named function in the Math object. It's not relevant here whatsoever.
You're also coming across just a little shouty. console.log() works fine, and your question didn't indicate that you knew where to look. This is totally your problem, but I'm trying to help you. I can obviously only go on the information you provide, and I can't say your initial question was written very clearly.
It appears, since the snippet of code you posted works here absolutely fine, that your calling code & containing (which you haven't posted) would be the cause of the problem. You should debug these, to find out what's going wrong.
Do you know how to use the Chrome debugger? Are there any error messages showing in Chrome or on the console?
Test it on a simple page if necessary, to rule out other errors in the page/ or surrounding context breaking it. One common mistakes is declare functions in a jQuery ready handler or similar, and then try & access them globally. Make sure your logging function is actually global (outside any other function(){} or object {} blocks).
Lastly, it's good to have a logging function for portability (I have one myself) but put() is not a good name for it. Naming it consoleLog() or log() would be better.
Had the same issue .
Make sure your using de right path when you try import thing's .
Example whit my issue :
Wrong path ----> ** import normalizedData from 'normalizr'; **
Right path ---> ** import normalizedData from '../schemas/index.js'; **
I had also faced the same problem. Make sure you apply no filter in the console. It worked for me.

Scriptella: get error codes and messages within onerror tag

Using Scriptella ETL, i recently came to know about the onerror tag. It is working fine,but I want to make a generic code which inserts the code and the message into the database whenever any error occurs.
I am using it like this:
<onerror codes="42604,42617,42000,1366" >
INSERT INTO demo_travel.test_log(Time_Now, ErrorName) values ( sysdate(),'eeuhue');
</onerror>
Which is working, but I want something like this:
<onerror >
INSERT INTO demo_travel.test_log(Time_Now, ErrorName,ErrorMSG) values ( sysdate(),Error.code, error.msg);
</onerror>
Unfortunately there is no easy way to achieve that. onerror was based on the assumption that a developer knows an error he is dealing with. But I do agree this has to be improved. The problem was partially addressed in a Feature request: Allow different connection-id in onerror element.
So for 1.1 or earlier versions, this is not possible. For a current development snapshot of 1.2, this information can be inferred from the "error" variable as explained in the ticket. I've also created a subticket to expose additional properties of the error.

$m->comp is returning infinite recursive call error

I am having trouble using HTML::Mason's $m->comp to redirect from one view to another.
There is a file say file1.mi which has embedded HTML code in this file1.mi I am using $m->comp to redirect to file2.mi.
But in the webpage whenever file1.mi is loaded it prints the footer multiple times and in the logs i am getting the errors
Nested page framework application dispatch detected, this usage is not
fully supported and may result in unexpected behavior
and
Error: APPLICATION CONTEXT ERROR (RENDER): 32 levels deep in component
stack (infinite recursive call?)
. Here is the script which i am using for redirecting from file1.mi
return $m->comp('/page-framework/dispatch.mi', applicationPath =>'/gp/tradein/omc', viewID => 'file2.mi', %ARGS);
I am using this script in file1.mi before it renders the webpage -- i.e. before any HTML scripts are executed.
I am kinda new to Mason, if you have queries regarding this please go ahead.
It looks like that your file1.mi gets loaded and rendered, then file2.mi gets executed and it in infinite loop.
Please, show us more code, it is not possible to debug with that small details.
What do you in the web server logs? Please, paste some example from loglines too.
Regards,
It should be your dispatcher dispatch.mi that is calling file1 or file2. Deciding that you want to go elsewhere after the request has already been dispatched seems like the logic is in the wrong place.