Is it possible to isolate a component via API?

Is it possible to isolate a component via API?

luca.giorcelli9CG7C
Contributor Contributor
762 Views
3 Replies
Message 1 of 4

Is it possible to isolate a component via API?

luca.giorcelli9CG7C
Contributor
Contributor

I'm trying to isolate a component via API in order to export a thumbnail using Viewport.saveAsImageFile(filename, width, height). I've hundreds of component, so I need to do that programmatically.

 

In the API reference I cannot find any method to accomplish this simple task.

 

Any help is appreciated.

0 Likes
Accepted solutions (1)
763 Views
3 Replies
Replies (3)
Message 2 of 4

Rushikesh.kadam
Autodesk
Autodesk
Accepted solution

@luca.giorcelli9CG7C here are few references I found related to isolation of component. 

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-bb040782-b1b0-4ffe-b0f7-3cd97533b9c5

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7cd5b52f-26bb-4890-9c37-2dc48213d685

Also, refer to below sample code where in I created two components and then isolated one and performed unisolate operation on the same component.

 

import adsk.core, adsk.fusion, traceback
import time
def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        
        # Create a document.
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
 
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)

        # Get the root component of the active design
        rootComp = design.rootComponent
                
        # Get extrude features
        extrudes = rootComp.features.extrudeFeatures

        # Create sketch     
        sketches = rootComp.sketches   
        sketch = sketches.add(rootComp.xZConstructionPlane)
        sketchCircles = sketch.sketchCurves.sketchCircles
        centerPoint = adsk.core.Point3D.create(0, 0, 0)
        circle = sketchCircles.addByCenterRadius(centerPoint, 5.0)
        
        # Get the profile defined by the circle
        prof = sketch.profiles.item(0)
        
        # Create another sketch
        sketchVertical = sketches.add(rootComp.yZConstructionPlane)
        sketchCirclesVertical = sketchVertical.sketchCurves.sketchCircles
        centerPointVertical = adsk.core.Point3D.create(0, 10, 0)
        cicleVertical = sketchCirclesVertical.addByCenterRadius(centerPointVertical, 0.5)    
        
        # Get the profile defined by the vertical circle
        profVertical = sketchVertical.profiles.item(0)

        distance = adsk.core.ValueInput.createByReal(5)
        extrude1 = extrudes.addSimple(prof, distance, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)

        distance2 = adsk.core.ValueInput.createByReal(5)
        extrude2 = extrudes.addSimple(profVertical, distance2, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)

        occ1 = rootComp.allOccurrences.item(0)
        occ1.isIsolated = True

        ui.messageBox('Component 1 isloated. It will be unisolated on OK')

        occ1.isIsolated = False

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

 

 

If it works out, do click on accept solution button.

 

Regards,

Rushikesh Kadam




Rushikesh Kadam
Senior QA Engineer
Quality Assurance
Autodesk, Inc.


Message 3 of 4

luca.giorcelli9CG7C
Contributor
Contributor

It was so simple!!!

isIsolated

 

But where is located this command in the API reference?

 

Message 4 of 4

Rushikesh.kadam
Autodesk
Autodesk

Here is the link to reference 

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-bb040782-b1b0-4ffe-b0f7-3cd97533b9c5

 

If it worked out, do click on accept solution button.

 

Regards,

Rushikesh Kadam.




Rushikesh Kadam
Senior QA Engineer
Quality Assurance
Autodesk, Inc.


0 Likes