Offset issue

Offset issue

dinocoglitore
Advocate Advocate
1,607 Views
9 Replies
Message 1 of 10

Offset issue

dinocoglitore
Advocate
Advocate

I found some behavior that I don’t understand regarding the offset of a set of closed loops.

I have two closed loops almost similar, generated by two dxf file and slightly rotated by an angle.

spline_sketches.PNG

I used the same function to generate the offset inward for the two closed loops.

This is the code:

 

def offsetShape(sketch, thickness):
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
	spline = sketch.sketchCurves.sketchFittedSplines.item(0)
        
        # Create a collection of entities for move
        curves = adsk.core.ObjectCollection.create()
        # move the entire oval
        curves.add(spline)

        # Create the offset.
        dirPoint = adsk.core.Point3D.create(0, 0, 0)
        offsetCurves = sketch.offset(curves, dirPoint, thickness)       
		
        # find the inside profile
        # item(0) should be the outside profile
        profInt = sketch.profiles.item(1)
		
        return profInt
		
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

I find the same behavior using the UI. So I recreate the issue using the interface.

If I create the offset for the first loop all is ok. It generates a closed loop inward:

offset_1.PNGoffset_1_ok.PNG

It creates only one closed spline .

But if I do the same operation for the second loop it give me two splines (this could be right) but it does not close the loop:

offset_2.PNGoffset_2_not_ok.PNG

open_llop.PNGtwo_spline.PNG

 

Someone can help me ?

Thanks

Dino

0 Likes
Accepted solutions (1)
1,608 Views
9 Replies
Replies (9)
Message 2 of 10

ekinsb
Alumni
Alumni

It seems that the curves in the second place aren't connected.  They may or may not geometrically touch (the endpoints are at the same coordinate) but I don't think they share the same sketch point.  The white point that I can see in your image indicates that there is an free end point.  Because they're not connected, the offset doesn't attempt to keep that corner closed.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 10

dinocoglitore
Advocate
Advocate

Hi Brian, thanks for the immediate reply. But there is something that I don’t understand in your answer.

When I use the offset operation I start from a closed loop that has no point on it.

spline_singola.PNG

It is closed, in fact I can select it and point out the relative profile.

profile.PNG

When I use the offset operation on it,  a point (the white one) springs up on the original spline and the created curve (inward offset curve) is open and consists of two spline.

offset_2_not_ok.PNG

I can see the gap in the offset curve if I use the max zoom I can use in the UI.

With this zoom there is no gap in the original curve.

open_llop.PNG

In addition I can remove the white point on the original curve, selecting it and deleting it.

offset_curv_eno_point.PNG

Thanks

Dino

0 Likes
Message 4 of 10

dinocoglitore
Advocate
Advocate

Just another little information.

The original curve come from a scale operation.

Is it useful to understand the issue ?

Thanks

0 Likes
Message 5 of 10

ekinsb
Alumni
Alumni

It's best if you can provide a very small data set and a series of instructions that we can use to reproduce the problem.  If you can reproduce just using commands and not the API that's even better because then we know it's a general problem with the command functionality and not something that is API specific.  If I can reproduce the problem then we can investigate the cause and hopefully fix it.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 6 of 10

dinocoglitore
Advocate
Advocate

I thank you for the reply. Maybe I’ve found the problem. It is connected to the copy operation from one sketch to another.

I attach three dxf file: 22.dxf, 21.dxf and 2.dxf

The first have no problem. The second and third have it.

These are the steps I followed to reproduce the issue.

·         Insert a dxf file choosing the XY plane (this create a closed curve – CURVE_0 and a new sketch – (it has the name of the dxf file)

·         Create a construction plane with offset 22.5 mm from the XY plane

·         Create a sketch (SKETCH1) over the new plane

·         Select the CURVE_0 and copy it on the new sketch (SKETCH1). I call it CURVE_1. I used CTRL-C – CTRL-V to make the copy.

·         Use the Offset operation selecting the CURVE_1 and choosing an offset of -1.0 mm

If I use the 22.dxf curve there is no problem. If I use the 21.dxf or the 2.dxf curve the problem arises. If I use the offset operation on the same sketch there is no problem at all.

Maybe the problem is connected to the dxf file ? I have no competence about the dxf format so reading the file with an editor I cannot understand if there are problems.

When I do the copy operation a white point arises in every dxf file. I don’t know why !

I hope that the description is clear.

 

Thanks a lot

0 Likes
Message 7 of 10

dinocoglitore
Advocate
Advocate

Here are the dxf Files.

Thanks

Dino

 

0 Likes
Message 8 of 10

ekinsb
Alumni
Alumni
Accepted solution

I've logged a bug for the sketch team to look at it.  Since it's a bit of an odd workflow I'm not sure how high of a priority it will be compared to other tasks they're working on.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 9 of 10

dinocoglitore
Advocate
Advocate

I thank you for your kindness. If you think that the problem I had is a little bug, I hope that the problem will be solved soon for the sake of the community.

Dino

0 Likes
Message 10 of 10

dinocoglitore
Advocate
Advocate

I Brian, I had the doubt that the problem can be connected to the DXF files that I sent you so I decided to recreate the two file 2.dxf and 21.dxf. I drew again the closed splines and I made again the tests. The result is that the problem has gone away.

Talking with you has been helpful and it has clarified the problem.

I thank you a lot

Dino

0 Likes