Skip to content

Commit

Permalink
Select primitive on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Oct 25, 2024
1 parent a4fda90 commit 35472aa
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/base/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { DocumentRegistry } from '@jupyterlab/docregistry';
import { PathExt } from '@jupyterlab/coreutils';
import { MainViewModel } from './3dview/mainviewmodel';
import { handleRemoveObject } from './panelview';

import { v4 as uuid } from 'uuid';
export function newName(type: string, model: IJupyterCadModel): string {
const sharedModel = model.sharedModel;

Expand Down Expand Up @@ -1217,9 +1217,10 @@ namespace Private {
name: Name
};

const sharedModel = current.context.model.sharedModel;
const jcadModel = current.context.model;

if (sharedModel) {
if (jcadModel) {
const sharedModel = jcadModel.sharedModel;
if (!sharedModel.objectExists(objectModel.name)) {
// Try a dry run with the update content to verify its feasibility
const currentJcadContent = current.context.model.getContent();
Expand All @@ -1241,6 +1242,12 @@ namespace Private {
objectModel.shapeMetadata = objMeta;
}
sharedModel.addObject(objectModel);
setTimeout(() => {
jcadModel.syncSelected(
{ [objectModel.name]: { type: 'shape' } },
uuid()
);
}, 0); // doing the selection at the next tick
} else {
showErrorMessage(
'The object already exists',
Expand Down

0 comments on commit 35472aa

Please sign in to comment.