Difficulties Obtaining Path for Lofting

Difficulties Obtaining Path for Lofting

dozerdroid
Enthusiast Enthusiast
478 Views
2 Replies
Message 1 of 3

Difficulties Obtaining Path for Lofting

dozerdroid
Enthusiast
Enthusiast

I have written a simple program to loft two lines but I cannot correctly obtain the path for lofting, any assistance most welcome. Creating the planes, sketches and lines work fine however the lines below don't work so I assume I am missing something basic ? Thanks. 

        
        path1 = rootComp.features.createPath(line1)
        path2 = rootComp.features.createPath(line2)

 

 

def createNewComponent(rootComp😞
    allOccs = rootComp.occurrences
    newOcc = allOccs.addNewComponent(adsk.core.Matrix3D.create())
    return newOcc.component

def run(context😞
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        design = app.activeProduct                              # active design
        rootComp = design.rootComponent                         # root component of active design, top level in browser
        hullComponent = createNewComponent(rootComp)            # create a new hull component
        hullComponent.name = "hull"
        
        planesObj = hullComponent.constructionPlanes            # returns planes object
        xyPlane = hullComponent.xYConstructionPlane             # variable representing the xy plane

        # add construction plane 1, add sketch and line

        planeInput1 = planesObj.createInput()                   # create construction planes
        offsetValue1 = adsk.core.ValueInput.createByReal(1.0)
        planeInput1.setByOffset(xyPlane, offsetValue1)
        plane1 = planesObj.add(planeInput1)                
        plane1.name = "bulkhead 1"
        sketchesObj = hullComponent.sketches                    # returns sketches object
        sketch1 = sketchesObj.add(plane1)
        sketch1.name = "bulkhead 1 sketch 1"                    # create sketch on construction plane

        lines1 = sketch1.sketchCurves.sketchLines
        line1 = lines1.addByTwoPoints(adsk.core.Point3D.create(2.03.00.0),adsk.core.Point3D.create(4.05.00.0))
        
        # add construction plane 2, add sketch and line

        planeInput2 = planesObj.createInput()
        offsetValue2 = adsk.core.ValueInput.createByReal(3.0)
        planeInput2.setByOffset(xyPlane, offsetValue2)
        plane2 = planesObj.add(planeInput2)                
        plane2.name = "bulkhead 2"
        sketch2 = sketchesObj.add(plane2)
        sketch2.name = "bulkhead 2 sketch 1"                    # create sketch on construction plane

        lines2 = sketch2.sketchCurves.sketchLines
        line2 = lines2.addByTwoPoints(adsk.core.Point3D.create(3.04.00.0),adsk.core.Point3D.create(5.06.00.0))
      
        # everything above works fine, so lets try a loft between these two lines
        
        path1 = rootComp.features.createPath(line1)
        path2 = rootComp.features.createPath(line2)

        #I also tried as below ?
        #path1 = adsk.fusion.Path.create(line1, adsk.fusion.ChainedCurveOptions.noChainedCurves)
        #path2 = adsk.fusion.Path.create(line2, adsk.fusion.ChainedCurveOptions.noChainedCurves)

            # create a surface loft feature between the two lines
 
        new_feature = adsk.fusion.FeatureOperations.NewBodyFeatureOperation
        loft_features = rootComp.features.loftFeatures
        loft_input = loft_features.createInput(new_feature)

        loft_sections = loft_input.loftSections
        loft_sections.add(path1)
        loft_sections.add(path2)
        loft_features.add(loft_input)
  
0 Likes
Accepted solutions (1)
479 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi @dozerdroid .

 

Since we are creating a sketch with a new occurrence, we will need to get the createPath from the same features as the sketch.

・・・
        # everything above works fine, so lets try a loft between these two lines
        
        # path1 = rootComp.features.createPath(line1)
        # path2 = rootComp.features.createPath(line2)
        path1 = hullComponent.features.createPath(line1)
        path2 = hullComponent.features.createPath(line2)

・・・

 

The same will be true for loftFeatures.

        # create a surface loft feature between the two lines
 
        new_feature = adsk.fusion.FeatureOperations.NewBodyFeatureOperation
        # loft_features = rootComp.features.loftFeatures
        loft_features = hullComponent.features.loftFeatures
        loft_input = loft_features.createInput(new_feature)

 

0 Likes
Message 3 of 3

dozerdroid
Enthusiast
Enthusiast

Thank you for your assistance.

0 Likes