Draw and extrude multiple rectangles -- connect LineList to Profile?

Draw and extrude multiple rectangles -- connect LineList to Profile?

Anonymous
Not applicable
1,374 Views
5 Replies
Message 1 of 6

Draw and extrude multiple rectangles -- connect LineList to Profile?

Anonymous
Not applicable

I'm trying to draw an open ended box programatically. I know I need a profile to extrude, but I can't find the profile created by the last SketchLineList.

 

Maybe I need to draw the shapes explicitly, but it seems like I should be able to extrude them and have the original sketch.

 

For example, I want to draw this and extrude the highlighted sections here:

sketch.png

 

While I read in the docs that the profile argument can be a single profile, a single planar face, I can't figure out how to how to get from a LineList to an extruded object.

 

oSketchLineList = lines.addTwoPointRectangle(adsk.core.Point3D.create(x1, y1, 0), adsk.core.Point3D.create(x2, y2,0))
  

After this, I try to get the last profile added through something like:

   p_index = sketch.profiles.count
   print("working profile %d" % p_index)
   profile = sketch.profiles.item(p_index-1) 

This produces [1, 2, 3, 5, 5]. So then I created a separate counter for the profiles. This worked even less well.

 

One way I did get things to work was to create a different sketch for each extrusion. This was really ugly, but at least sketch.profiles.item(0) worked consistently.

 

Another thought would be to create a complex search routine for profiles that looked at how many loops they had, etc. I tried to attach the files below, but I had to put my code at this gist: https://gist.github.com/tbbooher/042d4ddb7c201d393cfd8d3f545d9a15.

 

I would love to build an addin to build bookshelves that the community can use, but need to better understand the object model first.

 

Thanks!

 

Lauren

 

 

0 Likes
1,375 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

It is so strange, every example has sketch.profiles.items(0) or extrudes all profiles.

0 Likes
Message 3 of 6

Anonymous
Not applicable

I've been working with this awhile. This seems like a very basic problem. Any help very appreciated that would steer me in the right direction to solve this. I would think that extruding multiple components is a pretty basic spec for an api.

0 Likes
Message 4 of 6

ekinsb
Alumni
Alumni
Sorry for the delay in responding. We've all been on holiday this past week.

I need to create a more detailed write-up of how sketches work in Fusion and add it to the online help but here's a short description that hopefully will help.

When you draw geometry in a sketch you're not directly creating profiles but Fusion is examining the geometry in the sketch to look for closed and overlapping areas and a profile is created for each one of these areas. For example, if I draw rectangle there will be a single profile because there's only one closed area in the sketch. Now if I draw a second rectangle that crosses the original to create a cross shape there are now five profiles. You can try this interactively and see this visually by seeing the areas available when you extrude.

If you're creating a complex sketch and need a specific profile you have to figure out what makes that profile unique From the others so you can find it. One way is that from a profile you can find out which sketch entities are used to define it. Anothwe option is the area properties of the profile.

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 5 of 6

Anonymous
Not applicable
Any tips on how to set area properties of the profile.
0 Likes
Message 6 of 6

ekinsb
Alumni
Alumni

It's not possible to directly set area properties.  Area properties are the result of the current geometry.  To change the area properties you need to edit the sketch entities, which will cause the profiles to be recomputed and the area properties to change.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes