Insert entity export
See original GitHub issueDear 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 this one is from my code…
Thank you for any help, will be appreciated
Issue Analytics
- State:
- Created 3 months ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
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.
Outisde
ACadSharp
I’m quite clueless but if I have to guess I would suggest to review this piece of code: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!