File tree Expand file tree Collapse file tree
fragments/FragmentsManager Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -232,20 +232,10 @@ export class Viewpoint implements BCFViewpoint {
232232 *
233233 * @returns A Promise that resolves when the components have been added to the viewpoint.
234234 */
235- async addComponentsFromMap ( fragmentIdMap : FRAGS . FragmentIdMap ) {
235+ addComponentsFromMap ( fragmentIdMap : FRAGS . FragmentIdMap ) {
236236 const fragments = this . _components . get ( FragmentsManager ) ;
237- for ( const fragmentID in fragmentIdMap ) {
238- const fragment = fragments . list . get ( fragmentID ) ;
239- if ( ! ( fragment && fragment . group ) ) continue ;
240- const model = fragment . group ;
241- const expressIDs = fragmentIdMap [ fragmentID ] ;
242- for ( const expressID of expressIDs ) {
243- const attrs = await model . getProperties ( expressID ) ;
244- if ( ! attrs ) continue ;
245- const globalId = attrs . GlobalId ?. value ;
246- if ( globalId ) this . selectionComponents . add ( globalId ) ;
247- }
248- }
237+ const guids = fragments . fragmentIdMapToGuids ( fragmentIdMap ) ;
238+ this . selectionComponents . add ( ...guids ) ;
249239 const manager = this . _components . get ( Viewpoints ) ;
250240 manager . list . set ( this . guid , this ) ;
251241 }
Original file line number Diff line number Diff line change @@ -232,6 +232,32 @@ export class FragmentsManager extends Component implements Disposable {
232232 return fragmentIdMap ;
233233 }
234234
235+ /**
236+ * Converts a fragment ID map to a collection of IFC GUIDs.
237+ *
238+ * @param fragmentIdMap - A fragment ID map to be converted to a collection of IFC GUIDs.
239+ *
240+ * @returns An array of IFC GUIDs.
241+ */
242+ fragmentIdMapToGuids ( fragmentIdMap : FRAGS . FragmentIdMap ) {
243+ const guids : string [ ] = [ ] ;
244+ const modelIdMap = this . getModelIdMap ( fragmentIdMap ) ;
245+ for ( const modelID in modelIdMap ) {
246+ const model = this . groups . get ( modelID ) ;
247+ if ( ! model ) continue ;
248+ const expressIDs = modelIdMap [ modelID ] ;
249+ for ( const expressID of expressIDs ) {
250+ for ( const [ guid , id ] of model . globalToExpressIDs . entries ( ) ) {
251+ if ( id === expressID ) {
252+ guids . push ( guid ) ;
253+ break ;
254+ }
255+ }
256+ }
257+ }
258+ return guids ;
259+ }
260+
235261 /**
236262 * Applies coordinate transformation to the provided models.
237263 * If no models are provided, all groups are used.
You can’t perform that action at this time.
0 commit comments