Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
Autodesk Forge: Viewer Extension no puede usar .getExternalIdMapping()
class IBSProgressExtension extends Autodesk.Viewing.Extension{ constructor(viewer, options) { super(viewer, options); } load() { //For proof of concept project, I will simply store the externalIds here in a variable. const allExternalIds = [ '8a00f4c7-0709-4749-88b6-abb0ddccf965-0006879a', '8a00f4c7-0709-4749-88b6-abb0ddccf965-000688ee', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068961', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068963', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a78', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a0d', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a0f', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a11', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a13', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068c2f', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068c31', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068c33', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b2e', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b30', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b32', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b34', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b3e', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b36', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b38', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b3a', '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b3c' ]; this.viewer.model.getExternalIdMapping(data => onSuccessMapping(data)); function onSuccessMapping(data) { const resArray = []; allExternalIds.forEach(externalId => { if (data[externalId]) resArray.push(data[externalId], externalId); }); console.log(resArray); }; console.log('IBSProgressExtension is loaded.'); return true; } }; Autodesk.Viewing.theExtensionManager.registerExtension("IBSProgressExtension", IBSProgressExtension);

Eche un vistazo a mi extensión y ayúdeme a descubrir por qué sucede esto. Cada vez que lo ejecuto, los registros de devtools: ViewerExtension.js:31 Uncaught TypeError: No se pueden leer las propiedades de undefined (leyendo 'getExternalIdMapping').

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Las extensiones se cargan antes que el modelo, por lo que el método getExternalIdMapping() aún no tiene las propiedades del modelo. Para manejar este escenario, generalmente recomendamos usar los eventos del visor como Autodesk.Viewing.GEOMETRY_LOADED_EVENT para "atrapar" el momento en que el modelo está disponible. Es mejor esperar al evento. Esto se activará cuando el modelo/dibujo termine de cargarse.

En vez de:

 this.viewer.model.getExternalIdMapping(data => onSuccessMapping(data));

Prueba esto:

 this.viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, (x) => { this.viewer.model.getExternalIdMapping(data => onSuccessMapping(data)); });

about 4 years ago · Juan Pablo Isaza Report

0

Por favor, pruebe esto y vea si es útil. Traté de incorporar elementos de sus comentarios para ayudarlo a estructurarlo.

 class IBSProgressExtension extends Autodesk.Viewing.Extension { constructor(viewer, options) { super(viewer, options); this._externalIds = null; //Eventually will want to pass in your external IDs to this function, I assume: //this._externalIds = options.externalIds this._doStuff = () => { this.startDoingStuff(); }; } load() { console.log("loading extension"); //For now, hard coded like your example. this._externalIds = [ "8a00f4c7-0709-4749-88b6-abb0ddccf965-0006879a", "8a00f4c7-0709-4749-88b6-abb0ddccf965-000688ee", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068961", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068963", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a78", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a0d", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a0f", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a11", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a13", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068c2f", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068c31", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068c33", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b2e", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b30", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b32", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b34", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b3e", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b36", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b38", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b3a", "8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b3c", ]; //Not sure if this is truly the right event, but it worked when I tested on mine. this.viewer.addEventListener(Autodesk.Viewing.MODEL_LAYERS_LOADED_EVENT, this._doStuff); } startDoingStuff() { console.log("startDoingStuff executing"); this.getDbIds(this._externalIds).then((CombinedArray) => { this.setCustomColors(CombinedArray); }); } setCustomColors(arrayOfIDs) { console.log("setCustomColors executing"); var somecolor = "#7D5B51"; var threecolor = new THREE.Color(somecolor); var vectcolor = new THREE.Vector4(threecolor.r, threecolor.g, threecolor.b, 1); arrayOfIDs.forEach((e) => { this.viewer.setThemingColor(e[0], vectcolor, this.viewer.getVisibleModels()[0]); }); } getDbIds(externalIds) { console.log("getDbIds executing"); return new Promise((resolve) => { this.viewer.model.getExternalIdMapping((d) => { //console.log("getDbIdFromExternalId Executed"); let responseArr = []; externalIds.forEach((externalId) => { if (d[externalId]) responseArr.push([d[externalId], externalId]); }); console.log("resolving", responseArr); resolve(responseArr); }); }); } } Autodesk.Viewing.theExtensionManager.registerExtension("IBSProgressExtension", IBSProgressExtension);
about 4 years ago · Juan Pablo Isaza Report

0

Con respecto a esto, estaba tratando de lograr 3 cosas en esta etapa.

  1. Obtenga los externalIds de Mongodb .
  2. Compare los externalIds con los obtenidos de getExternalIdMapping() .
  3. Obtenga DbIds de aquellos que coincidieron.

Los resolvió al darse cuenta de que 2 y 3 se pueden colocar dentro a.then() después de .loadDocumentNode() .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!