Loft wrong orientation

Loft wrong orientation

shutov441-vuz
Contributor Contributor
538 Views
1 Reply
Message 1 of 2

Loft wrong orientation

shutov441-vuz
Contributor
Contributor

Hi, i am have a txt file with set of points, these points creating a closing curve. In result i need to create a solid body following the curve. In first step i am create a copies of curve and move they up and down. Next i create a surface by using a Loft function and at the last step i using Thikness function to create a solid. All curves are roughly similar but still have some differences. The curve must be on the surface of the solid and not inside (for creation Multi-Axis contour operation). For a while, everything worked well, but at some point, curves began to appear that cannot be oriented outward, the loft normals are oriented inward of the contour, this happens by chance and occurs in 1 out of 10 cases. This prevents me from automating the process. I do not understand why loft is turned inside out. I need your help. The only thing that helped me was to open the curve, but this creates a hole. I will attach my code that loads the curve and creates a solid.loft.png

    def import_object(self, accuracy, factor, splitter, name_in_fusion):
        self.name_in_fusion = name_in_fusion

        with io.open(self.path + '\\' + self.name, 'r', encoding='utf-8-sig') as f:
            points = adsk.core.ObjectCollection.create()
            line = f.readline()
            data = []
            counter = 0
            while line:
                pntStrArr = line.split(splitter)
                for pntStr in pntStrArr:
                    try:
                        data.append(float(pntStr))
                    except:
                        break
            
                if len(data) >= 3 :
                    point = adsk.core.Point3D.create(data[0] * factor, data[1] * factor, data[2] * factor)
                    if counter == accuracy:
                        points.add(point)
                        counter = 0
                    else:
                        counter += 1

                line = f.readline()
                data.clear()

        points.add(points.item(0))

        if points.count:
            sketch = root.sketches.add(root.xYConstructionPlane)
            sketch.sketchCurves.sketchFittedSplines.add(points)
            sketch.name = name_in_fusion
            self.sketch = sketch
        else:
            ui.messageBox('No valid points', title)
def create_surface(self, thickness, height, is_reverse):
        if self.sketch == None:
            ui.messageBox('The sketch does not exist!')
            return

        objs :adsk.core.ObjectCollection = 
        self.__get_sketch_all_entities(self.sketch)

        cloneSketch_firstHalf = root.sketches.add(root.xYConstructionPlane)
        cloneSketch_secondHalf = 
        root.sketches.add(root.xYConstructionPlane)

        transform_firstHalf = adsk.core.Matrix3D.create()
        transform_firstHalf.translation = set_vector3D(0, 0, height / 2)

        transform_secondHalf = adsk.core.Matrix3D.create()
        transform_secondHalf.translation = set_vector3D(0, 0, -height / 2)

        self.sketch.copy(objs, transform_firstHalf, cloneSketch_firstHalf)
        self.sketch.copy(objs, transform_secondHalf, 
        cloneSketch_secondHalf)

        path_top = root.features.createPath(cloneSketch_firstHalf.sketchCurves[0])
        path_bot = root.features.createPath(cloneSketch_secondHalf.sketchCurves[0])

        loftFeats = root.features.loftFeatures
        loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        loftSectionsObj = loftInput.loftSections
        loftSectionsObj.add(path_bot)
        loftSectionsObj.add(path_top)
        loftInput.isSolid = True

        loftFeat = loftFeats.add(loftInput)

        cloneSketch_firstHalf.deleteMe()
        cloneSketch_secondHalf.deleteMe()

        thickenFeatures = root.features.thickenFeatures
        inputSurfaces = adsk.core.ObjectCollection.create()
        bodies = loftFeat.bodies
        for body in bodies:
            inputSurfaces.add(body)
        thicknessSelf = adsk.core.ValueInput.createByReal(thickness)
        thickenInput = thickenFeatures.createInput(inputSurfaces, thicknessSelf, False, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        thickenFeatures.add(thickenInput)

        loftFeat.deleteMe()

 

0 Likes
539 Views
1 Reply
  • API
Reply (1)
Message 2 of 2

BrianEkins
Mentor
Mentor

Since I don't know what to look for, it's not obvious to me what the difference is between the good and the bad pictures.  Also, to diagnose this it will be best to have a full test case, the point data you are reading in, and a model to run it in if it is dependent on the model geometry.

 

You said the problem isn't consistent. Does it happen all the time with the same text file?  Hopefully it does, so if you can provide a text file that shows the problem and one that works correctly, along with some details of why the one that's wrong is wrong, that will help a lot.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes