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

Issue 679 - Add support for DWG importer #680

Merged
merged 18 commits into from
Jun 10, 2024
Merged

Issue 679 - Add support for DWG importer #680

merged 18 commits into from
Jun 10, 2024

Conversation

sebjf
Copy link
Contributor

@sebjf sebjf commented May 1, 2024

This fixes #679 - DWG object handles do not match Navis.

This PR adds a dedicated DWG importer using the Drawings SDK, replacing the previous importer which converted the DWG to a DGN, and then imported that using the DGN importer.

The new importer preserves the Handle Ids from AutoCAD, and better matches the Navisworks tree.

Description

New classes

  • The new importer follows the pattern of the existing ODA importers: a FileProcessor reads the file into an OdDatabase, which is then vectorised by a Graphics System View subclass (DataProcessorDwg), which sets up the collector layers and metadata, before the Gs tesselates the geometry into the DataProcessor superclass's methods.

View

  • The importer always imports the ModelSpace view.

Blocks

  • The importer creates tree nodes for all primitives outside of Blocks, and Block References. Block References take the name of their Block. All nested Block Entities are collapsed to the top level Block Reference.
  • Where Block Entities are assigned to different layers, tree nodes are created for the top-level Block Reference under each relevant layer. This allows the user to select & toggle elements by Layer regardless of Block membership, mirroring the behaviour of AutoCAD and Navisworks.

Names

  • Leaf nodes take the name of the type of primitive. Known class names are converted to a user-friendly name, mirroring the behaviour of Navisworks.

Metadata

  • Entities have only one metadata entry (Entity Handle::Value), which contains the hex encoded handle of the object. This handle can be seen in AutoCAD with the LIST command.

Colours

  • ODCOLORREF has been replaced with OdCmEntityColor in the MaterialColours struct across all ODA importers.
  • This is because this struct is part of the DataProcessor superclass which is used in a number of places.
  • The change was made because the ODCOLORREF macros are encoding dependent, and a different coding was turning up for DWGs leading to colour channels being swapped. OdCmEntityColor should handle this transparently.

CMake

  • New dependencies have been added to FindODA.cmake
  • Additionally the ODA_LIB_NAMES variable now has each entry on its own line as is done for the sources and headers, to make diff/change control easier

Unit Tests

  • Two new unit tests for DWGs have been added, to check the tree logic, and to check that password protected DWGs fail with an appropriate error.

Things to note

  1. A new error code has been added for the password protected case. The code is 37. This code will also be used by A new error code for model import failures due to encrypted file #667.
  2. The handle entities created by the new importer are "correct", however they do not match those created by the NWD importer or the (Navis) plugin. The plugins and NWD importer will need to be changed before cross referencing will work.

@carmenfan carmenfan self-assigned this May 2, 2024
Copy link
Member

@carmenfan carmenfan left a comment

Choose a reason for hiding this comment

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

General seems ok (as far as I can tell with the very small amount of dwg models I have!)

bouncer/src/repo/error_codes.h Show resolved Hide resolved
carmenfan
carmenfan previously approved these changes May 30, 2024
Copy link
Member

@carmenfan carmenfan left a comment

Choose a reason for hiding this comment

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

This is fine and good to merge

Just waiting on #685 so we can merge that in first (incase we need to do a hotfix!)

Issue 667 - New error code for encrypted NWDs
Copy link
Member

@carmenfan carmenfan left a comment

Choose a reason for hiding this comment

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

@sebjf travis is upset after merge from staging 😢

@sebjf
Copy link
Contributor Author

sebjf commented Jun 10, 2024

@carmenfan fixed!

@carmenfan carmenfan merged commit 33b2131 into staging Jun 10, 2024
3 checks passed
@carmenfan carmenfan deleted the ISSUE_679 branch June 10, 2024 14:33
@carmenfan carmenfan removed their assignment Jun 11, 2024
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.

2 participants