Sketchpoint coordinate with too many decimals for plane setByThreePoints() ?

Sketchpoint coordinate with too many decimals for plane setByThreePoints() ?

eric.kooistra
Participant Participant
853 Views
5 Replies
Message 1 of 6

Sketchpoint coordinate with too many decimals for plane setByThreePoints() ?

eric.kooistra
Participant
Participant

In my script creatplane.py on github at https://github.com/erkooi/fusion360/blob/main/README.md I get an error in Fusuin360 when I use setByThreePoints() to create a plane. It seems as if some coordinates have too many decimals, because when I reduce the number of decimals in one or more of them, then the plane can be created.

I reproduced the issue in the Sample script "Construction Plane API Sample" at https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-c4edd2d2-aea3-11e5-98bc-f8b156d7cd97 and changed the default coordinates to ones with many decimals:

 

# Create three sketch points
sketchPoints = sketch.sketchPoints
positionOne = adsk.core.Point3D.create(-143, 41, 0)
sketchPointOne = sketchPoints.add(positionOne)
positionTwo = adsk.core.Point3D.create(-49.2778148942438, 75.8733712021419, 0)
sketchPointTwo = sketchPoints.add(positionTwo)
positionThree = adsk.core.Point3D.create(-236.722185105756, 6.12662879785814, 0)
sketchPointThree = sketchPoints.add(positionThree)

 

and then I get this error in Fusion360:

 

Failed:
Traceback (most recent call last):
File "D:/git/fusion360/API/Scripts/ConstructionPlaneApiSample/ConstructionPlaneApiSample.py", line 100, in run
planes.add(planeInput)
File "C:\Users/Gebruiker/AppData/Local/Autodesk/webdeploy/production/b0c303e70bd97cfdc195adab65922cfeffcb363a/Api/Python/packages\adsk\fusion.py", line 15970, in add
return _fusion.ConstructionPlanes_add(self, input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 2 : InternalValidationError : data_->execute(&obj, apiName) && obj

 

Can you please help me with this ?

0 Likes
Accepted solutions (1)
854 Views
5 Replies
Replies (5)
Message 2 of 6

BrianEkins
Mentor
Mentor

I used the coordinates you provided with the sample. commented out the created of the two sketch lines above where the points are created and add a return statement right after the sketch point creation. This resulted in a much simpler model where the three points are obvious. Here's a picture after manually drawing a line between the two points that are the furthest apart. You can see that the points are in a straight line. Colinear points don't define a plane, and as a result, the plane creation will fail. It would be nice if the error message indicated that. I think changing the coordinates' precision was changing them enough that the points were no longer colinear.

 

BrianEkins_0-1705963202914.png

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 6

eric.kooistra
Participant
Participant

Thank you for your quick response. I now realize that I created three points on a line, by using the Sample script "Construction Plane API Sample", because all three points are then in the same sketch. I have now been able to reproduce the issue with these three points in attached SetByThreePoints.txt (I had to rename .py into .txt, because the drop in box does not allow .py):

 

sketchPointOne = 0, -143, 41
sketchPointTwo = 100, -49.2778148942438, 75.8733712021419
sketchPointThree = 100, -236.722185105756, 6.12662879785814

 

If sketchPointOne = 100, -143, 41 so at the x = 100 offset plane, then all three points are one one line. But now I have put sketchPointOne at the origin plane at x = 0, so now it should be possible to create a plane through the three points. However still it seems like setByThreePoints() seems to think that the three points are one line.

 

I also tried these points using the GUI, and then the plane was created, but with the Script SetByThreePoints.py it fails to create the tilted plane. If I slightly move sketchPointOne = 0, -143, 41 to 0, -143, 42, then the script SetByThreePoints.py can create a tilted plane.

 

Do you know why it fails to create the tilted plane ?

0 Likes
Message 4 of 6

BrianEkins
Mentor
Mentor

I looked into this some more, and something weird is going on. A bug has been filed.

 

Strangely, I simplified your program so that all three points are created in the same sketch. A sketch is 3D, and the Z component of the sketch points does not have to be zero. By slightly modifying your script, I could create all three points, with two of them being offset in the Z direction. It still uses your original coordinates but successfully creates the construction plane. The creation of the construction plane fails when creating the points on separate sketches.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 5 of 6

eric.kooistra
Participant
Participant

I tried what you described, by using all points in one sketch (I use the origin sketch in the yZConstructionPlane) and with z = 100 for the two offset points. Now it does indeed create the tilted plane.

 

I did not know that it is allowed to define z != 0 for a sketch point. In https://github.com/erkooi/fusion360/blob/main/API/libraries/schemacsv360.py I therefore use get_3d_point_in_offset_plane() to determine the (x, y, 0) coordinate for the point in the sketch. To be honest I do not fully understand the implications of using z != 0 for a sketch point, because the sketch is in a flat 2D xy plane, so how can it have a z coordinate != 0 that is then outside that plane? How does that correspond to what you can do via the GUI?

0 Likes
Message 6 of 6

BrianEkins
Mentor
Mentor
Accepted solution

Sketches are 3D, but in the UI, they mostly behave like 2D, where the geometry you sketch lies on the X-Y plane.

 

When a sektch is active, there is an option in the SKETCH PALETTE dialog for "3D Sketch". When it is checked, you have some additional capabilities to sketch in 3 dimensions. This doesn't change the sketch itself, but just the UI to make it easier to draw in 3D. Another way to see this is to draw geometry on the X-Y plane and then use the Move command to move sketch geometry out of the X-Y plane. 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com