Turning off history capture prevents code execution

Turning off history capture prevents code execution

lachycharts
Participant Participant
441 Views
1 Reply
Message 1 of 2

Turning off history capture prevents code execution

lachycharts
Participant
Participant

A small snippet of my code is below which creates a shell and then a tangent plane on it's outer edge. The code then undergoes a lot of iterations and so I would like to turn history capture off to improve performence, however when I disable history capture, a plane through the centre of the extrusion occurs. Why does history capture affect execution of the code?

 

Thanks

 

 

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

def run(context):

    ui = None

    #Get application
    app = adsk.core.Application.get()
    
    #Get application ui
    ui  = app.userInterface
    
    #Get open design (open document)
    design = app.activeProduct
    
    #Get root component.
    root = design.rootComponent
    
    #Get sketches
    sketches = root.sketches
    
    #Delete all sketches and features first.
    print('sketches count', root.sketches.count)
    for i in range(root.sketches.count):
        print('Success:', root.sketches.item(i).deleteMe())
    for i in range(root.features.count):
        print('Success:', root.features.item(i).deleteMe())
    for i in range(root.constructionPlanes.count):
        print('Success:', root.constructionPlanes.item(i).deleteMe())
    
    #Get XY sketches.
    sketchXZ = root.sketches.add(root.xZConstructionPlane);

    cyl_H = 20
    cyl_R = 5
    cyl_thickness = 0.4
    cyl_r = cyl_R - cyl_thickness
    
    #Draw big cylinder.
    circles = sketchXZ.sketchCurves.sketchCircles
    circles.addByCenterRadius(adsk.core.Point3D.create(0,0,0),cyl_R)
    circles.addByCenterRadius(adsk.core.Point3D.create(0,0,0),cyl_r)
    
    #Go through and get the profile with the smallest area.
    profiles = sketchXZ.profiles
    if(profiles.item(0).areaProperties().area > profiles.item(1).areaProperties().area):
        cylProfile = profiles.item(1)
    else:
        cylProfile = profiles.item(0)
        
    #Extrude this profile.
    extrudes = root.features.extrudeFeatures  
    extInput = extrudes.createInput(cylProfile, adsk.fusion.FeatureOperations.JoinFeatureOperation)  
    distance = adsk.core.ValueInput.createByReal(cyl_H)
    extInput.setDistanceExtent(False, distance)
    cylExtrude = extrudes.add(extInput)
    print('Cylinder Extruded')
    
    #Get the external face (bigger area)
    cylOutsideFace = cylExtrude.sideFaces.item(0)
    if(cylExtrude.sideFaces.item(0).area < cylExtrude.sideFaces.item(1).area):
        cylOutsideFace = cylExtrude.sideFaces.item(1)
    print('Got outside face')

    #Get planes.
    planes = root.constructionPlanes
    print('planes = root.constructionPlanes')
    planeInput = planes.createInput()
    print('planeInput = planes.createInput()')
    angle = adsk.core.ValueInput.createByString('0 deg') 
    print('angle = adsk.core.ValueInput.createByString(0 deg)')
    planeInput.setByTangent(cylOutsideFace, angle, cylProfile)
    print('planeInput.setByTangent(cylOutsideFace, angle, cylProfile)')
    tangentPlane = planes.add(planeInput)
    print('tangentPlane = planes.add(planeInput)')

 

0 Likes
442 Views
1 Reply
Reply (1)
Message 2 of 2

marshaltu
Autodesk
Autodesk

Hello,

 

Thank you for reporting the issue to us. It could be a bug of ConstrnctionPlane API. I logged UP-28626 to track it. We will investigate and fix it in future updates.

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes