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: 

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

5 REPLIES 5
Reply
Message 1 of 6
lauren.booher
911 Views, 5 Replies

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

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

 

 

Tags (2)
5 REPLIES 5
Message 2 of 6

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

Message 3 of 6

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.

Message 4 of 6
ekinsb
in reply to: lauren.booher

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
Message 5 of 6

Any tips on how to set area properties of the profile.
Message 6 of 6
ekinsb
in reply to: lauren.booher

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

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