Use the fit curve to mesh in a script

Use the fit curve to mesh in a script

yosef.ali.omar
Participant Participant
794 Views
7 Replies
Message 1 of 8

Use the fit curve to mesh in a script

yosef.ali.omar
Participant
Participant

Hi 

 

I have created a mesh sketch plane now i would like to convert that "brown" sketch by using the available feature of fit curve to mesh on the ui but in a script. can this be done whether using API calls or text commands 

 

 

0 Likes
795 Views
7 Replies
Replies (7)
Message 2 of 8

yosef.ali.omar
Participant
Participant

after some digging I ended up writing this 

 

 

def fitCurveToMeshSectionSketch(self,
    sketch):

            app = adsk.core.Application.get()
            ui = app.userInterface
            sels = ui.activeSelections

            app.executeTextCommand(u'Commands.Start 
                                              FitCurvesToSectionCommand')

            app.executeTextCommand(u'UI.EnableCommandInput infoFitGeomType 
                                            infoFitGeomTypePeriodicSpline')

            app.executeTextCommand(u'UI.EnableCommandInput infoSection')
            sels.add(sketch)

            app.executeTextCommand(u'Commands.SetDouble infoSplineFitTol 0.1')
            app.executeTextCommand(u'NuCommands.CommitCmd')

However, its not giving me any error but its not executing the command as well 

0 Likes
Message 3 of 8

kandennti
Mentor
Mentor

@yosef.ali.omar .

 

I tried a few things.

 

I can't figure out how to select the lines created by the ParallelMeshPlanarSectionCommand.

 

sels.add(sketch)

This process should not be able to select the desired line. I can confirm that it is not selected even if it is done in the GUI.

 

As for the FitCurvesToSectionCommand, it is not possible with my current knowledge.

0 Likes
Message 4 of 8

yosef.ali.omar
Participant
Participant

@kandennti 

is there away to go around, what I am trying to achieve is after having the sketch section (applying the sketch plane section command) just have a sketch where i can extrude cuz the one produced by the sketch section is a brown sketch which you can't do much with. 

basically what i am doing is this 

cut a mesh (done that)

have the sketch of the cut plane (dont that)

use that sketch to extrude (what I am trying to do now) 

0 Likes
Message 5 of 8

kandennti
Mentor
Mentor

@yosef.ali.omar .

 

It is only a forecast.

The following commands are available within the TextCommands.

Commands.Pick

https://github.com/kantoku-code/Fusion360_Small_Tools_for_Developers/blob/master/TextCommands/TextCo... 

 

If you use this command, you may be able to make a selection.
Unfortunately, I don't know the format of <Point3D> or <BRect>.

0 Likes
Message 6 of 8

yosef.ali.omar
Participant
Participant
can you elaborate further, I dont understand what this commands.pick actually does.
will it allow me to choose a sketch you might think
0 Likes
Message 7 of 8

yosef.ali.omar
Participant
Participant

I was thinking is there a way to get the 3d points of the 'brown' sketch resulting from mesh section sketch, maybe i can use the same coordinate and create a new sketch on top of it that has the same points in space, would that be possible 

0 Likes
Message 8 of 8

kandennti
Mentor
Mentor

@yosef.ali.omar .

 

I think the only last way to do something that is not provided by the API is a text command.
However, since there is no information on text commands, the only way is for the person to try them out.

 

I have experienced many times when Fusion360 crashes or becomes unresponsive because I try. And there is no guarantee that you will reach the goal.
You can't rely on others to inquire about it, because no one knows what to do.

 

 

I have tried a few things about "Commands.Pick".
The format of <Point3D> is

(0,0,0)

The format of <BRect> is

(0,0,0,1)

 

Create a sketch in the XY plane of the root component and execute the following text command

Commands.Pick (0,0,0) (0,0,0,1)

Here is the result.

1.png

The origin is selected.

 

Another thing I found out is that there seems to be an effect of the camera orientation on the screen. Therefore, it seems that we need to manipulate the camera.

 

This does not mean that you will be able to select brown lines or points.

 

If you really want to get a cross section of a selectable mesh, the add-in process here will help.

https://apps.autodesk.com/FUSION/en/Detail/Index?id=5742637258089280352&appLang=en&os=Win64 

However, the "Fit Curves to Mesh Section" will not be available. I would give up if I were you.

0 Likes