Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS Implementation for Sheet Indexes #6992

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open

TS Implementation for Sheet Indexes #6992

wants to merge 50 commits into from

Conversation

Ellord207
Copy link
Contributor

@Ellord207 Ellord207 commented Jul 22, 2024

Context:

My team is working on creating features to facilitate the production of 2d drawings and sheets for users using iTwin.js. To do this, we need to be able to insert Sheet Indexes and their relational elements into the iModel. Since there are no Sheet Index TS implementations, we took the initiative and started creating them ourselves.

I have created an accompanying Discussion Post as a more appropriate place for this discussion.

Description

After discussions, I am intending this PR to include the basic implementations for the Sheet Index. This including backend Classes, common props, Codes, and tests.

After more discussion, future PR(s) will follow to answer the following questions:

  • How to ensure a consistent order of the Sheet Index Entries during editing, specifically including when using SheetIndexReferences among other scenarios.
  • How to automatically generate and update sheet labels/page numbers during editing.
  • Enforcing the 1 SheetReference per Sheet rule.
  • And possibly other limitations to ensure consistency across the platform.

ExtensiveTestScenario.populateDb(iModelDb);
iModel = iModelDb;

await insertCodeSpec(iModel);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? This steps feel like it should already have happened. Is this what was meant by, "Ensure the new codes are included in pre-existing iModels"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer to @aruniverse to investigate and confirm this question.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built-in code specs are registered in native code when creating a new DgnDb by DgnDb::CreateCodeSpecs.
That function notably does not register sheet index-related code specs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeSpecs use server-issued Ids. There is some attempt to prevent conflicts between briefcases. I think you will need to make your createCode functions ensure that they register the relevant CodeSpec if not already present in the iModel. You may wish to add documentation to your new BisCodeSpec members indicating that they are only created in an iModel on first use.

@khanaffan should we consider a DgnDb schema upgrade that adds these code specs if not present?

Copy link
Contributor Author

@Ellord207 Ellord207 Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the iModel indirectly seems like a side effect we should avoid, but I'm not sure if there's an instance where a user would want to create a code an not immediately update the iModel with a new element. Plus, I can't think of a more elegant way.

Implemented as suggested

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though feel like we should have different approach where its like define in custom attribute in BisCore. So we do not have to add them via profile version change instead biscore can be modified to add builtin code that will exist in seed file or upgraded file. So we can tie it to biscore rather then runtime.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khanaffan can you ping me sometime today to clarify your suggestion please?

@Ellord207 Ellord207 marked this pull request as ready for review August 27, 2024 14:38
@Ellord207 Ellord207 requested review from a team as code owners August 27, 2024 14:38
import { SheetIndexFolderOwnsEntries, SheetIndexOwnsEntries, SheetIndexReferenceRefersToSheetIndex, SheetReferenceRefersToSheet } from "./NavigationRelationship";

/**
* A bis:InformationReferenceElement used to organize bis:Sheet instances into a hierarchy with the assistance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please link to the Sheet Index section of docs/bis/domains/drawings-sheets.md where people can learn what a sheet index is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a URL to the doc site. I wasn't sure if there's a better way to do that or not. If there is, I couldn't find an example of it in the repo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use $docs to reference the base url without hard coding a specific environment. Something like: [SheetIndex]($docs/bis/domains/drawings-sheets#sheet-index)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Updated

* @returns The newly constructed SheetIndexReference element.
* @throws [[IModelError]] if unable to create the element.
*/
public static create(
Copy link
Member

@pmconne pmconne Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many args here and in insert, same for SheetIndexFolder and SheetReference methods. Consolidate into an "arguments" object so people can't screw up the order of the 4 string arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored

core/backend/src/Model.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants