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: 

A collection of points does not contain a profile anymore after rotation

1 REPLY 1
Reply
Message 1 of 2
janfrouws
196 Views, 1 Reply

A collection of points does not contain a profile anymore after rotation

Dear fellow scripters,
 
First, fusion, great job with the API support.
I made some elaborate script creating the following profiles and loft through them (see other post). The problem I now encounter is that the (slightly) rotated sketches do not contain a profile anymore. Is there a way to overcome this issue? It has probably something to do with the XY constructionplane "rootComp.xYConstructionPlane" that is used, but the behaviour is the same for the YZ and ZX planes. Is there a 3D sketch type?
After deselecting 'Profile 8' it is clear that the other, rotated, sketches do not form profiles (are orange-like)After deselecting 'Profile 8' it is clear that the other, rotated, sketches do not form profiles (are orange-like) After deselecting 'Profile 8'  it is clear that the other, rotated, sketches do not form profiles (they are not turning orange)
I added a minimum working example with profiles that do, and do not work. Comment any profiles to prevent them from being ploted. Please try it!
 
Hopefully someone can aid me in this, more people must have had this problem..? Any help is greatly appreciated!
Kind Regards,
Jan Frouws
 
Another example:
afbeelding.png
Version info: Windows 10, Fusion 360: V2.0.5119
 
#Author Jan Frouws
# This file is created for the sole purpose of illustrating 
# the existance of closed point clouds that do not generate closed profiles.
import adsk.core, adsk.fusion, traceback
global app, ui, _handlers

app = None
ui  = None

def run(context):
    try:
        global app, ui, _handlers
        ## Prosa
        app = adsk.core.Application.get()
        ui = app.userInterface
        design = app.activeProduct
        rootComp = adsk.fusion.Component.cast(design.rootComponent)

        ## Perform some conditioning on profileCollection        
        sketch = rootComp.sketches.add(rootComp.xYConstructionPlane)
#        sketch = rootComp.sketches.add(rootComp.xZConstructionPlane)
#        sketch = rootComp.sketches.add(rootComp.yZConstructionPlane)

        ProfileCollection = []


#### Working points ### (Paralel to XY plane)
#        ProfileCollection.append([[0.0, 1.0, 2.0, 4.0, 6.0, 8.0, 12.0, 16.0, 20.0, 24.0, 32.0, 40.0, 48.0, 56.0, 64.0, 72.0, 76.0, 77.6, 80.0, 77.6, 76.0, 72.0, 64.0, 56.0, 48.0, 40.0, 32.0, 24.0, 20.0, 16.0, 12.0, 8.0, 6.0, 4.0, 2.0, 1.0, 0.0], [0.0, 2.03, 2.83, 3.94, 4.8, 5.49, 6.58, 7.33, 7.84, 8.13, 8.17, 7.66, 6.78, 5.58, 4.08, 2.26, 1.23, 0.8, 0.0, -0.11, -0.13, -0.18, -0.33, -0.54, -0.83, -1.17, -1.5, -1.88, -2.08, -2.28, -2.4, -2.38, -2.28, -2.08, -1.63, -1.19, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]])
#        ProfileCollection.append([[10.0, 10.875, 11.75, 13.5, 15.25, 17.0, 20.5, 24.0, 27.5, 31.0, 38.0, 45.0, 52.0, 59.0, 66.0, 73.0, 76.5, 77.9, 80.0, 77.9, 76.5, 73.0, 66.0, 59.0, 52.0, 45.0, 38.0, 31.0, 27.5, 24.0, 20.5, 17.0, 15.25, 13.5, 11.75, 10.875, 10.0], [0.0, 1.7255, 2.4055, 3.349, 4.08, 4.6665, 5.593, 6.2305, 6.664, 6.9105, 6.9445, 6.511, 5.763, 4.743, 3.468, 1.921, 1.0455, 0.68, 0.0, -0.0935, -0.1105, -0.153, -0.2805, -0.459, -0.7055, -0.9945, -1.275, -1.598, -1.768, -1.938, -2.04, -2.023, -1.938, -1.768, -1.3855, -1.0115, 0.0], [35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0, 35.0]])
#        ProfileCollection.append([[15.0, 15.8125, 16.625, 18.25, 19.875, 21.5, 24.75, 28.0, 31.25, 34.5, 41.0, 47.5, 54.0, 60.5, 67.0, 73.5, 76.75, 78.05, 80.0, 78.05, 76.75, 73.5, 67.0, 60.5, 54.0, 47.5, 41.0, 34.5, 31.25, 28.0, 24.75, 21.5, 19.875, 18.25, 16.625, 15.8125, 15.0], [0.0, 1.57325, 2.19325, 3.0535, 3.72, 4.25475, 5.0995, 5.68075, 6.076, 6.30075, 6.33175, 5.9365, 5.2545, 4.3245, 3.162, 1.7515, 0.95325, 0.62, 0.0, -0.08525, -0.10075, -0.1395, -0.25575, -0.4185, -0.64325, -0.90675, -1.1625, -1.457, -1.612, -1.767, -1.86, -1.8445, -1.767, -1.612, -1.26325, -0.92225, 0.0], [52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5]])

        ProfileCollection.append([[0.0, 0.75, 1.5, 3.0, 4.5, 6.0, 9.0, 12.0, 15.0, 18.0, 24.0, 30.0, 36.0, 42.0, 48.0, 54.0, 57.0, 58.2, 60.0, 58.2, 57.0, 54.0, 48.0, 42.0, 36.0, 30.0, 24.0, 18.0, 15.0, 12.0, 9.0, 6.0, 4.5, 3.0, 1.5, 0.75, 0.0], [40.0, 41.218, 41.698, 42.364, 42.88, 43.294, 43.948, 44.398, 44.704, 44.878, 44.902, 44.596, 44.068, 43.348, 42.448, 41.356, 40.738, 40.48, 40.0, 39.934, 39.922, 39.892, 39.802, 39.676, 39.502, 39.298, 39.1, 38.872, 38.752, 38.632, 38.56, 38.572, 38.632, 38.752, 39.022, 39.286, 40.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]])
        ProfileCollection.append([[0.0, 0.75, 1.5, 3.0, 4.5, 6.0, 9.0, 12.0, 15.0, 18.0, 24.0, 30.0, 36.0, 42.0, 48.0, 54.0, 57.0, 58.2, 60.0, 58.2, 57.0, 54.0, 48.0, 42.0, 36.0, 30.0, 24.0, 18.0, 15.0, 12.0, 9.0, 6.0, 4.5, 3.0, 1.5, 0.75, 0.0], [28.2844, 29.14566, 29.48507, 29.95601, 30.32088, 30.61362, 31.07607, 31.39427, 31.61065, 31.73368, 31.75065, 31.53428, 31.16092, 30.6518, 30.01541, 29.24324, 28.80625, 28.62381, 28.2844, 28.23773, 28.22925, 28.20803, 28.14439, 28.0553, 27.93226, 27.78801, 27.648, 27.48678, 27.40193, 27.31707, 27.26616, 27.27465, 27.31707, 27.40193, 27.59285, 27.77952, 28.2844], [28.2844, 29.14566, 29.48507, 29.95601, 30.32088, 30.61362, 31.07607, 31.39427, 31.61065, 31.73368, 31.75065, 31.53428, 31.16092, 30.6518, 30.01541, 29.24324, 28.80625, 28.62381, 28.2844, 28.23773, 28.22925, 28.20803, 28.14439, 28.0553, 27.93226, 27.78801, 27.648, 27.48678, 27.40193, 27.31707, 27.26616, 27.27465, 27.31707, 27.40193, 27.59285, 27.77952, 28.2844]])
        ProfileCollection.append([[0.0, 0.75, 1.5, 3.0, 4.5, 6.0, 9.0, 12.0, 15.0, 18.0, 24.0, 30.0, 36.0, 42.0, 48.0, 54.0, 57.0, 58.2, 60.0, 58.2, 57.0, 54.0, 48.0, 42.0, 36.0, 30.0, 24.0, 18.0, 15.0, 12.0, 9.0, 6.0, 4.5, 3.0, 1.5, 0.75, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [40.0, 41.218, 41.698, 42.364, 42.88, 43.294, 43.948, 44.398, 44.704, 44.878, 44.902, 44.596, 44.068, 43.348, 42.448, 41.356, 40.738, 40.48, 40.0, 39.934, 39.922, 39.892, 39.802, 39.676, 39.502, 39.298, 39.1, 38.872, 38.752, 38.632, 38.56, 38.572, 38.632, 38.752, 39.022, 39.286, 40.0]])
 
#### Not working points ### (NOT Paralel to XY plane)
#        ProfileCollection.append([[20.0, 20.73437, 21.46875, 22.9375, 24.40625, 25.875, 28.8125, 31.75, 34.6875, 37.625, 43.5, 49.375, 55.25, 61.125, 67.0, 72.875, 75.8125, 76.9875, 78.75, 76.9875, 75.8125, 72.875, 67.0, 61.125, 55.25, 49.375, 43.5, 37.625, 34.6875, 31.75, 28.8125, 25.875, 24.40625, 22.9375, 21.46875, 20.73437, 20.0], [0.1284, 1.51208, 2.05737, 2.81396, 3.40015, 3.87047, 4.61343, 5.12464, 5.47226, 5.66993, 5.69719, 5.34957, 4.74975, 3.93181, 2.90939, 1.66885, 0.96679, 0.67369, 0.1284, 0.05342, 0.03979, 0.00571, -0.09653, -0.23967, -0.43734, -0.66909, -0.89402, -1.15304, -1.28936, -1.42568, -1.50748, -1.49384, -1.42568, -1.28936, -0.98263, -0.68272, 0.1284], [71.95795, 71.77578, 71.70399, 71.60438, 71.5272, 71.46528, 71.36746, 71.30016, 71.25439, 71.22837, 71.22478, 71.27055, 71.34952, 71.4572, 71.59181, 71.75514, 71.84757, 71.88616, 71.95795, 71.96782, 71.96962, 71.9741, 71.98756, 72.00641, 72.03243, 72.06295, 72.09256, 72.12666, 72.14461, 72.16256, 72.17332, 72.17153, 72.16256, 72.14461, 72.10423, 72.06474, 71.95795]])
#        ProfileCollection.append([[20.0, 20.6875, 21.375, 22.75, 24.125, 25.5, 28.25, 31.0, 33.75, 36.5, 42.0, 47.5, 53.0, 58.5, 64.0, 69.5, 72.25, 73.35, 75.0, 73.35, 72.25, 69.5, 64.0, 58.5, 53.0, 47.5, 42.0, 36.5, 33.75, 31.0, 28.25, 25.5, 24.125, 22.75, 21.375, 20.6875, 20.0], [2.00955, 2.99409, 3.38219, 3.92038, 4.33761, 4.67251, 5.20062, 5.56464, 5.81217, 5.95274, 5.97178, 5.72481, 5.29806, 4.71563, 3.98814, 3.10553, 2.60598, 2.39765, 2.00955, 1.95635, 1.94627, 1.92218, 1.84938, 1.74745, 1.60689, 1.44224, 1.28207, 1.09782, 1.00093, 0.90348, 0.8458, 0.85532, 0.90348, 1.00093, 1.21878, 1.43215, 2.00955], [77.5, 76.91986, 76.69117, 76.37404, 76.12819, 75.93085, 75.61966, 75.40516, 75.2593, 75.17647, 75.16525, 75.31078, 75.56224, 75.90544, 76.33411, 76.85419, 77.14855, 77.27131, 77.5, 77.53135, 77.53729, 77.55148, 77.59438, 77.65444, 77.73727, 77.83429, 77.92867, 78.03724, 78.09433, 78.15175, 78.18574, 78.18013, 78.15175, 78.09433, 77.96596, 77.84023, 77.5]])
#        ProfileCollection.append([[23.33333, 23.89583, 24.45833, 25.58333, 26.70833, 27.83333, 30.08333, 32.33333, 34.58333, 36.83333, 41.33333, 45.83333, 50.33333, 54.83333, 59.33333, 63.83333, 66.08333, 66.98333, 68.33333, 66.98333, 66.08333, 63.83333, 59.33333, 54.83333, 50.33333, 45.83333, 41.33333, 36.83333, 34.58333, 32.33333, 30.08333, 27.83333, 26.70833, 25.58333, 24.45833, 23.89583, 23.33333], [12.00955, 12.43584, 12.60389, 12.83692, 13.01757, 13.16258, 13.39125, 13.54887, 13.65605, 13.71691, 13.72515, 13.61822, 13.43344, 13.18125, 12.86626, 12.4841, 12.2678, 12.17759, 12.00955, 11.98651, 11.98215, 11.97172, 11.9402, 11.89606, 11.8352, 11.76391, 11.69456, 11.61478, 11.57283, 11.53063, 11.50566, 11.50978, 11.53063, 11.57283, 11.66716, 11.75954, 12.00955], [94.82, 94.56216, 94.46052, 94.31957, 94.21031, 94.1226, 93.98429, 93.88896, 93.82413, 93.78732, 93.78233, 93.84701, 93.95877, 94.1113, 94.30182, 94.53297, 94.6638, 94.71836, 94.82, 94.83393, 94.83657, 94.84288, 94.86195, 94.88864, 94.92545, 94.96857, 95.01052, 95.05877, 95.08415, 95.10966, 95.12478, 95.12228, 95.10966, 95.08415, 95.02709, 94.97121, 94.82]])

        ProfileCollection.append([[0.0, 0.75, 1.5, 3.0, 4.5, 6.0, 9.0, 12.0, 15.0, 18.0, 24.0, 30.0, 36.0, 42.0, 48.0, 54.0, 57.0, 58.2, 60.0, 58.2, 57.0, 54.0, 48.0, 42.0, 36.0, 30.0, 24.0, 18.0, 15.0, 12.0, 9.0, 6.0, 4.5, 3.0, 1.5, 0.75, 0.0], [36.9552, 38.08049, 38.52395, 39.13925, 39.61597, 39.99846, 40.60268, 41.01842, 41.30113, 41.46189, 41.48406, 41.20135, 40.71354, 40.04835, 39.21686, 38.20798, 37.63702, 37.39866, 36.9552, 36.89422, 36.88314, 36.85542, 36.77227, 36.65586, 36.49511, 36.30664, 36.12371, 35.91306, 35.8022, 35.69133, 35.62481, 35.6359, 35.69133, 35.8022, 36.05165, 36.29555, 36.9552], [15.3072, 15.7733, 15.95699, 16.21186, 16.40932, 16.56775, 16.81802, 16.99023, 17.10733, 17.17391, 17.1831, 17.066, 16.86394, 16.58841, 16.244, 15.82611, 15.58962, 15.49089, 15.3072, 15.28194, 15.27735, 15.26587, 15.23143, 15.18321, 15.11663, 15.03856, 14.96279, 14.87554, 14.82962, 14.78369, 14.75614, 14.76073, 14.78369, 14.82962, 14.93294, 15.03397, 15.3072]])
        ProfileCollection.append([[0.0, 0.75, 1.5, 3.0, 4.5, 6.0, 9.0, 12.0, 15.0, 18.0, 24.0, 30.0, 36.0, 42.0, 48.0, 54.0, 57.0, 58.2, 60.0, 58.2, 57.0, 54.0, 48.0, 42.0, 36.0, 30.0, 24.0, 18.0, 15.0, 12.0, 9.0, 6.0, 4.5, 3.0, 1.5, 0.75, 0.0], [15.3072, 15.7733, 15.95699, 16.21186, 16.40932, 16.56775, 16.81802, 16.99023, 17.10733, 17.17391, 17.1831, 17.066, 16.86394, 16.58841, 16.244, 15.82611, 15.58962, 15.49089, 15.3072, 15.28194, 15.27735, 15.26587, 15.23143, 15.18321, 15.11663, 15.03856, 14.96279, 14.87554, 14.82962, 14.78369, 14.75614, 14.76073, 14.78369, 14.82962, 14.93294, 15.03397, 15.3072], [36.9552, 38.08049, 38.52395, 39.13925, 39.61597, 39.99846, 40.60268, 41.01842, 41.30113, 41.46189, 41.48406, 41.20135, 40.71354, 40.04835, 39.21686, 38.20798, 37.63702, 37.39866, 36.9552, 36.89422, 36.88314, 36.85542, 36.77227, 36.65586, 36.49511, 36.30664, 36.12371, 35.91306, 35.8022, 35.69133, 35.62481, 35.6359, 35.69133, 35.8022, 36.05165, 36.29555, 36.9552]])

####### Create the sketches that are not commented out
        for Profile in ProfileCollection: # Plot all the uncommented profiles
            nrDP = len(Profile[0])

            # Define the points the spline will fit through.
            points = adsk.core.ObjectCollection.create()
            
            for PointNr in range(nrDP):
                x=Profile[0][PointNr]
                y=Profile[1][PointNr]
                z=Profile[2][PointNr]
                points.add(adsk.core.Point3D.create(x,y,z))
    
            # Create the spline.
            sketch.sketchCurves.sketchFittedSplines.add(points)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
1 REPLY 1
Message 2 of 2
JesusFreke
in reply to: janfrouws

The problem is that the points for the "invalid" profiles aren't actually all in the same plane.

 

I modified your script like so:

 

for index, Profile in enumerate(ProfileCollection): # Plot all the uncommented profiles
print("start profile %d" % index)
nrDP = len(Profile[0])

# Define the points the spline will fit through.
points = adsk.core.ObjectCollection.create()

for PointNr in range(nrDP):
x=Profile[0][PointNr]
y=Profile[1][PointNr]
z=Profile[2][PointNr]
points.add(adsk.core.Point3D.create(x,y,z))

plane = adsk.core.Plane.create(points[0],
points[0].vectorTo(points[1]).crossProduct(points[0].vectorTo(points[2])))

for point in points:
print(app().measureManager.measureMinimumDistance(plane, point).value)

# Create the spline.
spline = sketch.sketchCurves.sketchFittedSplines.add(points)

 

The successful profiles' points were all in the same plane (measureMinimumDistance returned 0), but here are the

results for the last 2 profiles:

 

start profile 3
0.0
0.0
0.0
6.082771454102908e-06
2.2304398696786315e-05
3.897399195363455e-05
7.614527976959434e-05
0.0001065591370805257
0.00014598245006016357
0.00019374191468414257
0.0002716885435828555
0.0003593233522295881
0.00045506897449573957
0.0005510372247604173
0.0006465547989878166
0.0007477071786660786
0.0007916358969854258
0.0008110543430526497
0.0008470541441802699
0.0008238972550398182
0.0008076294761920759
0.0007639260958883674
0.0006789953434511475
0.0005976699992925595
0.000511384508733471
0.00043298720379747956
0.0003496338174855782
0.00026492975807419436
0.00022482772102124464
0.00019013786141791256
0.00014575711204780725
0.00010655778207689297
8.425609339557787e-05
5.5416892184646866e-05
3.4916552634091486e-05
1.6894931272486845e-05
0.0
start profile 4
0.0
0.0
0.0
6.082771454102909e-06
2.2304398696786315e-05
3.897399195363455e-05
7.614527976959434e-05
0.0001065591370805257
0.00014598245006016357
0.0001937419146841426
0.0002716885435828555
0.0003593233522295881
0.00045506897449573957
0.0005510372247604173
0.0006465547989878166
0.0007477071786660786
0.0007916358969854258
0.0008110543430526497
0.0008470541441802699
0.0008238972550398182
0.0008076294761920759
0.0007639260958883674
0.0006789953434511475
0.0005976699992925595
0.000511384508733471
0.00043298720379747956
0.0003496338174855782
0.00026492975807419436
0.00022482772102124467
0.00019013786141791256
0.00014575711204780725
0.00010655778207689297
8.425609339557787e-05
5.5416892184646866e-05
3.4916552634091486e-05
1.6894931272486845e-05
0.0

Of course, with floating point math, there is expected to be a small amount of non-planarity,  but I think fusion's point tolerance is 1e-6, while your points are up to almost 1e-3 away from the plane.

 

I'm assuming that the "invalid" profiles are externally rotated versions of the first profile? If so, here's an alternate way to rotate them using fusion's apis.

 

#Author Jan Frouws
# This file is created for the sole purpose of illustrating
# the existance of closed point clouds that do not generate closed profiles.
import adsk.core, adsk.fusion, traceback, math
global app, ui, _handlers

app = None
ui = None

import _pydevd_bundle.pydevd_comm
_pydevd_bundle.pydevd_comm.MAX_IO_MSG_SIZE = 131072



def app():
return adsk.core.Application.get()


def root() -> adsk.fusion.Component:
return design().rootComponent


def ui():
return app().userInterface


def brep():
return adsk.fusion.TemporaryBRepManager.get()


def design():
return adsk.fusion.Design.cast(app().activeProduct)


def setup_document(document_name="test"):
preview_doc = None
saved_camera = None
for document in app().documents:
if document.name == document_name:
preview_doc = document
break
if preview_doc is not None:
preview_doc.activate()
saved_camera = app().activeViewport.camera
preview_doc.close(False)

preview_doc = app().documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
preview_doc.name = document_name
preview_doc.activate()
if saved_camera is not None:
is_smooth_transition_bak = saved_camera.isSmoothTransition
saved_camera.isSmoothTransition = False
app().activeViewport.camera = saved_camera
saved_camera.isSmoothTransition = is_smooth_transition_bak
app().activeViewport.camera = saved_camera
design().designType = adsk.fusion.DesignTypes.DirectDesignType

def run(context):
try:
setup_document()

profile_definition = [[0.0, 0.75, 1.5, 3.0, 4.5, 6.0, 9.0, 12.0, 15.0, 18.0, 24.0, 30.0, 36.0, 42.0, 48.0, 54.0, 57.0, 58.2, 60.0, 58.2, 57.0, 54.0, 48.0, 42.0, 36.0, 30.0, 24.0, 18.0, 15.0, 12.0, 9.0, 6.0, 4.5, 3.0, 1.5, 0.75, 0.0], [40.0, 41.218, 41.698, 42.364, 42.88, 43.294, 43.948, 44.398, 44.704, 44.878, 44.902, 44.596, 44.068, 43.348, 42.448, 41.356, 40.738, 40.48, 40.0, 39.934, 39.922, 39.892, 39.802, 39.676, 39.502, 39.298, 39.1, 38.872, 38.752, 38.632, 38.56, 38.572, 38.632, 38.752, 39.022, 39.286, 40.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]

points = adsk.core.ObjectCollection.create()

for index in range(len(profile_definition[0])):
x = profile_definition[0][index]
y = profile_definition[1][index]
z = profile_definition[2][index]
points.add(adsk.core.Point3D.create(x, y, z))

profiles = []

for angle in [0, 22.5, 45, 67.5, 90]:
new_occurrence = root().occurrences.addNewComponent(adsk.core.Matrix3D.create())
sketch = new_occurrence.component.sketches.add(root().xYConstructionPlane)
spline = sketch.sketchCurves.sketchFittedSplines.add(points)
profiles.append(sketch.profiles[0])

transform = new_occurrence.transform
transform.setToRotation(
math.radians(angle),
adsk.core.Vector3D.create(1, 0, 0),
adsk.core.Point3D.create(0, 0, 0))
new_occurrence.transform = transform

loft_input = root().features.loftFeatures.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
for profile in profiles:
loft_input.loftSections.add(profile)
root().features.loftFeatures.add(loft_input)

except:
print('Failed:\n{}'.format(traceback.format_exc()))


 

loft.png

 

 

 

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