AutodeskAILab / Fusion360GalleryDataset

Data, tools, and documentation of the Fusion 360 Gallery Dataset
Other
421 stars 51 forks source link

How to acquire 3D-Constraints info based on provided 2D-Constraints and Extrusion? #86

Closed StevenZzz07 closed 3 years ago

StevenZzz07 commented 3 years ago

Hi,

Firstly thanks for selflessly releasing such outstanding dataset for public!

As depicted in paper, Fusion360Gallery provides constraints information on 2D sketch, such as CoincidentConstraint or ColinearConstraint. However, these provided constraints all lie in 2D domain rather than 3D. To me, the 3D constraints information is equally important to their 2D counterpart and can also be applied for many meaningful tasks. So i wonder whether there are some available tools to be applied to extracting 3D constraints info from the existing 2D sketch constraints and extrusion sequence?

Look forward to your reply! Thanks in advance.

karldd commented 3 years ago

Great question. In Fusion 360 there are various ways you might setup 3D constraints, for example with Joints or User Parameters. We unfortunately don't have any of that information in the reconstruction dataset, as it focuses on the sketch and extrude modeling operations. Probably the closest thing we have is the ability to constrain a sketch to a B-Rep face, by selecting the face as the sketches reference plane.

Is there something specific you were looking for?

StevenZzz07 commented 3 years ago

Thanks for ur timely reply. However, i am a little confused with the "constrain a sketch to a B-Rep face" as you mentioned. I suppose you mean we could first locate a target sketch in B-Rep representation then we can infer the 3D relation btw the sketch and other primitives based on the B-Rep information? Have i got you point :) ?

karldd commented 3 years ago

So here I am talking about the functionality of constraints in parametric CAD. Let me see if I can illustrate.

Supposed we create a first extrusion like this:

image

Then we want to add another extrude on top of it like this:

image

There are two different ways to do this.

  1. We can select the top face, draw a sketch on it, then extrude it.

    image
  2. We can select the XY plane, draw a sketch, and then extrude all the way to the top.

    image

Now lets say we want to change the distance we extrude the first extrusion.

  1. Will look like this:

    image
  2. Will look like this:

    image

This is because in 1, the sketch is 'constrained' to the top face of the first extrusion. While 2 is defined by the XY plane. So this is what I mean by constrain a sketch to a B-Rep face.

StevenZzz07 commented 3 years ago

OKkkkkk, i have got your point! Thank you very much.

Also, i have another question to ask for help. Right now, I need to obtain the primitives correspondence btw design sequence(.json) and B-rep (.smt). I notice that the idx value in Extrude/faces could be used to build such face correspondence. However, i have some problems to parse the provided .smt file with no availability to any APIs or python packages to read this file format. So how could i read a .smt file effectively? Is there any existing packages or tools to do it?

Thank you in advance :)

karldd commented 3 years ago

So the .smt files are used by Fusion 360. See how to get setup with Fusion 360 here.

From the documentation you can use the index to reference the face once you import it into Fusion 360. Then read it with something like this:

app = adsk.core.Application.get()
design = adsk.fusion.Design.cast(self.app.activeProduct)
# Get the first body
body = design.rootComponent.bRepBodies[0]
# Get the first face
face = body.faces[0]

The other option is you could use the point_on_face to locate the face from the B-Rep .step file. The point is typically in the center of the surface of the face. The options for working with .step files are pyOCC or FreeCAD. Both use Open Cascade as the CAD kernel.

"faces": {
    "eab25b94-e6ef-11ea-8960-acde48001122": {
        "index": 0,
        "surface_type": "PlaneSurfaceType",
        "point_on_face": {
            "type": "Point3D",
            "x": 2.0000000298023224,
            "y": 0.30000000447034836,
            "z": 1.6
        }
    },
StevenZzz07 commented 3 years ago

Great! Let me have a try on them. Thanks a lot!

StevenZzz07 commented 3 years ago

Hello! One more question please.

Now i am dealing with the Reconstruction dataset, and i want to visualize the specific B-Rep edge indexed by the body-face-edge-idx from .json and .smt file. One example is as follows, i want to colorize the particular edge: image

This example is done by OCC and SVG based on .step file, but i think there is no index correspondings in provided .step file. So is there any tools or script available in Fusion360Gallery to achieve this? Thanks!

karldd commented 3 years ago

You are correct, we don’t provide entity index information for STEP files, but you can use the SMT files with Fusion 360 and cross reference to the indices there.

One possible approach for faces is to use the point_on_face to search for the face in the STEP file. This point will be on the surface of the face, typically at the center.

StevenZzz07 commented 3 years ago

Thanks, i will try!