Issue creating offset with ValueInput less than one

alden_360
Contributor

Issue creating offset with ValueInput less than one

alden_360
Contributor
Contributor

Hi all,

 

I am doing some testing to implement the new OffsetConstraintInput functionality to get code that was using the retired offset function working again. I am running in to an issue where if I try to use a ValueInput that is less than one I get an "RuntimeError: 3 : invalid argument offset distance" error thrown on this line: 

offset_input = sk.geometricConstraints.createOffsetInput(line, value_input)

 

Seemingly any value above 1 that I have tested works, and 0.9999999999999999999 seems to get rounded up to 1 and function. Does anyone have any insight in to what is going on here? Full test code is posted below.

 

Thanks,

Alden

 

def command_execute(args: adsk.core.CommandEventArgs):
    # General logging for debug.
    futil.log(f'{CMD_NAME} Command Execute Event')

    # TODO ******************************** Your code here ********************************
    product = app.activeProduct
    rootComp = adsk.fusion.Design.cast(product).rootComponent
    sk = rootComp.sketches.add(rootComp.xYConstructionPlane)
    point1 = sk.sketchPoints.add(rootComp.originConstructionPoint.geometry)
    point2 = sk.sketchPoints.add(adsk.core.Point3D.create(10, 0, 0))
    line = [sk.sketchCurves.sketchLines.addByTwoPoints(point1, point2)]
    value = 0.99
    value_input = adsk.core.ValueInput.createByReal(value)
    offset_input = sk.geometricConstraints.createOffsetInput(line, value_input)
    sk.geometricConstraints.addTwoSidesOffset(offset_input, True)

 

0 Likes
Reply
546 Views
6 Replies
Replies (6)

BrianEkins
Mentor
Mentor

This looks like a nasty bug. I can reproduce the problem and will make sure it's logged. I tried several unsuccessful workarounds but finally found one that works. It creates the offset with a value greater than one and then edits the parameter controlling the offset to the desired value. Here's the modified section of the code.

 

value_input = adsk.core.ValueInput.createByReal(1.1)
offset_input = sk.geometricConstraints.createOffsetInput(line, value_input)
offsetConst = sk.geometricConstraints.addTwoSidesOffset(offset_input, True)
offsetConst[0].dimension.value = 0.5

 

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

alden_360
Contributor
Contributor

Thanks for looking into this @BrianEkins. That workaround should work for me for the time being.

 

Is there a way to be notified ahead of time when functions/methods will be retired? I assume there is but wasn't able to find it in my searching. The sketch.offset functionality was used in a few add-ins critical to some of our processes and I'd like to be prepared for this happening in the future.

 

Thanks again,

Alden

0 Likes

alden_360
Contributor
Contributor

Should note that this workaround does still cause issues if the 1cm offset breaks the topology of the offset curves when the wanted "offsetConst[0].dimension.value" would not (which for my uses is most of the time).

0 Likes

BrianEkins
Mentor
Mentor

It's not usually practical for Autodesk to be able to pre-notify about something that will be retired. Often, the API team doesn't know until the last minute and is reacting to an internal change. However, because something is being retired doesn't mean that you can't use it. Unless a significant internal change makes supporting the old function impossible, the retired function should continue to work. It's flagged as "retired" to encourage people to use the new API function, which probably uses the same internal function the updated command is using.

 

Regarding the issue with the topology breaking, you could change the setting to allow a change in the topology. I guess you could set this back after you've changed the parameter value.

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

rohit.bapat
Autodesk
Autodesk

Hello @alden_360 

 

I wanted to give some update about the issue. We have logged a ticket FUS-172314 for the development team to look into. The team is working on it, and the solution is going through validation. It will be released soon after validation is complete.

 

Thank you for your patience





Rohit Bapat
Product Owner
2 Likes

alden_360
Contributor
Contributor

Great, thanks for the update Rohit.

0 Likes

Type a product name