Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Now available for Insiders to try: API improvements and fixes

5 REPLIES 5
Reply
Message 1 of 6
keqingsong
606 Views, 5 Replies

Now available for Insiders to try: API improvements and fixes

Hello add-in authors and script writers, with the upcoming May 2022 product update right around the corner, we'd like to share with you the latest API improvements going into that release. These improvements are also available to try right now in our Insider Build. If you are a Fusion 360 Insider, make sure you have the latest version of your Insider Build and check out these new improvements.

 

If you are not a Fusion 360 Insider (or have the Insider build installed), becoming a member of our Insider Program is very easy, just go to this application page and apply to join. Once you're in, you'll be able to get the Insider Build and start testing.
___

 

Here are the improvements and fixes for API, currently available in the Insider Build:

NEW | We’ve added API support for the following preferences settings since we see them as commonly set preferences by many of you. You are now able to automate these.

 

  1. isAutoProjectEdgesOnReference 
  2. isAutoHideSketchOnFeatureCreation 
  3. isSketchScaledWithFirstDimension  
  4. isAllowReferencesDuringEditInPlace  
  5. isEnableArrangeAndSimplifyTools  
  6. isSkipCreationWhenLiveUpdate   
  7. isDefaultMeasureShown  
  8. panZoomOrbitShortcuts  
  9. isWoodBumpEnabled  
  10. isLimitEffectsDuringNavigation  
  11. isSurfaceNormalDisplayDisabled  
  12. isGoogleAnalyticsTrackingEnabled 

 

Improved | For commands that use a slider that also shows spinner inputs to edit and display the value, often the spinner field was not wide enough to display the entire number. You had to click into the field and then scroll left and right to see what the current value is. Now you will either have a spinner or a stepper at a time but never both.  

 

Improved | Peter__B reported that Viewport::saveAsImageFile() did not support the "Transparent Background" option. Now the transparent background is supported using app.activeViewport.saveAsImageFileWithOptions(SaveImageFileOptions). 

 

Improved | You are now able to apply and read information from 3D appearance texture and orientation, like how 3D wood controls wood grain direction. We’ved addd MeshBody.textureMapControl property to NIDL. 

 

Improved | When creating a Boundary Fill feature there is an option in the UI whether to keep the tool bodies or not. This was missing in the API. With this update, the Remove Tools option is now supported. 

 

Fixed | We fixed an issue where if you hid the browser tree manually from View > Hide Browser and tried to Reset Layout twice once, the browser tree didn’t reappear like it was supposed to. Trying Reset Layout again and it came back. Now doing a Reset Layout the first time will unhide the browser.  

 

Fixed | We fixed an API issue where the appearance material API was returning the wrong materials. In the UI everything worked as expected; the bodies changed to the correct color you assigned them to, and the Appearance dialog correctly showed them as such.  The API, however had big problems with querying the appearances. Now the correct appearances are returned. 

Fixedseb.quevillon.1 told us that he was unable to delete multiple sub assemblies under the top node. From an API standpoint, When we created StrongRef of DcNodes in API framework, we increased the ref count of xRefs by 1. In place of StrongRefs, we've created PassiveRefs, so that we don't increase the refcount of Xref entities. This is now fixed.  

Fixed an issue that was occuring when you tried to read texture property value from a Fusion library asset and kept getting the following error: InternalValidationError : pIProperty->GetConnectedAssetCount() > 0 && pIProperty->IsConnectionEnabled(). Now none of the properties will fail again.   

 

Fixed | When you used the DataFiles.itemById method with an id that contains the version, the dataFile returned was always the latest version, rather than the specified version. This is now fixed.  

 

Fixed | The nativeObject and createForAssemblyContext functions were missing on the SketchText object. It did support the assemblyContext property because that was defined on the parent SketchEntity class. We fixed this issue so that now, nativeObject and createForAssemblyContext functions are available for the Sketch Text object. 

 

___


Join the Insider Program to try these improvements

Again, if you are not a Fusion 360 Insider (or have the Insider build installed), becoming a member of our Insider Program is very easy, just go to this application page and apply to join. Once you're in, you'll be able to get the Insider Build and start testing.


Keqing Song
Autodesk Fusion Community Manager
Portland, Oregon, USA

Become an Autodesk Fusion Insider



5 REPLIES 5
Message 2 of 6
kandennti
in reply to: keqingsong

Hi @keqingsong .

 

Thanks for the valuable information.
I ran the following script in Ver 2.0.13122 and could not find some of the new additions.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface

        target = [
            'isAutoProjectEdgesOnReference',
            'isAutoHideSketchOnFeatureCreation',
            'isSketchScaledWithFirstDimension',
            'isAllowReferencesDuringEditInPlace',
            'isEnableArrangeAndSimplifyTools',
            'isSkipCreationWhenLiveUpdate',
            'isDefaultMeasureShown',
            'panZoomOrbitShortcuts',
            'isWoodBumpEnabled',
            'isLimitEffectsDuringNavigation',
            'isSurfaceNormalDisplayDisabled',
            'isGoogleAnalyticsTrackingEnabled',
        ]

        prefs = app.preferences
        prefsProps = [pref for pref in dir(prefs) if pref[0] != '_']

        for prefName in prefsProps:
            pref = getattr(app.preferences, prefName)
            app.log(f'-- {prefName} --')
            props = dir(pref)
            for prop in props:
                if prop[0] == '_':
                    continue
                hit = '-- Found!!' if prop in target else ''
                app.log(f'  {prop} {hit}')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

I think it is due to my lack of understanding, but I can't find them because I don't know the object names.
I will wait until the documentation is updated after the official release.

Message 3 of 6
keqingsong
in reply to: kandennti

If you ran your script on Ver 2.0.13122, you will not see it. 2.0.13122 is the current version available to the general public, but these fixes are only available in the Insider Build at this time, and it is on a newer version. If you are not a Fusion 360 Insider member, you can apply to join here:

https://feedback.autodesk.com/key/Fusion360Insider



Keqing Song
Autodesk Fusion Community Manager
Portland, Oregon, USA

Become an Autodesk Fusion Insider



Message 4 of 6
kandennti
in reply to: keqingsong

@keqingsong .

 

As of yesterday, the Producton Build is Ver 2.0.12888.
Today, the Insider Build was Ver 2.0.13134 and I tried it, but could not find some parts.

 

I will wait until the Producton Build is updated.

Message 5 of 6
navid.nikbin
in reply to: kandennti

Hi @keqingsong,

 

The following code works fine in previous versions of Fusion 360, for example version 2.0.12888. But it produce error in insider version 2.0.13158. It has broken some functionality of two of my add-ins (3D Voronoi Studio add-in and Voronoi Studio bundle add-in). I guess it may break some add-ins from other developers.

 

I have reported it to the insider community.

Would you please let me know if it is by design and I should change my add-ins and republish them or it is a bug and I can wait for Fusion team to solve it.

import adsk.core, adsk.fusion, traceback
def run(context):
    ui = None
    try: 
        app = adsk.core.Application.get()
        ui = app.userInterface
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        design = app.activeProduct
        design.designType = adsk.fusion.DesignTypes.ParametricDesignType
        # Get the root component of the active design.
        rootComp = design.rootComponent
        # Create a base feature
        baseFeats = rootComp.features.baseFeatures
        baseFeat = baseFeats.add()
        
        baseFeat.startEdit()
        
        # Create construction plane in base feature
        planes = rootComp.constructionPlanes
        planeInput = planes.createInput()
        planeInput.targetBaseOrFormFeature = baseFeat
        planeInput.setByOffset(rootComp.xYConstructionPlane, adsk.core.ValueInput.createByReal(0))
        plane = planes.add(planeInput)
        
        # Create sketch in base feature
        sketches = rootComp.sketches
        sketch = sketches.addToBaseOrFormFeature(plane, baseFeat, True)
     
        vector:adsk.core.Vector3D = adsk.core.Vector3D.create(2, 0, 2)
        matrix = adsk.core.Matrix3D.create()
        matrix.translation = vector
        origin:adsk.core.Point3D = adsk.core.Point3D.create(0, 0, 0)
        xVector:adsk.core.Vector2D = adsk.core.Vector3D.create(1, 0, 0)
        yVector:adsk.core.Vector2D = adsk.core.Vector3D.create(0, 0, 1)
        zVector:adsk.core.Vector3D = adsk.core.Vector3D.create(0, 1, 0)
        
        matrix.setWithCoordinateSystem(origin, xVector, yVector, zVector)
        sketch.transform = matrix
        # Draw a circle.
        circles = sketch.sketchCurves.sketchCircles
        circles.addByCenterRadius(adsk.core.Point3D.create(0, 0, 0), 2)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

In sould produce a sketch with a circle, but it fails and  produce the following error:

 

line 44, in run\n    sketch.transform = matrix\n  File "C:\\Users/Navid/AppData/Local/Autodesk/webdeploy/pre-production/b59ed944fcd4557fa88ff2e06cadb32b1670cb50/Api/Python/packages\\adsk\\fusion.py", line 31074, in _set_transform\n    return _fusion.Sketch__set_transform(self, value)\nRuntimeError: 2 : InternalValidationError : xlMat->isValidNonScaledTransformMatrix()\n'

 

Message 6 of 6
navid.nikbin
in reply to: keqingsong

@keqingsong ,

It seems that setting spinStep Property will show the spinner and the problem of being not wide enough will remain. So potentially we can have both spinner and slider at the same time but for float sliders the edit field will not be wide enough.

 

I changed an FloatSpinnerCommandInput to FloatSliderCommandInput in one of my add-ins for test and you can see the result in the following screenshot after setting spinStep propery:

 

20.png 

 


 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report