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: 

Unstitch return value

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
imajar
193 Views, 3 Replies

Unstitch return value

Hello,

 

In the script below I create a simple cube, then I unstitch that cube into its faces. 

 

In the gui, this all works as it should, but line 36, "unstitchedbox=unstitch.add(entities)" returns null despite the UI showing the unstitched faces, shouldn't the variable "unstichedbox" return an unstitch feature containing the newly unstitched faces?  Or what am I doing wrong here?  (I am having the same problem with the stitch feature successfully stitching surfaces into a solid body but returning null).

 

Thank You,

 

import adsk.core, adsk.fusion, adsk.cam, traceback

def CreateBox():  
    # Get TemporaryBRepManager
    tempBrepMgr = adsk.fusion.TemporaryBRepManager.get()

    centerPoint = adsk.core.Point3D.create(0.0, 10.0, 0.0);
    lengthDir = adsk.core.Vector3D.create(1.0, 0.0, 0.0)
    widthDir = adsk.core.Vector3D.create(0.0, 1.0, 0.0)
    orientedBoundingBox3D = adsk.core.OrientedBoundingBox3D.create(centerPoint, lengthDir, widthDir, 5.0, 6.0, 2.0)
    # Create box                                                              
    box = tempBrepMgr.createBox(orientedBoundingBox3D)
    return box
    
def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        design.designType = adsk.fusion.DesignTypes.DirectDesignType
        rootComp = design.rootComponent
        features = rootComp.features
        bodies = rootComp.bRepBodies
        
        # Create a temporary solid box
        box = CreateBox()
        newbox=bodies.add(box)

        #Unstitch the box
        unstitch=features.unstitchFeatures
        entities=adsk.core.ObjectCollection.create()
        entities.add(newbox)
        unstitchedbox=unstitch.add(entities) #unstitchedbox is null?
        print("unstitchedbox Type: ",unstitchedbox.classType())        
        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 


Aaron Jarrett, PE
Inventor 2019 | i7-6700K 64GB NVidia M4000
LinkedIn

Life is Good.
3 REPLIES 3
Message 2 of 4
kandennti
in reply to: imajar

Hi ajarrett.

 

I don't know why but unstitch doesn't seem to work with DirectDesignType.

 

Temporarily change to ParametricDesignType and unstitch.

Change to DirectDesignType again
Then what about?

 

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        design.designType = adsk.fusion.DesignTypes.DirectDesignType
        rootComp = design.rootComponent
        features = rootComp.features
        bodies = rootComp.bRepBodies
        
        # Create a temporary solid box
        box = CreateBox()
        newbox=bodies.add(box)
        
        #ParametricDesignType
        design.designType = adsk.fusion.DesignTypes.ParametricDesignType #this
        
        #Unstitch the box
        unstitch=features.unstitchFeatures
        entities=adsk.core.ObjectCollection.create()
        entities.add(newbox)
        unstitchedbox=unstitch.add(entities)
        
        #DirectDesignType
        design.designType = adsk.fusion.DesignTypes.DirectDesignType #this
        
        print("unstitchedbox Type: ",unstitchedbox.classType())        
        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Message 3 of 4
imajar
in reply to: kandennti

That works for me.

 

Digging in a bit more, it looks like there may be other features that don't work in ParametricDesignType.  After a successful unstitch, If I did stitch.bodies.count in parametric design it returns 0, in DirectDesignType it returns 1. . .

 

Anyway, not sure if this is a bug or if stitch is not supposed to be used in ParametricDesignType designs?

 

Thanks


Aaron Jarrett, PE
Inventor 2019 | i7-6700K 64GB NVidia M4000
LinkedIn

Life is Good.
Message 4 of 4
zxynine
in reply to: imajar

I know this thread is pretty old, but I am currently running into the same issue with stitchFeatures. Im trying to stitch regardless of design type and im doing it on execute preview so I cannot quickly switch design types. Have any of you found a better solution? I cannot even access the bodies attr because the stitchFeature is None, yet the faces still get stitched into a body (A return of None should mean it failed, yet it hasn't.).

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