ConstructionPlane offsetValue createByObject error

ConstructionPlane offsetValue createByObject error

jaco_tech
Contributor Contributor
779 Views
8 Replies
Message 1 of 9

ConstructionPlane offsetValue createByObject error

jaco_tech
Contributor
Contributor

I am trying to create an offset plane.

 

 

        planeInput = planes.createInput()
        # offsetValue = adsk.core.ValueInput.createByString('10mm')
        offsetValue = adsk.core.ValueInput.createByObject(rect.item(3).startSketchPoint)
        planeInput.setByOffset(targetComponent.xZConstructionPlane, offsetValue)
        planeOne = planes.add(planeInput)    

 

 

with the createByString it works as intended.

But i would like to use the createByObject, this takes a Base object, and and SketchPoint is a Base object.

when debugging, the offsetValue has isValid = True, so does the planeInput.

 

yet it gives an invalid expression.

 

 

 

 

REPEAT Materials panel Error occurred, 3 : invalid expression, An unknonwn error occurred, please validate your inputs and try again:
Traceback (most recent call last):
  File "C:\Users/jaco/DEV/FusionAddins/RepeatMaterials\commands\commandCreatePanel\entry.py", line 418, in generatePanel
    repeatPanel = createRepeatPanel(panelGeneratorInput, repeatPanelComponent)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users/jaco/DEV/FusionAddins/RepeatMaterials\lib\repeatUtils\panelGenerator.py", line 66, in createRepeatPanel
    planeOne = planes.add(planeInput)
       ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users/jaco/AppData/Local/Autodesk/webdeploy/production/06fdec045fd75975b505ab1dcbd568595c1cf626/Api/Python/packages\adsk\fusion.py", line 18091, in add
    return _fusion.ConstructionPlanes_add(self, input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 3 : invalid expression

 

 

Which is not very helpfull.

 

Any ideas ?

0 Likes
Accepted solutions (1)
780 Views
8 Replies
Replies (8)
Message 2 of 9

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

To create a plane at a specific offset over a plane, it needs an input which provides a float value.

If you expect to offset the plane to the Y coordinate (I believe so since you're using XZ plane as base plane) of the startSketchPoint, you can do it so:

offsetValue = adsk.core.ValueInput.createByReal(rect.item(3).startSketchPoint.worldGeometry.y)

 

I understand you're expecting to receive the error message in the planeInput.setByOffset() method, but it seems the offset is being validated (that the ValueInput is of type float) in the add() method instead.

 

Regards,

Jorge Jaramillo

 

0 Likes
Message 3 of 9

jaco_tech
Contributor
Contributor
Thanks for your reply.

According to the documentation it takes in a ValueInput ... how are we supposed to know that it only accepts a ValueInput 'created by Real' ??

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-a4f85da0-15bd-480e-af9a-d9355ebbad08
0 Likes
Message 4 of 9

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

From the offset parameter's description:

Jorge_Jaramillo_0-1726764222075.png

since it says "distance", I suppose it has to be a float or real value.

 

A ValueInput could be of type boolean, string, real (float) or reference to an object.  From these four types the only one that can provide an offset measurement is the real.

It is my assumption, but I could be wrong too.

 

Regards,

Jorge Jaramillo

 

Message 5 of 9

jaco_tech
Contributor
Contributor
Hmm, thats indeed a bit confusing. Hope someone from Autodesk can clarify. If that would be the case i would expect there to be a DistanceValueInput object or so ...
0 Likes
Message 6 of 9

BrianEkins
Mentor
Mentor

The ValueInput object is usually used when you provide a value that will become an expression of a parameter. The offset of a construction plane is a good example. When you interactively create an offset plane, you enter the value in a dialog. You're entering a string that will be used for the parameter expression. If your document units are set to "mm" and you enter "20", the offset will be interpreted as 20 mm. However, it could also be an equation like "Length / 2", and you can specify the units rather than let them default to the document units, so "4 in" would be valid.  These are all string inputs.

 

When programming, you more commonly deal with float values when computing sizes, so the API also lets you provide these values as real numbers. When you use real numbers, they're always assumed to be in the same units that Fusion uses internally. This is cm for lengths and radians for angles. When you provide the value as a real number, Fusion creates a string equivalent it uses for the parameter's expression.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 7 of 9

jaco_tech
Contributor
Contributor
I understand the string and float value input. But my inital question was why it does not (seem) to work with an Object ?
In the UI i often use an OffsetPlane parallel to a reference plane and to an object, a sketch point.
So that if somehow the sketch point moves due to some parametric changes. This construstionPlane also moves.

Is this way of working supported in the API as well ? Or am I just messing it up in code ?
0 Likes
Message 8 of 9

Jorge_Jaramillo
Collaborator
Collaborator

Maybe you need to use setByTangentAtPoint() method instead of the setByOffset() method?

0 Likes
Message 9 of 9

BrianEkins
Mentor
Mentor
Accepted solution

When the API for construction planes was initially implemented, Fusion didn't support creating an offset plane through a point. It was added a few years ago, but the API hasn't been updated to support this. I would expect this to be implemented with a new construction method in the API, something like setByOffsetThroughPoint. In short, I don't think what you're trying to do is currently possible.

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