Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Feature: Enable Sketches object visible in web view #49

Open
amrit3701 opened this issue Jul 6, 2023 · 6 comments
Open

Feature: Enable Sketches object visible in web view #49

amrit3701 opened this issue Jul 6, 2023 · 6 comments
Assignees
Labels
backend relates to the server backend frontend relates to the web frontend
Milestone

Comments

@amrit3701
Copy link
Contributor

No description provided.

@amrit3701 amrit3701 self-assigned this Jul 6, 2023
@amrit3701 amrit3701 added frontend relates to the web frontend backend relates to the server backend labels Jul 6, 2023
@amrit3701 amrit3701 added this to the Open Beta milestone Jul 6, 2023
@amrit3701
Copy link
Contributor Author

First solution

On investigation I found, OBJ support Line segment element. With this we can load sketch object to online viewer. However, current Arch ImportOBJ.py not exporting 2D objects, it only supports shapes which have faces.

I created below OBJ file manually, added a rectangle:

# FreeCAD v0.20 build2 Arch module
# http://www.freecadweb.org
mtllib sketch_drawing.mtl
o Extrude
usemtl color_cccccc
v 0.0 0.0 0.0
v 100.0 0.0 0.0
v 100.0 100.0 0.0
v 0.0 100.0 0.0
l 1 2 2 3 3 4 4 1

After adding support of line segments to 3D viewer, this is how above OBJ file looks like:

Image

Image

We need to update Arch ImportOBJ module code to support 2D objects.

For line segment, we simply add edge start and last vertexes to OBJ and then add l (line) element.

For Curves, first we need to find points on curve by discretize method, and then create line segments.

>>> pts = w.discretize(10)
>>> for i, j in zip(pts[:9], pts[1:]):
... 	Draft.makeLine(i, j)

Image

With this we can load any type of 2D shape to 3D web viewer.

Second solution:

Extrude the 2D sketch object using Part Extrude feature. Set extrude face length to 0.1 um. So with naked eye it looks like line but in actual it's a face object.

http://ec2-54-234-132-150.compute-1.amazonaws.com:8080/share/64ba8baa7d037ab99acfa774

Image

@sliptonic
Copy link
Contributor

Pros and cons?
The second one seems like a work-around rather than doing it right

@amrit3701
Copy link
Contributor Author

I am trying third party DXF loader. If it works, then FC lamdba will generate two file OBJ and DXF. OBJ for 3D shapes and DXF for 2D shape. Then in viewer will load both file on same scene.

https://github.com/gdsestimating/three-dxf

amrit3701 added a commit that referenced this issue Aug 7, 2023
@amrit3701
Copy link
Contributor Author

FC-worker PR: Ondsel-Development/FC-Worker#1

amrit3701 added a commit that referenced this issue Aug 7, 2023
…objects_in_obj

#49, frontend: Support 2d objects
@amrit3701
Copy link
Contributor Author

Ondsel-server PR: #83

@sliptonic
Copy link
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backend relates to the server backend frontend relates to the web frontend
Projects
None yet
Development

No branches or pull requests

2 participants