js-dxf icon indicating copy to clipboard operation
js-dxf copied to clipboard

zoom to layers extent

Open clavijojuan opened this issue 2 years ago • 21 comments

Maybe but i think that is most important a method or function to make "zoom to layers extent"

Originally posted by @clavijojuan in https://github.com/ognjen-petrovic/js-dxf/issues/69#issuecomment-1021588211

clavijojuan avatar Jan 25 '22 20:01 clavijojuan

what behavior we expect from that feature?

ognjen-petrovic avatar Jan 26 '22 07:01 ognjen-petrovic

Hi,

I think the feature is fit in view. When you open the dxf the entities not showing up in first time you should make a fit in view to show them.

I have an implementation of this in my lib.

To make this work You need to calculate the bounding box of all entities. So also bounding box for every entity to make this happen need some work and maths. 😢

tarikjabiri avatar Jan 26 '22 10:01 tarikjabiri

Hola,

Creo que la función se ajusta a la vista. Cuando abre el dxf, las entidades que no aparecen la primera vez, debe hacer un ajuste a la vista para mostrarlas.

Tengo una implementación de esto en mi lib.

Para que esto funcione, debe calcular el cuadro delimitador de todas las entidades. Entonces, también el cuadro delimitador para cada entidad para que esto suceda necesita algo de trabajo y matemáticas.😢

Hi @tarikjabiri can u share this implementation? I actually have the bbox (extent of entities) because in my app I'm trying to convert geojson features to DXF file. In leaflet u can calculate bbox with function :p

clavijojuan avatar Jan 26 '22 11:01 clavijojuan

Hi,

I think the feature is fit in view. When you open the dxf the entities not showing up in first time you should make a fit in view to show them.

I have an implementation of this in my lib.

To make this work You need to calculate the bounding box of all entities. So also bounding box for every entity to make this happen need some work and maths. 😢

An easy way to calculate bbox is using turf.js. Hope helps

clavijojuan avatar Jan 26 '22 11:01 clavijojuan

dxf dev branch I have a class `BoundingBox' and see Sections/Entities/Entities they use this class to calculate bbox and set the center and height of the vport

Or try this lib if it could help you. 😅

I will implement this in this lib when I have time.

tarikjabiri avatar Jan 26 '22 12:01 tarikjabiri

Hi,

I think the feature is fit in view. When you open the dxf the entities not showing up in first time you should make a fit in view to show them.

I have an implementation of this in my lib.

To make this work You need to calculate the bounding box of all entities. So also bounding box for every entity to make this happen need some work and maths. 😢

An easy way to calculate bbox is using turf.js. Hope helps

But this work with geojson features not in dxf world there is some deferences.

tarikjabiri avatar Jan 26 '22 12:01 tarikjabiri

Hi, I think the feature is fit in view. When you open the dxf the entities not showing up in first time you should make a fit in view to show them. I have an implementation of this in my lib. To make this work You need to calculate the bounding box of all entities. So also bounding box for every entity to make this happen need some work and maths. 😢

An easy way to calculate bbox is using turf.js. Hope helps

But this work with geojson features not in dxf world there is some deferences.

ahh ok sorry :(

clavijojuan avatar Jan 26 '22 12:01 clavijojuan

I will implement this in this lib when I have time.

Thanks you 👍

clavijojuan avatar Jan 26 '22 12:01 clavijojuan

I have some time will try to add this feature...

ognjen-petrovic avatar Jan 30 '22 09:01 ognjen-petrovic

I have some time will try to add this feature...

Thanks you <3

clavijojuan avatar Jan 30 '22 13:01 clavijojuan

There is new branch fit-zoom. computeBoundingBox method has been added to Line and Circle. In example folder is zoom.js that sets view port height, some other values also should be set as well... In DraftSight it looks ok so far:

image

Does it look same in AC?

ognjen-petrovic avatar Jan 31 '22 20:01 ognjen-petrovic

I dont see "zoom.js" on example folder

clavijojuan avatar Jan 31 '22 20:01 clavijojuan

ah sorry, it is now.

ognjen-petrovic avatar Jan 31 '22 20:01 ognjen-petrovic

Autocad :

image

Almost

clavijojuan avatar Jan 31 '22 21:01 clavijojuan

Hi,

I suggest creating a class BoundingBox that compute bounding box for every entity and return the global bounding box of all entities so we did not need for creating a method in every entity.

For help I have a function for computing boundingbox of ellipse it is ready so no more work on it I will added it.

tarikjabiri avatar Feb 01 '22 11:02 tarikjabiri

I have added centerPoint property to Viewport class. Those are 12 and 22 from the documentation

Here is same circle moved a little bit:

image

Does the center point work in AC?

ognjen-petrovic avatar Feb 05 '22 15:02 ognjen-petrovic

Autocad:

image

Can you try with higher coordinates such as (1200000, 1100000) ?

clavijojuan avatar Feb 05 '22 17:02 clavijojuan

OK it works. Thanks.

I did not get this:

Can you try with higher coordinates such as (1200000, 1100000) ?

ognjen-petrovic avatar Feb 05 '22 19:02 ognjen-petrovic

I did not get this:

Can you try with higher coordinates such as (1200000, 1100000) ?

I was referring to create the circle at coordinates away from the origin of usc like so:

const circle = new Circle(1200000, 1100000, 200)

clavijojuan avatar Feb 06 '22 14:02 clavijojuan

Aha...Could you try to do that?

On Sun, 6 Feb 2022 at 15:45, clavijojuan @.***> wrote:

I did not get this:

Can you try with higher coordinates such as (1200000, 1100000) ?

I was referring to create the circle at coordinates away from the origin of usc like so:

const circle = new Circle(1200000, 1100000, 200)

— Reply to this email directly, view it on GitHub https://github.com/ognjen-petrovic/js-dxf/issues/70#issuecomment-1030846772, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA256WQA53DLW6BW4LW3DV3UZ2CQZANCNFSM5MZJIE6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

ognjen-petrovic avatar Feb 07 '22 10:02 ognjen-petrovic

Aha...Could you try to do that?

It works

clavijojuan avatar Mar 05 '22 21:03 clavijojuan