question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Insert entity export

See original GitHub issue

Dear all, I am using this library to read some dwg files. I have been able to read almost all the entities in the file, but I am having issues with the Insert Entities. What I need is to understand how to position entities in the Insert type correctly in the world. Now seems that all related entities are positioned well, but rotated some kind of 90 degrees

` EntityTransform transform = new() { Rotation = (float)insert.Rotation, Scale = new((float)insert.XScale, (float)insert.YScale), Translation3d = new((float)insert.InsertPoint.X, (float)insert.InsertPoint.Y, (float)insert.InsertPoint.Z), };

        transforms_[transformCount] = transform;

        foreach (Entity entity in insert.Block.Entities)
        {
            if (insert.Normal.Z == -1)
            {
                transform.Rotation *= -1;
                transform.Scale = new(-(float)insert.XScale, (float)insert.YScale);
                transform.Translation3d = new((float)-insert.InsertPoint.X, (float)insert.InsertPoint.Y, (float)insert.InsertPoint.Z);
            }
            ExportEntity(entity, layer, transforms_);
        }`

I am using the quoted code, where insert is my insert entity. I am transforming the entities by father, but rotation is bugged (and some entities are pixels away from their position). Which is the right code to calculate it? I am not able to find any useful example online

The following images show result, first one is from Autodesk DWG TrueView Correct Layout this one is from my code… Wrong layout

Thank you for any help, will be appreciated

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DomCRcommented, Jun 14, 2023

The order of how ACadSharp or any framework reads the different objects should not matter, Autocad creates a section in the dwg file that should contain all the Handles (unique object id) and the offset of where the object is, but in practice the some objects only gives the parent, for example a block, and when you read the block you get all the entities in it. depending on how the framework stores this handles the reading order will vary but the information at the end should be the same.

In the image the values are the same so I’m guessing that everything went fine (I cannot see the angle) so I wouldn’t worry about the order.

Hope that this information helps, as I said in the other message your problem may be related on how you are handling the symmetry of the objects with an inverted normal, try to isolate those and see what’s missing.

1reaction
DomCRcommented, Jun 11, 2023

Outisde ACadSharp I’m quite clueless but if I have to guess I would suggest to review this piece of code:

if (insert.Normal.Z == -1)
{
transform.Rotation *= -1;
transform.Scale = new(-(float)insert.XScale, (float)insert.YScale);
transform.Translation3d = new((float)insert.InsertPoint.X, (float)-insert.InsertPoint.Y, (float)insert.InsertPoint.Z);
}

By changing the normal you are applying a symmetry using the plane XY, the rotation that had in the first state may be to correct the difference between the insert point and the position of the object, by rotating the element again this may cause the invalid positions in your drawing. Try to isolate the elements that are badly rotated and check if they go inside the if and try to correct the rotation by changing the transform.Rotation *= -1;

Hope it helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create custom target entities for the Data Import/Export ...
Go to Data Import/Export Framework > Common > Create a custom entity for data import/export. · Select the table that is related to...
Read more >
How to create DATA ENTITY in D365 FO for import ... - YouTube
How to create DATA ENTITY in D365 FO for import / export (Part 1) | Dynamics 365 Finance & Operations · Comments26.
Read more >
Exporting data entities with BYOD feature in D365 Finance ...
Click on Publish, select the Entity(s) you want to publish and click on Publish. This will create the Staging tables in our BYOD...
Read more >
How To Use A D365 Data Entity
Create Export Project ... First, go to the System Administration>Workspaces>Data management. Or, search for 'Data management' in the search bar.
Read more >
How to Export Entity Data to Excel
Click on the Data tab, expand the (System) entry of the Database, and drag the User entity to the development main editor: Double-click...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found