Most efficient way to model 1000s of objects?

Most efficient way to model 1000s of objects?

Anonymous
Not applicable
516 Views
2 Replies
Message 1 of 3

Most efficient way to model 1000s of objects?

Anonymous
Not applicable

I need to efficiently create a lattice composed of cylinders with a sphere at each intersection. I have the code for creating the positions of each beam in the lattice working efficiently but actually creating the bodies is crushingly slow (hours).

 

At the end of the process the lattice will be continuous (ie could be combined into a single body) but currently the input is just a list of pairs of points so i'm just creating the beams in the order that they presented in the list. The current process is:

for each pair of points:
  create a sketch at first point on the plane normal to the line
  add a circle to the sketch
  sweep circle along the line
  delete the sketch
for each unique point:
create a sketch at the point
sketch a circle
revolve circle to create sphere
delete the sketch
combine all beams and spheres into a single body

 

I feel like Fusion might be the wrong tool for a modelling job like this but I thought i'd ask the community if there's a more efficient way. Is it better to incrementally add to a single lattice body? I imagine fusion is struggling to manage the thousands of individual bodies that are generated before combining.

0 Likes
517 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor

Take a look at my class from last year's Autodesk University. Temporary B-Rep will be the fastest.

 

https://www.autodesk.com/autodesk-university/class/Understanding-Geometry-and-B-Rep-Inventor-and-Fus...

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

JesusFreke
Advocate
Advocate

I did a little test with my fscad framework, which uses temporary brep objects under the hood, and it was able to do 10,000 spheres + 9,999 connecting cylinders in a bit under 2 minutes.

 

import adsk
import adsk.core
import adsk.fusion
import time

from fscad import *

def design():
points = []
for i in range(1, 10000):
points.append((i, i, i))

i1 = iter(points)
i2 = iter(points)
first = next(i2)

objects = []

objects.append(Sphere(.1).translate(*first))

for p1, p2 in zip(i1, i2):
print(p1)
objects.append(Sphere(.1).translate(*p2))
point1 = adsk.core.Point3D.create(*p1)
point2 = adsk.core.Point3D.create(*p2)

cyl = Cylinder(point2.distanceTo(point1), .05)

transform = adsk.core.Matrix3D.create()
transform.setToRotateTo(adsk.core.Vector3D.create(0, 0, 1), point1.vectorTo(point2))

cyl.transform(transform).translate(*p1)
objects.append(cyl)

u = Union(*objects)

u.create_occurrence(False, scale=.1)

def run(_):
start = time.time()
run_design(design, message_box_on_error=False, document_name=__name__)
end = time.time()
print(end-start)

ball_and_cylinder.jpg

0 Likes