Loft profile setDirectionEndCondition

Loft profile setDirectionEndCondition

Anonymous
Not applicable
507 Views
2 Replies
Message 1 of 3

Loft profile setDirectionEndCondition

Anonymous
Not applicable

Hi everyone,

I've been trying to create a loft between two sketches, and I'd like to set the loft to be driven by the direction of the first spline.

I know I should be using 

returnValue = loftSection_var.setDirectionEndCondition()

but I have no idea where I should put it. I've been trying all day. I am new to this and I feel like something very basic is missing from my understanding.

Here's my code:

 

"""
Created on Sun Feb 25 15:52:28 2018

@author: balintgabor
"""

import adsk.core, adsk.fusion, traceback

def run(context):
  ui = None
  try:
    app = adsk.core.Application.get()
    ui  = app.userInterface
            
    design = app.activeProduct
    
    # Get the root component of the active design.
    rootComp = design.rootComponent
    
    ######
    
    # Create a new sketch on the xy plane.
    sketches = rootComp.sketches
    xyPlane = rootComp.xYConstructionPlane
    sketch = sketches.add(xyPlane)
    
    # Create an object collection for the points.
    points = adsk.core.ObjectCollection.create()  
    
    Steps = 10 #How many steps to go through
    R = Steps - 2
    
    points.add(adsk.core.Point3D.create(0, 0, 0)) # This plots the origin
    
    
    Bin1 = range(0, R, 2)
    Bin2 = range(1, R, 2)
    
    xCoord = 0
    yCoord = 0
    hossz = 1
    
    for i in range(R):
    
        if i in Bin1:
            xCoord = xCoord + 1
            yCoord = 0 + hossz
            points.add(adsk.core.Point3D.create(xCoord, yCoord, 0))
    
        if i in Bin2:
            xCoord = xCoord + 1
            yCoord = 0 - hossz
            points.add(adsk.core.Point3D.create(xCoord, yCoord, 0))
    
    
    # Create the spline.
    spline1 = sketch.sketchCurves.sketchFittedSplines.add(points)
   
       
    #create second sketch
    planes = rootComp.constructionPlanes
            
    ####        # Create construction plane input
    
    planeInput = planes.createInput()
            
            # Add construction plane by offset
    offsetValue = adsk.core.ValueInput.createByReal(5.0)
    planeInput.setByOffset(rootComp.xYConstructionPlane, offsetValue)
    planeOne = planes.add(planeInput)
    
    sketch2 = rootComp.sketches
    offsetplane = planeOne
    sketch = sketch2.add(offsetplane)
    
    lines = sketch.sketchCurves.sketchLines;
    line1 = lines.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(8, 0, 0))
    
    
    ########LOFT
    
    openProfile1 = adsk.fusion.Path.create(spline1, adsk.fusion.ChainedCurveOptions.noChainedCurves)
    openProfile2 = adsk.fusion.Path.create(line1, adsk.fusion.ChainedCurveOptions.noChainedCurves)
    
    
     # Create loft feature input
    loftFeats = rootComp.features.loftFeatures
    loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
    loftSectionsObj = loftInput.loftSections
    loftSectionsObj.add(openProfile1)
    loftSectionsObj.add(openProfile2)
    loftInput.isSolid = False
    
    # Create loft feature
    loftFeats.add(loftInput)
    
    

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

 any help welcome!


loft looks like this nowloft looks like this nowit should look like thisit should look like this

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

marshaltu
Autodesk
Autodesk
Accepted solution

Hello,

 

Please take a look at the line marked as red to show how to set direction end condition.

 

Thanks,

Marshal

 

"""
Created on Sun Feb 25 15:52:28 2018

@author: balintgabor
"""

import adsk.core, adsk.fusion, traceback

def run(context):
  ui = None
  try:
    app = adsk.core.Application.get()
    ui  = app.userInterface
            
    design = app.activeProduct
    
    # Get the root component of the active design.
    rootComp = design.rootComponent
    
    ######
    
    # Create a new sketch on the xy plane.
    sketches = rootComp.sketches
    xyPlane = rootComp.xYConstructionPlane
    sketch = sketches.add(xyPlane)
    
    # Create an object collection for the points.
    points = adsk.core.ObjectCollection.create()  
    
    Steps = 10 #How many steps to go through
    R = Steps - 2
    
    points.add(adsk.core.Point3D.create(0, 0, 0)) # This plots the origin
    
    
    Bin1 = range(0, R, 2)
    Bin2 = range(1, R, 2)
    
    xCoord = 0
    yCoord = 0
    hossz = 1
    
    for i in range(R):
    
        if i in Bin1:
            xCoord = xCoord + 1
            yCoord = 0 + hossz
            points.add(adsk.core.Point3D.create(xCoord, yCoord, 0))
    
        if i in Bin2:
            xCoord = xCoord + 1
            yCoord = 0 - hossz
            points.add(adsk.core.Point3D.create(xCoord, yCoord, 0))
    
    
    # Create the spline.
    spline1 = sketch.sketchCurves.sketchFittedSplines.add(points)
   
       
    #create second sketch
    planes = rootComp.constructionPlanes
            
    ####        # Create construction plane input
    
    planeInput = planes.createInput()
            
            # Add construction plane by offset
    offsetValue = adsk.core.ValueInput.createByReal(5.0)
    planeInput.setByOffset(rootComp.xYConstructionPlane, offsetValue)
    planeOne = planes.add(planeInput)
    
    sketch2 = rootComp.sketches
    offsetplane = planeOne
    sketch = sketch2.add(offsetplane)
    
    lines = sketch.sketchCurves.sketchLines;
    line1 = lines.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(8, 0, 0))
    
    
    ########LOFT
    
    openProfile1 = adsk.fusion.Path.create(spline1, adsk.fusion.ChainedCurveOptions.noChainedCurves)
    openProfile2 = adsk.fusion.Path.create(line1, adsk.fusion.ChainedCurveOptions.noChainedCurves)
    
    
     # Create loft feature input
    loftFeats = rootComp.features.loftFeatures
    loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
    loftSectionsObj = loftInput.loftSections
    section1 = loftSectionsObj.add(openProfile1)
    section1.setDirectionEndCondition(adsk.core.ValueInput.createByString('0.0 deg'), adsk.core.ValueInput.createByReal(1.0))
    loftSectionsObj.add(openProfile2)
    loftInput.isSolid = False
    
    # Create loft feature
    loftFeats.add(loftInput)
    
    

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


Marshal Tu
Fusion Developer
>
0 Likes
Message 3 of 3

Anonymous
Not applicable

thank you so much!

0 Likes